mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-01-22 11:21:12 +00:00
Additional tweaks in aggregate model.
Introduced Owner.addVisit(…) to avoid that state transition to live in controller code. Slightly polished some assertions in ClinicServiceTests.
This commit is contained in:
parent
b559077f14
commit
472575378c
3 changed files with 33 additions and 8 deletions
|
|
@ -199,13 +199,16 @@ class ClinicServiceTests {
|
|||
Pet pet7 = owner6.getPet(7);
|
||||
int found = pet7.getVisits().size();
|
||||
Visit visit = new Visit();
|
||||
pet7.addVisit(visit);
|
||||
visit.setDescription("test");
|
||||
|
||||
owner6.addVisit(pet7.getId(), visit);
|
||||
this.owners.save(owner6);
|
||||
|
||||
owner6 = this.owners.findById(6);
|
||||
assertThat(pet7.getVisits().size()).isEqualTo(found + 1);
|
||||
assertThat(pet7.getVisits()).allMatch(value -> value.getId() != null);
|
||||
|
||||
assertThat(pet7.getVisits()) //
|
||||
.hasSize(found + 1) //
|
||||
.allMatch(value -> value.getId() != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -213,9 +216,10 @@ class ClinicServiceTests {
|
|||
Owner owner6 = this.owners.findById(6);
|
||||
Pet pet7 = owner6.getPet(7);
|
||||
Collection<Visit> visits = pet7.getVisits();
|
||||
assertThat(visits).hasSize(2);
|
||||
Visit[] visitArr = visits.toArray(new Visit[visits.size()]);
|
||||
assertThat(visitArr[0].getDate()).isNotNull();
|
||||
|
||||
assertThat(visits) //
|
||||
.hasSize(2) //
|
||||
.element(0).extracting(Visit::getDate).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue