Skip to content

Commit

Permalink
[wenhao] increase unit test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhao committed Oct 15, 2019
1 parent 0b170f6 commit 4ee4577
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
12 changes: 3 additions & 9 deletions config/githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
#!/usr/bin/env bash

# Color codes
red='\033[0;31m'
yellow='\033[0;33m'
blue='\033[0;34m'
NC='\033[0m' # No colors

# Regex & Usage
commit_regex="^(\[\S+(\s\&\s\S+)*\]|merge)\s"
error_message="Aborting commit. Commit message must start with [YOUR NAME]."
usage="[YOUR NAME] Commit Message."

if ! grep -qE "$commit_regex" "$1"; then
printf "${red}$error_message\n"
printf "${yellow}Commit Regex: ${NC}${commit_regex}\n"
printf "${red}Usage: ${NC}${usage}\n"
printf "error_message\n"
printf "Commit Regex: ${commit_regex}\n"
printf "Usage: ${usage}\n"
exit 1
fi
6 changes: 1 addition & 5 deletions config/githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env bash

# Color codes
red='\033[0;31m'
yellow='\033[0;33m'

command="./gradlew build"

${command}

if ! [ $? -eq 0 ]; then
printf "${red}Make sure successfully execute command: ${yellow}$command${red}."
printf "Make sure successfully execute command: $command."
exit 1
fi
3 changes: 3 additions & 0 deletions src/test/java/com/github/wenhao/jpa/integration/InTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public void should_be_able_to_find_by_using_in() {
// given
Person jack = new PersonBuilder()
.name("Jack")
.nickName("Jack")
.age(18)
.build();
Person eric = new PersonBuilder()
.name("Eric")
.nickName("Eric")
.age(20)
.build();
personRepository.save(jack);
Expand All @@ -58,6 +60,7 @@ public void should_be_able_to_find_by_using_in() {
// when
Specification<Person> specification = Specifications.<Person>and()
.in(isNotBlank(jack.getName()), "name", Arrays.asList("Jack", "Eric"))
.in("name", Arrays.asList("Jack", "Eric"))
.build();

List<Person> persons = personRepository.findAll(specification);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public void should_be_able_to_find_by_using_in() {
// given
Person jack = new PersonBuilder()
.name("Jack")
.nickName("Jack")
.age(18)
.build();
Person eric = new PersonBuilder()
.name("Eric")
.nickName("Eric")
.age(20)
.build();
personRepository.save(jack);
Expand All @@ -58,6 +60,7 @@ public void should_be_able_to_find_by_using_in() {
// when
Specification<Person> specification = Specifications.<Person>and()
.notIn(isNotBlank(jack.getName()), "name", Arrays.asList("Eric"))
.notIn("nickName", Arrays.asList("Eric"))
.build();

List<Person> persons = personRepository.findAll(specification);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void should_be_able_to_find_by_using_not_like() {
// when
Specification<Person> specification = Specifications.<Person>and()
.notLike(isNotBlank(jack.getName()), "name", "%ac%")
.notLike(isNotBlank(jack.getNickName()), "name", "%og%", "%ri%")
.notLike("name", "%og%", "%ri%")
.build();

List<Person> persons = personRepository.findAll(specification);
Expand Down

0 comments on commit 4ee4577

Please sign in to comment.