diff --git a/backend/src/test/java/org/raddatz/familienarchiv/person/PersonServiceTest.java b/backend/src/test/java/org/raddatz/familienarchiv/person/PersonServiceTest.java index 43afccd7..9cabe1ce 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/person/PersonServiceTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/person/PersonServiceTest.java @@ -1045,4 +1045,18 @@ class PersonServiceTest { verify(personRepository, org.mockito.Mockito.atMost(8)).searchByName(any()); } + + @Test + void resolveByName_samePersonFromTwoTokens_appearsOnce() { + // Both token fetches return the same person id — fetchPool's putIfAbsent must dedup so the + // candidate is classified once, not twice. + Person clara = Person.builder().id(UUID.randomUUID()).firstName("Clara").lastName("Cram").build(); + when(personRepository.searchByName("clara")).thenReturn(List.of(clara)); + when(personRepository.searchByName("cram")).thenReturn(List.of(clara)); + + NameMatches result = personService.resolveByName("Clara Cram"); + + assertThat(result.direct()).hasSize(1); + assertThat(result.partial()).isEmpty(); + } }