From 79bcd1b31bb5817874f1954ff6535a26aa1a2f64 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Jun 2026 01:31:07 +0200 Subject: [PATCH] test(person): pin fetchPool dedup when one person matches two tokens (#763 review) Assert that when the same person id is returned by two different token fetches, the person appears exactly once in the result -- pinning fetchPool's putIfAbsent dedup so a future refactor can't silently double-classify a candidate. Co-Authored-By: Claude Opus 4.8 --- .../familienarchiv/person/PersonServiceTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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(); + } }