package org.raddatz.familienarchiv.person;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class PersonTest {

    @Test
    void getDisplayName_withAllFields() {
        Person person = Person.builder()
                .title("Dr.")
                .firstName("Walter")
                .lastName("de Gruyter")
                .build();
        assertThat(person.getDisplayName()).isEqualTo("Dr. Walter de Gruyter");
    }

    @Test
    void getDisplayName_withoutTitle() {
        Person person = Person.builder()
                .firstName("Clara")
                .lastName("Cram")
                .build();
        assertThat(person.getDisplayName()).isEqualTo("Clara Cram");
    }

    @Test
    void getDisplayName_withNullFirstName() {
        Person person = Person.builder()
                .lastName("Gesellschafter des Verlages")
                .build();
        assertThat(person.getDisplayName()).isEqualTo("Gesellschafter des Verlages");
    }

    @Test
    void getDisplayName_withTitleAndNullFirstName() {
        Person person = Person.builder()
                .title("Tante")
                .lastName("Molly")
                .build();
        assertThat(person.getDisplayName()).isEqualTo("Tante Molly");
    }

    @Test
    void personType_defaultsToPerson() {
        Person person = Person.builder()
                .firstName("Clara")
                .lastName("Cram")
                .build();
        assertThat(person.getPersonType()).isEqualTo(PersonType.PERSON);
    }
}
