test(person): alias-only and notes-only updates do not publish display-name event
Two regression guards on the "iff different" semantics in updatePerson. Person.alias and Person.notes are not part of getDisplayName() — they live outside DisplayNameFormatter — so changing only those fields must not fire PersonDisplayNameChangedEvent. If a future refactor accidentally pulls either field into the display name (or trips the comparison), these tests catch it before transcription blocks get rewritten with stale "@OldAlias" text. Refs #362 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -277,6 +277,46 @@ class PersonServiceTest {
|
|||||||
.contains("Frau");
|
.contains("Frau");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void updatePerson_doesNotPublishEvent_whenOnlyAliasChanges() {
|
||||||
|
UUID id = UUID.randomUUID();
|
||||||
|
Person existing = Person.builder()
|
||||||
|
.id(id).firstName("Auguste").lastName("Raddatz")
|
||||||
|
.personType(PersonType.PERSON).alias("old alias").build();
|
||||||
|
|
||||||
|
when(personRepository.findById(id)).thenReturn(Optional.of(existing));
|
||||||
|
when(personRepository.save(any())).thenAnswer(inv -> inv.getArgument(0));
|
||||||
|
|
||||||
|
PersonUpdateDTO dto = new PersonUpdateDTO();
|
||||||
|
dto.setPersonType(PersonType.PERSON);
|
||||||
|
dto.setFirstName("Auguste"); dto.setLastName("Raddatz");
|
||||||
|
dto.setAlias("new alias");
|
||||||
|
|
||||||
|
personService.updatePerson(id, dto);
|
||||||
|
|
||||||
|
verify(eventPublisher, never()).publishEvent(any(PersonDisplayNameChangedEvent.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void updatePerson_doesNotPublishEvent_whenOnlyNotesChanges() {
|
||||||
|
UUID id = UUID.randomUUID();
|
||||||
|
Person existing = Person.builder()
|
||||||
|
.id(id).firstName("Auguste").lastName("Raddatz")
|
||||||
|
.personType(PersonType.PERSON).notes("first note").build();
|
||||||
|
|
||||||
|
when(personRepository.findById(id)).thenReturn(Optional.of(existing));
|
||||||
|
when(personRepository.save(any())).thenAnswer(inv -> inv.getArgument(0));
|
||||||
|
|
||||||
|
PersonUpdateDTO dto = new PersonUpdateDTO();
|
||||||
|
dto.setPersonType(PersonType.PERSON);
|
||||||
|
dto.setFirstName("Auguste"); dto.setLastName("Raddatz");
|
||||||
|
dto.setNotes("revised note");
|
||||||
|
|
||||||
|
personService.updatePerson(id, dto);
|
||||||
|
|
||||||
|
verify(eventPublisher, never()).publishEvent(any(PersonDisplayNameChangedEvent.class));
|
||||||
|
}
|
||||||
|
|
||||||
// ─── findOrCreateByAlias ─────────────────────────────────────────────────
|
// ─── findOrCreateByAlias ─────────────────────────────────────────────────
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user