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:
Oliver Drotbohm 2022-01-06 11:00:14 +01:00 committed by Dave Syer
parent b559077f14
commit 472575378c
3 changed files with 33 additions and 8 deletions

View file

@ -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();
}
}