some tests

This commit is contained in:
Marc O. Sandlus 2024-03-18 17:41:58 +01:00
parent 1a3fad80ee
commit cc7b8fcf9b

View File

@ -60,19 +60,63 @@ class HsOfficePersonEntityUnitTest {
assertThat(actualDisplay).isEqualTo("NP some family name, some given name"); assertThat(actualDisplay).isEqualTo("NP some family name, some given name");
} }
@Test
void toShortStringWithSalutationAndTitleReturnsSalutationAndTitle() {
final var givenPersonEntity = HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON)
.salutation("Frau")
.title("Dr.")
.familyName("some family name")
.givenName("some given name")
.build();
final var actualDisplay = givenPersonEntity.toShortString();
assertThat(actualDisplay).isEqualTo("NP Frau Dr. some family name, some given name");
}
@Test
void toShortStringWithSalutationAndWithoutTitleReturnsSalutation() {
final var givenPersonEntity = HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON)
.salutation("Frau")
.familyName("some family name")
.givenName("some given name")
.build();
final var actualDisplay = givenPersonEntity.toShortString();
assertThat(actualDisplay).isEqualTo("NP Frau some family name, some given name");
}
@Test
void toShortStringWithoutSalutationAndWithTitleReturnsTitle() {
final var givenPersonEntity = HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON)
.title("Dr. Dr.")
.familyName("some family name")
.givenName("some given name")
.build();
final var actualDisplay = givenPersonEntity.toShortString();
assertThat(actualDisplay).isEqualTo("NP Dr. Dr. some family name, some given name");
}
@Test @Test
void toStringWithAllFieldsReturnsAllButUuid() { void toStringWithAllFieldsReturnsAllButUuid() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.title("Dr.")
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
.build(); .build();
final var actualDisplay = givenPersonEntity.toString(); final var actualDisplay = givenPersonEntity.toString();
assertThat(actualDisplay).isEqualTo("person(personType='NP', tradeName='some trade name', familyName='some family name', givenName='some given name')"); assertThat(actualDisplay).isEqualTo("person(personType='NP', tradeName='some trade name', title='Dr.', familyName='some family name', givenName='some given name')");
} }
@Test @Test
@ -86,4 +130,42 @@ class HsOfficePersonEntityUnitTest {
assertThat(actualDisplay).isEqualTo("person(familyName='some family name', givenName='some given name')"); assertThat(actualDisplay).isEqualTo("person(familyName='some family name', givenName='some given name')");
} }
@Test
void toStringWithSalutationAndTitleRetursSalutationAndTitle() {
final var givenPersonEntity = HsOfficePersonEntity.builder()
.salutation("Herr")
.title("Prof. Dr.")
.familyName("some family name")
.givenName("some given name")
.build();
final var actualDisplay = givenPersonEntity.toString();
assertThat(actualDisplay).isEqualTo("person(salutation='Herr', title='Prof. Dr.', familyName='some family name', givenName='some given name')");
}
@Test
void toStringWithSalutationAndWithoutTitleSkipsTitle() {
final var givenPersonEntity = HsOfficePersonEntity.builder()
.salutation("Herr")
.familyName("some family name")
.givenName("some given name")
.build();
final var actualDisplay = givenPersonEntity.toString();
assertThat(actualDisplay).isEqualTo("person(salutation='Herr', familyName='some family name', givenName='some given name')");
}
@Test
void toStringWithoutSalutationAndWithTitleSkipsSalutation() {
final var givenPersonEntity = HsOfficePersonEntity.builder()
.title("some title")
.familyName("some family name")
.givenName("some given name")
.build();
final var actualDisplay = givenPersonEntity.toString();
assertThat(actualDisplay).isEqualTo("person(title='some title', familyName='some family name', givenName='some given name')");
}
} }