feat: PersonNameParser enhancements and Person model refactor (#209-#213) #215

Merged
marcel merged 25 commits from feat/issues-209-213-person-parser-enhancements into main 2026-04-08 18:48:00 +02:00
Showing only changes of commit 5106d277f1 - Show all commits

View File

@@ -0,0 +1,66 @@
package org.raddatz.familienarchiv.service;
import org.junit.jupiter.api.Test;
import org.raddatz.familienarchiv.PostgresContainerConfig;
import org.raddatz.familienarchiv.model.Person;
import org.raddatz.familienarchiv.model.PersonType;
import org.raddatz.familienarchiv.repository.PersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import software.amazon.awssdk.services.s3.S3Client;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@ActiveProfiles("test")
@Import(PostgresContainerConfig.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
class PersonServiceIntegrationTest {
@MockitoBean S3Client s3Client;
@Autowired PersonService personService;
@Autowired PersonRepository personRepository;
@Test
void findOrCreateByAlias_skipReturnsNull_noRecordCreated() {
Person result = personService.findOrCreateByAlias("Briefumschlag aus Java");
assertThat(result).isNull();
assertThat(personRepository.findAll()).isEmpty();
}
@Test
void findOrCreateByAlias_institutionStoresFullNameInLastName() {
Person result = personService.findOrCreateByAlias("Arthur Collignon GmbH");
assertThat(result).isNotNull();
assertThat(result.getPersonType()).isEqualTo(PersonType.INSTITUTION);
assertThat(result.getFirstName()).isNull();
assertThat(result.getLastName()).isEqualTo("Arthur Collignon GmbH");
assertThat(result.getDisplayName()).isEqualTo("Arthur Collignon GmbH");
}
@Test
void findOrCreateByAlias_groupStoresFullNameInLastName() {
Person result = personService.findOrCreateByAlias("Geschwister de Gruyter");
assertThat(result).isNotNull();
assertThat(result.getPersonType()).isEqualTo(PersonType.GROUP);
assertThat(result.getFirstName()).isNull();
assertThat(result.getLastName()).isEqualTo("Geschwister de Gruyter");
}
@Test
void findOrCreateByAlias_personSplitsNameNormally() {
Person result = personService.findOrCreateByAlias("Clara Cram");
assertThat(result).isNotNull();
assertThat(result.getPersonType()).isEqualTo(PersonType.PERSON);
assertThat(result.getFirstName()).isEqualTo("Clara");
assertThat(result.getLastName()).isEqualTo("Cram");
}
}