feat(relationship): add generation to PersonNodeDTO + update all sites (#689)
PersonNodeDTO is a positional record. The optional Integer generation field is inserted between deathYear and familyMember so all four construction sites stay readable without a builder. - RelationshipService.getFamilyNetwork → populates with person.getGeneration() (the Stammbaum's strict-rank source on the frontend). - RelationshipInferenceService.findAllFor → populates the same way; inference UI does not consume it but the field travels along for consistency. - RelationshipControllerTest fixtures pass null. Refs #689 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -93,7 +93,7 @@ class RelationshipControllerTest {
|
||||
@Test
|
||||
@WithMockUser(username = "testuser", authorities = {"READ_ALL"})
|
||||
void getNetwork_returns200_with_NetworkDTO_for_authenticated_user() throws Exception {
|
||||
PersonNodeDTO node = new PersonNodeDTO(PERSON_ID, "Alice Müller", 1900, 1980, true);
|
||||
PersonNodeDTO node = new PersonNodeDTO(PERSON_ID, "Alice Müller", 1900, 1980, null, true);
|
||||
RelationshipDTO edge = new RelationshipDTO(
|
||||
UUID.randomUUID(), PERSON_ID, OTHER_ID,
|
||||
"Alice Müller", 1900, 1980,
|
||||
@@ -111,7 +111,7 @@ class RelationshipControllerTest {
|
||||
@Test
|
||||
@WithMockUser(username = "testuser", authorities = {"READ_ALL"})
|
||||
void getInferredRelationships_returns200_with_list_for_authenticated_user() throws Exception {
|
||||
PersonNodeDTO relative = new PersonNodeDTO(OTHER_ID, "Bob Müller", 1930, null, true);
|
||||
PersonNodeDTO relative = new PersonNodeDTO(OTHER_ID, "Bob Müller", 1930, null, null, true);
|
||||
InferredRelationshipWithPersonDTO inferred =
|
||||
new InferredRelationshipWithPersonDTO(relative, "Großvater", 2);
|
||||
when(relationshipService.getInferredRelationships(PERSON_ID))
|
||||
|
||||
@@ -237,6 +237,22 @@ class RelationshipServiceTest {
|
||||
assertThat(result.edges().get(0).relatedPersonId()).isEqualTo(bob.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getFamilyNetwork_populates_generation_on_PersonNodeDTO() {
|
||||
Person walter = Person.builder().id(UUID.randomUUID()).lastName("Raddatz")
|
||||
.familyMember(true).generation(2).build();
|
||||
Person clara = Person.builder().id(UUID.randomUUID()).lastName("Raddatz")
|
||||
.familyMember(true).generation(3).build();
|
||||
when(personService.findAllFamilyMembers()).thenReturn(List.of(walter, clara));
|
||||
when(relationshipRepository.findAllByRelationTypeIn(any())).thenReturn(List.of());
|
||||
|
||||
NetworkDTO result = service.getFamilyNetwork();
|
||||
|
||||
assertThat(result.nodes()).hasSize(2);
|
||||
assertThat(result.nodes().stream().map(n -> n.generation()).toList())
|
||||
.containsExactlyInAnyOrder(2, 3);
|
||||
}
|
||||
|
||||
// --- helpers ---
|
||||
|
||||
private static Person person(String name) {
|
||||
|
||||
Reference in New Issue
Block a user