Skip to content

Commit

Permalink
[wenhao] update equal unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhao committed Nov 30, 2019
1 parent 38a3661 commit 4f574dd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public PersonBuilder idCard(String number) {
return this;
}

public PersonBuilder married(boolean married) {
this.person.setMarried(married);
return this;
}

public Person build() {
return this.person;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ public void should_be_able_to_find_by_using_equal() {
Person person = new PersonBuilder()
.name("Jack")
.age(18)
.married(true)
.build();
personRepository.save(person);

// when
Specification<Person> specification = Specifications.<Person>and()
.eq(isNotBlank(person.getName()), "name", person.getName())
.eq("married", Boolean.TRUE)
.build();

Optional<Person> result = personRepository.findOne(specification);
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/com/github/wenhao/jpa/model/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class Person {
private String nickName;
private String company;
private Date birthday;
private boolean married;
@OneToOne(cascade = ALL)
@JoinColumn(name = "id_card_id")
private IdCard idCard;
Expand Down Expand Up @@ -106,6 +107,14 @@ public void setBirthday(Date birthday) {
this.birthday = birthday;
}

public boolean isMarried() {
return married;
}

public void setMarried(final boolean married) {
this.married = married;
}

public IdCard getIdCard() {
return idCard;
}
Expand Down

0 comments on commit 4f574dd

Please sign in to comment.