From cc7b8fcf9b190c14868c8e5b5fc8aeef5387375e Mon Sep 17 00:00:00 2001 From: "Marc O. Sandlus" Date: Mon, 18 Mar 2024 17:41:58 +0100 Subject: [PATCH] some tests --- .../person/HsOfficePersonEntityUnitTest.java | 84 ++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityUnitTest.java index 1eec872b..9d85fb22 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityUnitTest.java @@ -60,19 +60,63 @@ class HsOfficePersonEntityUnitTest { 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 void toStringWithAllFieldsReturnsAllButUuid() { final var givenPersonEntity = HsOfficePersonEntity.builder() .uuid(UUID.randomUUID()) .personType(HsOfficePersonType.NATURAL_PERSON) .tradeName("some trade name") + .title("Dr.") .familyName("some family name") .givenName("some given name") .build(); 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 @@ -86,4 +130,42 @@ class HsOfficePersonEntityUnitTest { 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')"); + } + }