From f150ea209141e573947df42f57c42f50cb8976fa Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 24 Jan 2024 15:18:44 +0100 Subject: [PATCH] more detailed person type (#12) Co-authored-by: Michael Hoennig Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/12 Reviewed-by: Michael Hierweck --- .../HsOfficeCoopAssetsTransactionEntity.java | 1 - .../office/person/HsOfficePersonEntity.java | 1 - .../hs/office/person/HsOfficePersonType.java | 22 ++++-- .../person/HsOfficePersonTypeConverter.java | 29 ++++++++ .../hs-office/hs-office-person-schemas.yaml | 10 ++- .../resources/db/changelog/050-rbac-base.sql | 2 +- .../db/changelog/210-hs-office-person.sql | 8 +- .../218-hs-office-person-test-data.sql | 16 ++-- .../228-hs-office-partner-test-data.sql | 11 +-- ...OfficeDebitorControllerAcceptanceTest.java | 2 +- .../HsOfficeDebitorEntityUnitTest.java | 4 +- ...fficeDebitorRepositoryIntegrationTest.java | 14 ++-- ...iceMembershipControllerAcceptanceTest.java | 4 +- .../HsOfficeMembershipEntityUnitTest.java | 2 +- ...ceMembershipRepositoryIntegrationTest.java | 10 +-- .../hs/office/migration/ImportOfficeData.java | 74 ++++++++++--------- ...OfficePartnerControllerAcceptanceTest.java | 2 +- .../HsOfficePartnerEntityUnitTest.java | 8 +- ...fficePartnerRepositoryIntegrationTest.java | 10 +-- .../office/partner/TestHsOfficePartner.java | 4 +- ...sOfficePersonControllerAcceptanceTest.java | 32 ++++---- .../HsOfficePersonEntityPatcherUnitTest.java | 6 +- .../person/HsOfficePersonEntityUnitTest.java | 20 ++--- ...OfficePersonRepositoryIntegrationTest.java | 8 +- .../HsOfficePersonTypeConverterUnitTest.java | 24 ++++++ .../hs/office/person/TestHsOfficePerson.java | 2 +- ...eRelationshipControllerAcceptanceTest.java | 12 +-- ...RelationshipRepositoryIntegrationTest.java | 8 +- ...ceSepaMandateControllerAcceptanceTest.java | 4 +- 29 files changed, 209 insertions(+), 141 deletions(-) create mode 100644 src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverter.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverterUnitTest.java diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntity.java index 0f1b3600..69e26183 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntity.java @@ -11,7 +11,6 @@ import org.hibernate.annotations.GenericGenerator; import jakarta.persistence.*; import java.math.BigDecimal; -import java.text.DecimalFormat; import java.time.LocalDate; import java.util.UUID; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java index 94a1a74e..2803136b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java @@ -35,7 +35,6 @@ public class HsOfficePersonEntity implements HasUuid, Stringifyable { private UUID uuid; @Column(name = "persontype") - @Enumerated(EnumType.STRING) private HsOfficePersonType personType; @Column(name = "tradename") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonType.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonType.java index aae35eaf..c9372919 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonType.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonType.java @@ -1,9 +1,21 @@ package net.hostsharing.hsadminng.hs.office.person; public enum HsOfficePersonType { - UNKNOWN, - NATURAL, - LEGAL, - SOLE_REPRESENTATION, - JOINT_REPRESENTATION + UNKNOWN_PERSON_TYPE("??"), + NATURAL_PERSON("NP"), // a human being + LEGAL_PERSON("LP"), // incorporated legal entity like A/S, GmbH, e.K., eG, e.V. + INCORPORATED_FIRM("IF"), // registered business partnership like OHG, Partnerschaftsgesellschaft + UNINCORPORATED_FIRM("UF"), // unregistered partnership, association etc. like GbR, ARGE, community of heirs + PUBLIC_INSTITUTION("PI"); // entities under public law like government entities, KdöR, AöR + + public final String shortName; + + HsOfficePersonType(final String shortName) { + this.shortName = shortName; + } + + @Override + public String toString() { + return shortName; + } } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverter.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverter.java new file mode 100644 index 00000000..8c268900 --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverter.java @@ -0,0 +1,29 @@ +package net.hostsharing.hsadminng.hs.office.person; + +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; +import java.util.stream.Stream; + +@Converter(autoApply = true) +public class HsOfficePersonTypeConverter implements AttributeConverter { + + @Override + public String convertToDatabaseColumn(HsOfficePersonType category) { + if (category == null) { + return null; + } + return category.shortName; + } + + @Override + public HsOfficePersonType convertToEntityAttribute(String code) { + if (code == null) { + return null; + } + + return Stream.of(HsOfficePersonType.values()) + .filter(c -> c.shortName.equals(code)) + .findFirst() + .orElseThrow(IllegalArgumentException::new); + } +} diff --git a/src/main/resources/api-definition/hs-office/hs-office-person-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-person-schemas.yaml index 34636034..3e651feb 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-person-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-person-schemas.yaml @@ -6,10 +6,12 @@ components: HsOfficePersonType: type: string enum: - - NATURAL # a human - - LEGAL # e.g. Corp., Inc., AG, GmbH, eG - - SOLE_REPRESENTATION # e.g. OHG, GbR - - JOINT_REPRESENTATION # e.g. community of heirs + - UNKNOWN_PERSON + - NATURAL_PERSON + - LEGAL_PERSON + - INCORPORATED_FIRM + - UNINCORPORATED_FIRM + - PUBLIC_INSTITUTION HsOfficePerson: type: object diff --git a/src/main/resources/db/changelog/050-rbac-base.sql b/src/main/resources/db/changelog/050-rbac-base.sql index 3254b464..0f111177 100644 --- a/src/main/resources/db/changelog/050-rbac-base.sql +++ b/src/main/resources/db/changelog/050-rbac-base.sql @@ -770,8 +770,8 @@ do $$ if '${HSADMINNG_POSTGRES_RESTRICTED_USERNAME}'='restricted' then create role restricted; + grant all privileges on all tables in schema public to restricted; end if; - -- grant all privileges on all tables in schema public to ${HSADMINNG_POSTGRES_RESTRICTED_USERNAME}; end $$ --// diff --git a/src/main/resources/db/changelog/210-hs-office-person.sql b/src/main/resources/db/changelog/210-hs-office-person.sql index 3f404b65..6a331277 100644 --- a/src/main/resources/db/changelog/210-hs-office-person.sql +++ b/src/main/resources/db/changelog/210-hs-office-person.sql @@ -4,7 +4,13 @@ --changeset hs-office-person-MAIN-TABLE:1 endDelimiter:--// -- ---------------------------------------------------------------------------- -CREATE TYPE HsOfficePersonType AS ENUM ('UNKNOWN', 'NATURAL', 'LEGAL', 'SOLE_REPRESENTATION', 'JOINT_REPRESENTATION'); +CREATE TYPE HsOfficePersonType AS ENUM ( + '??', -- unknown + 'NP', -- natural person + 'LP', -- legal person + 'IF', -- incorporated firm + 'UF', -- unincorporated firm + 'PI'); -- public institution CREATE CAST (character varying as HsOfficePersonType) WITH INOUT AS IMPLICIT; diff --git a/src/main/resources/db/changelog/218-hs-office-person-test-data.sql b/src/main/resources/db/changelog/218-hs-office-person-test-data.sql index 35946088..09d51b1a 100644 --- a/src/main/resources/db/changelog/218-hs-office-person-test-data.sql +++ b/src/main/resources/db/changelog/218-hs-office-person-test-data.sql @@ -59,14 +59,14 @@ end; $$; do language plpgsql $$ begin - call createHsOfficePersonTestData('LEGAL', 'First GmbH'); - call createHsOfficePersonTestData('NATURAL', null, 'Smith', 'Peter'); - call createHsOfficePersonTestData('LEGAL', 'Second e.K.', 'Sandra', 'Miller'); - call createHsOfficePersonTestData('SOLE_REPRESENTATION', 'Third OHG'); - call createHsOfficePersonTestData('SOLE_REPRESENTATION', 'Fourth e.G.'); - call createHsOfficePersonTestData('JOINT_REPRESENTATION', 'Erben Bessler', 'Mel', 'Bessler'); - call createHsOfficePersonTestData('NATURAL', null, 'Bessler', 'Anita'); - call createHsOfficePersonTestData('NATURAL', null, 'Winkler', 'Paul'); + call createHsOfficePersonTestData('LP', 'First GmbH'); + call createHsOfficePersonTestData('NP', null, 'Smith', 'Peter'); + call createHsOfficePersonTestData('LP', 'Second e.K.', 'Sandra', 'Miller'); + call createHsOfficePersonTestData('IF', 'Third OHG'); + call createHsOfficePersonTestData('IF', 'Fourth e.G.'); + call createHsOfficePersonTestData('UF', 'Erben Bessler', 'Mel', 'Bessler'); + call createHsOfficePersonTestData('NP', null, 'Bessler', 'Anita'); + call createHsOfficePersonTestData('NP', null, 'Winkler', 'Paul'); end; $$; --// diff --git a/src/main/resources/db/changelog/228-hs-office-partner-test-data.sql b/src/main/resources/db/changelog/228-hs-office-partner-test-data.sql index 759c48c9..11f02ffd 100644 --- a/src/main/resources/db/changelog/228-hs-office-partner-test-data.sql +++ b/src/main/resources/db/changelog/228-hs-office-partner-test-data.sql @@ -19,7 +19,6 @@ declare relatedPerson hs_office_person; relatedContact hs_office_contact; relatedDetailsUuid uuid; - birthday date; begin idName := cleanIdentifier( personTradeOrFamilyName|| '-' || contactLabel); currentTask := 'creating partner test-data ' || idName; @@ -33,18 +32,14 @@ begin where c.label = contactLabel into relatedContact; - if relatedPerson.persontype = 'NATURAL' then - birthday := '1987-10-31'::date; - end if; - raise notice 'creating test partner: %', idName; raise notice '- using person (%): %', relatedPerson.uuid, relatedPerson; raise notice '- using contact (%): %', relatedContact.uuid, relatedContact; - if relatedPerson.persontype = 'NATURAL' then + if relatedPerson.persontype = 'NP' then insert - into hs_office_partner_details (uuid, birthName, birthday) - values (uuid_generate_v4(), 'Meyer', '1987-10-31') + into hs_office_partner_details (uuid, birthName, birthday, birthPlace) + values (uuid_generate_v4(), 'Meyer', '1987-10-31', 'Hamburg') returning uuid into relatedDetailsUuid; else insert diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java index 1de3bb06..7085fe53 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java @@ -83,7 +83,7 @@ class HsOfficeDebitorControllerAcceptanceTest { { "debitorNumber": 1000111, "debitorNumberSuffix": 11, - "partner": { "person": { "personType": "LEGAL" } }, + "partner": { "person": { "personType": "LEGAL_PERSON" } }, "billingContact": { "label": "first contact" }, "vatId": null, "vatCountryCode": null, diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java index 270431b9..1e40cfd7 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java @@ -17,7 +17,7 @@ class HsOfficeDebitorEntityUnitTest { .debitorNumberSuffix((byte)67) .partner(HsOfficePartnerEntity.builder() .person(HsOfficePersonEntity.builder() - .personType(HsOfficePersonType.LEGAL) + .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .build()) .details(HsOfficePartnerDetailsEntity.builder().birthName("some birth name").build()) @@ -29,7 +29,7 @@ class HsOfficeDebitorEntityUnitTest { final var result = given.toString(); - assertThat(result).isEqualTo("debitor(1234567: LEGAL some trade name: som)"); + assertThat(result).isEqualTo("debitor(1234567: LP some trade name: som)"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java index 97eb49b1..7b1ef4b2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java @@ -211,9 +211,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest { // then allTheseDebitorsAreReturned( result, - "debitor(1000111: LEGAL First GmbH: fir)", - "debitor(1000212: LEGAL Second e.K.: sec)", - "debitor(1000313: SOLE_REPRESENTATION Third OHG: thi)"); + "debitor(1000111: LP First GmbH: fir)", + "debitor(1000212: LP Second e.K.: sec)", + "debitor(1000313: IF Third OHG: thi)"); } @ParameterizedTest @@ -231,8 +231,8 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest { // then: exactlyTheseDebitorsAreReturned(result, - "debitor(1000111: LEGAL First GmbH: fir)", - "debitor(1000120: LEGAL First GmbH: fif)"); + "debitor(1000111: LP First GmbH: fir)", + "debitor(1000120: LP First GmbH: fif)"); } @Test @@ -260,7 +260,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest { final var result = debitorRepo.findDebitorByDebitorNumber(1000313); // then - exactlyTheseDebitorsAreReturned(result, "debitor(1000313: SOLE_REPRESENTATION Third OHG: thi)"); + exactlyTheseDebitorsAreReturned(result, "debitor(1000313: IF Third OHG: thi)"); } } @@ -276,7 +276,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest { final var result = debitorRepo.findDebitorByOptionalNameLike("third contact"); // then - exactlyTheseDebitorsAreReturned(result, "debitor(1000313: SOLE_REPRESENTATION Third OHG: thi)"); + exactlyTheseDebitorsAreReturned(result, "debitor(1000313: IF Third OHG: thi)"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java index 6d394b53..07a441a5 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java @@ -288,7 +288,7 @@ class HsOfficeMembershipControllerAcceptanceTest { // finally, the Membership is actually updated assertThat(membershipRepo.findByUuid(givenMembership.getUuid())).isPresent().get() .matches(mandate -> { - assertThat(mandate.getPartner().toShortString()).isEqualTo("LEGAL First GmbH"); + assertThat(mandate.getPartner().toShortString()).isEqualTo("LP First GmbH"); assertThat(mandate.getMainDebitor().toString()).isEqualTo(givenMembership.getMainDebitor().toString()); assertThat(mandate.getMemberNumber()).isEqualTo(givenMembership.getMemberNumber()); assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2024-01-01)"); @@ -331,7 +331,7 @@ class HsOfficeMembershipControllerAcceptanceTest { // finally, the Membership is actually updated assertThat(membershipRepo.findByUuid(givenMembership.getUuid())).isPresent().get() .matches(mandate -> { - assertThat(mandate.getPartner().toShortString()).isEqualTo("LEGAL First GmbH"); + assertThat(mandate.getPartner().toShortString()).isEqualTo("LP First GmbH"); assertThat(mandate.getMainDebitor().toString()).isEqualTo(givenMembership.getMainDebitor().toString()); assertThat(mandate.getMemberNumber()).isEqualTo(givenMembership.getMemberNumber()); assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,)"); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java index 14959428..52fabefa 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java @@ -27,7 +27,7 @@ class HsOfficeMembershipEntityUnitTest { void toStringContainsAllProps() { final var result = givenMembership.toString(); - assertThat(result).isEqualTo("Membership(10001, LEGAL Test Ltd., 1000100, [2020-01-01,))"); + assertThat(result).isEqualTo("Membership(10001, LP Test Ltd., 1000100, [2020-01-01,))"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java index d633d8af..a010c67c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java @@ -184,9 +184,9 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { // then exactlyTheseMembershipsAreReturned( result, - "Membership(10001, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)", - "Membership(10002, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)", - "Membership(10003, SOLE_REPRESENTATION Third OHG, 1000313, [2022-10-01,), NONE)"); + "Membership(10001, LP First GmbH, 1000111, [2022-10-01,), NONE)", + "Membership(10002, LP Second e.K., 1000212, [2022-10-01,), NONE)", + "Membership(10003, IF Third OHG, 1000313, [2022-10-01,), NONE)"); } @Test @@ -201,7 +201,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { null); // then - exactlyTheseMembershipsAreReturned(result, "Membership(10001, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)"); + exactlyTheseMembershipsAreReturned(result, "Membership(10001, LP First GmbH, 1000111, [2022-10-01,), NONE)"); } @Test @@ -213,7 +213,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002); // then - exactlyTheseMembershipsAreReturned(result, "Membership(10002, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)"); + exactlyTheseMembershipsAreReturned(result, "Membership(10002, LP Second e.K., 1000212, [2022-10-01,), NONE)"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index bb08f2e7..16771953 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -208,9 +208,9 @@ public class ImportOfficeData extends ContextBasedTest { assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace(""" { - 17=partner(NATURAL Mellies, Michael: Herr Michael Mellies ), - 20=partner(LEGAL JM GmbH: Herr Philip Meyer-Contract , JM GmbH), - 22=partner(LEGAL Test PS: Petra Schmidt , Test PS) + 17=partner(NP Mellies, Michael: Herr Michael Mellies ), + 20=partner(LP JM GmbH: Herr Philip Meyer-Contract , JM GmbH), + 22=partner(?? Test PS: Petra Schmidt , Test PS) } """); assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace(""" @@ -225,39 +225,39 @@ public class ImportOfficeData extends ContextBasedTest { """); assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace(""" { - 1101=person(personType='NATURAL', tradeName='', familyName='Mellies', givenName='Michael'), - 1200=person(personType='LEGAL', tradeName='JM e.K.', familyName='', givenName=''), - 1201=person(personType='LEGAL', tradeName='JM GmbH', familyName='Meyer-Billing', givenName='Jenny'), - 1202=person(personType='LEGAL', tradeName='JM GmbH', familyName='Meyer-Operation', givenName='Andrew'), - 1203=person(personType='LEGAL', tradeName='JM GmbH', familyName='Meyer-Contract', givenName='Philip'), - 1301=person(personType='LEGAL', tradeName='Test PS', familyName='Schmidt', givenName='Petra') + 1101=person(personType='NP', tradeName='', familyName='Mellies', givenName='Michael'), + 1200=person(personType='LP', tradeName='JM e.K.', familyName='', givenName=''), + 1201=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Billing', givenName='Jenny'), + 1202=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Operation', givenName='Andrew'), + 1203=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Contract', givenName='Philip'), + 1301=person(personType='??', tradeName='Test PS', familyName='Schmidt', givenName='Petra') } """); assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace(""" { - 17=debitor(1001700: NATURAL Mellies, Michael: mih), - 20=debitor(1002000: LEGAL JM GmbH: xyz), - 22=debitor(1102200: LEGAL Test PS: xxx) + 17=debitor(1001700: NP Mellies, Michael: mih), + 20=debitor(1002000: LP JM GmbH: xyz), + 22=debitor(1102200: ?? Test PS: xxx) } """); assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace(""" { - 17=Membership(10017, NATURAL Mellies, Michael, 1001700, [2000-12-06,), NONE), - 20=Membership(10020, LEGAL JM GmbH, 1002000, [2000-12-06,2016-01-01), UNKNOWN), - 22=Membership(11022, LEGAL Test PS, 1102200, [2021-04-01,), NONE) + 17=Membership(10017, NP Mellies, Michael, 1001700, [2000-12-06,), NONE), + 20=Membership(10020, LP JM GmbH, 1002000, [2000-12-06,2016-01-01), UNKNOWN), + 22=Membership(11022, ?? Test PS, 1102200, [2021-04-01,), NONE) } """); assertThat(toFormattedString(relationships)).isEqualToIgnoringWhitespace(""" { - 2000000=rel(relAnchor='NATURAL Mellies, Michael', relType='OPERATIONS', relHolder='NATURAL Mellies, Michael', contact='Herr Michael Mellies '), - 2000001=rel(relAnchor='LEGAL JM GmbH', relType='EX_PARTNER', relHolder='LEGAL JM e.K.', contact='JM e.K.'), - 2000002=rel(relAnchor='LEGAL JM GmbH', relType='OPERATIONS', relHolder='LEGAL JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'), - 2000003=rel(relAnchor='LEGAL JM GmbH', relType='VIP_CONTACT', relHolder='LEGAL JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'), - 2000004=rel(relAnchor='LEGAL JM GmbH', relType='REPRESENTATIVE', relHolder='LEGAL JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'), - 2000005=rel(relAnchor='LEGAL Test PS', relType='OPERATIONS', relHolder='LEGAL Test PS', contact='Petra Schmidt , Test PS'), - 2000006=rel(relAnchor='LEGAL Test PS', relType='REPRESENTATIVE', relHolder='LEGAL Test PS', contact='Petra Schmidt , Test PS'), - 2000007=rel(relAnchor='NATURAL Mellies, Michael', relType='REPRESENTATIVE', relHolder='NATURAL Mellies, Michael', contact='Herr Michael Mellies ') - } + 2000000=rel(relAnchor='NP Mellies, Michael', relType='OPERATIONS', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '), + 2000001=rel(relAnchor='LP JM GmbH', relType='EX_PARTNER', relHolder='LP JM e.K.', contact='JM e.K.'), + 2000002=rel(relAnchor='LP JM GmbH', relType='OPERATIONS', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'), + 2000003=rel(relAnchor='LP JM GmbH', relType='VIP_CONTACT', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'), + 2000004=rel(relAnchor='LP JM GmbH', relType='REPRESENTATIVE', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'), + 2000005=rel(relAnchor='?? Test PS', relType='OPERATIONS', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'), + 2000006=rel(relAnchor='?? Test PS', relType='REPRESENTATIVE', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'), + 2000007=rel(relAnchor='NP Mellies, Michael', relType='REPRESENTATIVE', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies ') + } """); } @@ -793,17 +793,22 @@ public class ImportOfficeData extends ContextBasedTest { private static void determinePersonType(final HsOfficePersonEntity person, final String roles) { if (person.getTradeName().isBlank()) { - person.setPersonType(HsOfficePersonType.NATURAL); - } else if (roles.contains("partner")) { - person.setPersonType(HsOfficePersonType.LEGAL); - } else if (roles.contains("contractual") && + person.setPersonType(HsOfficePersonType.NATURAL_PERSON); + } else + // contractual && !partner with a firm and a natural person name + // should actually be split up into two persons + // but the legacy database consists such records + if (roles.contains("contractual") && !roles.contains("partner") && !person.getFamilyName().isBlank() && !person.getGivenName().isBlank()) { - person.setPersonType(HsOfficePersonType.NATURAL); + person.setPersonType(HsOfficePersonType.NATURAL_PERSON); } else if ( endsWithWord(person.getTradeName(), "e.K.", "e.G.", "eG", "GmbH", "AG") ) { - person.setPersonType(HsOfficePersonType.LEGAL); + person.setPersonType(HsOfficePersonType.LEGAL_PERSON); + } else if ( endsWithWord(person.getTradeName(), "OHG") ) { + person.setPersonType(HsOfficePersonType.INCORPORATED_FIRM); + } else if ( endsWithWord(person.getTradeName(), "GbR") ) { + person.setPersonType(HsOfficePersonType.INCORPORATED_FIRM); } else { - // TODO: detect the other person types as soon as we've switche to the new person types - person.setPersonType(HsOfficePersonType.UNKNOWN); + person.setPersonType(HsOfficePersonType.UNKNOWN_PERSON_TYPE); } } @@ -1029,10 +1034,7 @@ class OrderedDependedTestsExtension implements TestWatcher, BeforeEachCallback { } @Override - public void beforeEach(final ExtensionContext extensionContext) { - if (!previousTestsPassed) { - System.err.println("ignoring because previous fest has failed"); - } + public void beforeEach(final ExtensionContext extensionContext) throws Exception { assumeThat(previousTestsPassed).isTrue(); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java index 359c078d..38700b2a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java @@ -97,7 +97,7 @@ class HsOfficePartnerControllerAcceptanceTest { "details": { "registrationOffice": "Hamburg" } }, { - "person": { "personType": "SOLE_REPRESENTATION" }, + "person": { "personType": "INCORPORATED_FIRM" }, "contact": { "label": "forth contact" }, "details": { "registrationOffice": "Hamburg" } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityUnitTest.java index 87aeea12..a6d2c60a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityUnitTest.java @@ -13,7 +13,7 @@ class HsOfficePartnerEntityUnitTest { void toStringContainsPersonAndContact() { final var given = HsOfficePartnerEntity.builder() .person(HsOfficePersonEntity.builder() - .personType(HsOfficePersonType.LEGAL) + .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .build()) .contact(HsOfficeContactEntity.builder().label("some label").build()) @@ -21,14 +21,14 @@ class HsOfficePartnerEntityUnitTest { final var result = given.toString(); - assertThat(result).isEqualTo("partner(LEGAL some trade name: some label)"); + assertThat(result).isEqualTo("partner(LP some trade name: some label)"); } @Test void toShortStringContainsPersonAndContact() { final var given = HsOfficePartnerEntity.builder() .person(HsOfficePersonEntity.builder() - .personType(HsOfficePersonType.LEGAL) + .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .build()) .contact(HsOfficeContactEntity.builder().label("some label").build()) @@ -36,6 +36,6 @@ class HsOfficePartnerEntityUnitTest { final var result = given.toShortString(); - assertThat(result).isEqualTo("LEGAL some trade name"); + assertThat(result).isEqualTo("LP some trade name"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java index ad41e939..701f2d81 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java @@ -177,9 +177,9 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest { // then allThesePartnersAreReturned( result, - "partner(SOLE_REPRESENTATION Third OHG: third contact)", - "partner(LEGAL Second e.K.: second contact)", - "partner(LEGAL First GmbH: first contact)"); + "partner(IF Third OHG: third contact)", + "partner(LP Second e.K.: second contact)", + "partner(LP First GmbH: first contact)"); } @Test @@ -191,7 +191,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest { final var result = partnerRepo.findPartnerByOptionalNameLike(null); // then: - exactlyThesePartnersAreReturned(result, "partner(LEGAL First GmbH: first contact)"); + exactlyThesePartnersAreReturned(result, "partner(LP First GmbH: first contact)"); } } @@ -207,7 +207,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest { final var result = partnerRepo.findPartnerByOptionalNameLike("third contact"); // then - exactlyThesePartnersAreReturned(result, "partner(SOLE_REPRESENTATION Third OHG: third contact)"); + exactlyThesePartnersAreReturned(result, "partner(IF Third OHG: third contact)"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java index 8ac5ae85..6f567076 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java @@ -4,7 +4,7 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; -import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGAL; +import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGAL_PERSON; public class TestHsOfficePartner { @@ -14,7 +14,7 @@ public class TestHsOfficePartner { return HsOfficePartnerEntity.builder() .debitorNumberPrefix(10001) .person(HsOfficePersonEntity.builder() - .personType(LEGAL) + .personType(LEGAL_PERSON) .tradeName(tradeName) .build()) .contact(HsOfficeContactEntity.builder() diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java index 7a027106..6b505241 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java @@ -69,49 +69,49 @@ class HsOfficePersonControllerAcceptanceTest { .body("", lenientlyEquals(""" [ { - "personType": "LEGAL", + "personType": "LEGAL_PERSON", "tradeName": "First GmbH", "givenName": null, "familyName": null }, { - "personType": "LEGAL", + "personType": "LEGAL_PERSON", "tradeName": "Second e.K.", "givenName": "Miller", "familyName": "Sandra" }, { - "personType": "SOLE_REPRESENTATION", + "personType": "INCORPORATED_FIRM", "tradeName": "Third OHG", "givenName": null, "familyName": null }, { - "personType": "SOLE_REPRESENTATION", + "personType": "INCORPORATED_FIRM", "tradeName": "Fourth e.G.", "givenName": null, "familyName": null }, { - "personType": "NATURAL", + "personType": "NATURAL_PERSON", "tradeName": null, "givenName": "Anita", "familyName": "Bessler" }, { - "personType": "JOINT_REPRESENTATION", + "personType": "UNINCORPORATED_FIRM", "tradeName": "Erben Bessler", "givenName": "Bessler", "familyName": "Mel" }, { - "personType": "NATURAL", + "personType": "NATURAL_PERSON", "tradeName": null, "givenName": "Peter", "familyName": "Smith" }, { - "personType": "NATURAL", + "personType": "NATURAL_PERSON", "tradeName": null, "givenName": "Paul", "familyName": "Winkler" @@ -136,7 +136,7 @@ class HsOfficePersonControllerAcceptanceTest { .contentType(ContentType.JSON) .body(""" { - "personType": "NATURAL", + "personType": "NATURAL_PERSON", "familyName": "Tester", "givenName": "Temp Testi" } @@ -148,7 +148,7 @@ class HsOfficePersonControllerAcceptanceTest { .statusCode(201) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("personType", is("NATURAL")) + .body("personType", is("NATURAL_PERSON")) .body("familyName", is("Tester")) .body("givenName", is("Temp Testi")) .header("Location", startsWith("http://localhost")) @@ -224,7 +224,7 @@ class HsOfficePersonControllerAcceptanceTest { .contentType("application/json") .body("", lenientlyEquals(""" { - "personType": "JOINT_REPRESENTATION", + "personType": "UNINCORPORATED_FIRM", "tradeName": "Erben Bessler", "givenName": "Bessler", "familyName": "Mel" @@ -249,7 +249,7 @@ class HsOfficePersonControllerAcceptanceTest { .contentType(ContentType.JSON) .body(""" { - "personType": "JOINT_REPRESENTATION", + "personType": "UNINCORPORATED_FIRM", "tradeName": "Temp Trade Name - patched", "familyName": "Temp Family Name - patched", "givenName": "Temp Given Name - patched" @@ -262,7 +262,7 @@ class HsOfficePersonControllerAcceptanceTest { .statusCode(200) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("personType", is("JOINT_REPRESENTATION")) + .body("personType", is("UNINCORPORATED_FIRM")) .body("tradeName", is("Temp Trade Name - patched")) .body("familyName", is("Temp Family Name - patched")) .body("givenName", is("Temp Given Name - patched")); @@ -272,7 +272,7 @@ class HsOfficePersonControllerAcceptanceTest { context.define("superuser-alex@hostsharing.net"); assertThat(personRepo.findByUuid(givenPerson.getUuid())).isPresent().get() .matches(person -> { - assertThat(person.getPersonType()).isEqualTo(HsOfficePersonType.JOINT_REPRESENTATION); + assertThat(person.getPersonType()).isEqualTo(HsOfficePersonType.UNINCORPORATED_FIRM); assertThat(person.getTradeName()).isEqualTo("Temp Trade Name - patched"); assertThat(person.getFamilyName()).isEqualTo("Temp Family Name - patched"); assertThat(person.getGivenName()).isEqualTo("Temp Given Name - patched"); @@ -302,7 +302,7 @@ class HsOfficePersonControllerAcceptanceTest { .statusCode(200) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("personType", is(givenPerson.getPersonType().toString())) + .body("personType", is(givenPerson.getPersonType().name())) .body("tradeName", is(givenPerson.getTradeName())) .body("familyName", is("Temp Family Name - patched")) .body("givenName", is("Temp Given Name - patched")); @@ -389,7 +389,7 @@ class HsOfficePersonControllerAcceptanceTest { context.define(creatingUser); final var newPerson = HsOfficePersonEntity.builder() .uuid(UUID.randomUUID()) - .personType(HsOfficePersonType.LEGAL) + .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("Temp " + Context.getCallerMethodNameFromStackFrame(2)) .familyName(RandomStringUtils.randomAlphabetic(10) + "@example.org") .givenName("Temp Given Name " + RandomStringUtils.randomAlphabetic(10)) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcherUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcherUnitTest.java index f6f29f00..7fdb0a27 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcherUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcherUnitTest.java @@ -22,7 +22,7 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase< protected HsOfficePersonEntity newInitialEntity() { final var entity = new HsOfficePersonEntity(); entity.setUuid(INITIAL_PERSON_UUID); - entity.setPersonType(HsOfficePersonType.LEGAL); + entity.setPersonType(HsOfficePersonType.LEGAL_PERSON); entity.setTradeName("initial@example.org"); entity.setFamilyName("initial postal address"); entity.setGivenName("+01 100 123456789"); @@ -45,9 +45,9 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase< new SimpleProperty<>( "personType", HsOfficePersonPatchResource::setPersonType, - HsOfficePersonTypeResource.SOLE_REPRESENTATION, + HsOfficePersonTypeResource.INCORPORATED_FIRM, HsOfficePersonEntity::setPersonType, - HsOfficePersonType.SOLE_REPRESENTATION) + HsOfficePersonType.INCORPORATED_FIRM) .notNullable(), new JsonNullableProperty<>( "tradeName", 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 9502bfb3..1eec872b 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 @@ -11,32 +11,32 @@ class HsOfficePersonEntityUnitTest { @Test void getDisplayReturnsTradeNameIfAvailable() { final var givenPersonEntity = HsOfficePersonEntity.builder() - .personType(HsOfficePersonType.LEGAL) + .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .build(); final var actualDisplay = givenPersonEntity.toShortString(); - assertThat(actualDisplay).isEqualTo("LEGAL some trade name"); + assertThat(actualDisplay).isEqualTo("LP some trade name"); } @Test void getDisplayReturnsFamilyAndGivenNameIfNoTradeNameAvailable() { final var givenPersonEntity = HsOfficePersonEntity.builder() - .personType(HsOfficePersonType.NATURAL) + .personType(HsOfficePersonType.NATURAL_PERSON) .familyName("some family name") .givenName("some given name") .build(); final var actualDisplay = givenPersonEntity.toShortString(); - assertThat(actualDisplay).isEqualTo("NATURAL some family name, some given name"); + assertThat(actualDisplay).isEqualTo("NP some family name, some given name"); } @Test void toShortStringWithTradeNameReturnsTradeName() { final var givenPersonEntity = HsOfficePersonEntity.builder() - .personType(HsOfficePersonType.LEGAL) + .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .familyName("some family name") .givenName("some given name") @@ -44,27 +44,27 @@ class HsOfficePersonEntityUnitTest { final var actualDisplay = givenPersonEntity.toShortString(); - assertThat(actualDisplay).isEqualTo("LEGAL some trade name"); + assertThat(actualDisplay).isEqualTo("LP some trade name"); } @Test void toShortStringWithoutTradeNameReturnsFamilyAndGivenName() { final var givenPersonEntity = HsOfficePersonEntity.builder() - .personType(HsOfficePersonType.NATURAL) + .personType(HsOfficePersonType.NATURAL_PERSON) .familyName("some family name") .givenName("some given name") .build(); final var actualDisplay = givenPersonEntity.toShortString(); - assertThat(actualDisplay).isEqualTo("NATURAL some family name, some given name"); + assertThat(actualDisplay).isEqualTo("NP some family name, some given name"); } @Test void toStringWithAllFieldsReturnsAllButUuid() { final var givenPersonEntity = HsOfficePersonEntity.builder() .uuid(UUID.randomUUID()) - .personType(HsOfficePersonType.NATURAL) + .personType(HsOfficePersonType.NATURAL_PERSON) .tradeName("some trade name") .familyName("some family name") .givenName("some given name") @@ -72,7 +72,7 @@ class HsOfficePersonEntityUnitTest { final var actualDisplay = givenPersonEntity.toString(); - assertThat(actualDisplay).isEqualTo("person(personType='NATURAL', tradeName='some trade name', familyName='some family name', givenName='some given name')"); + assertThat(actualDisplay).isEqualTo("person(personType='NP', tradeName='some trade name', familyName='some family name', givenName='some given name')"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java index 59243daf..8d7eace2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java @@ -144,10 +144,10 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTest { // then allThesePersonsAreReturned( result, - "NATURAL Smith, Peter", - "LEGAL Second e.K.", - "SOLE_REPRESENTATION Third OHG", - "JOINT_REPRESENTATION Erben Bessler"); + "NP Smith, Peter", + "LP Second e.K.", + "IF Third OHG", + "UF Erben Bessler"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverterUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverterUnitTest.java new file mode 100644 index 00000000..93283f2b --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverterUnitTest.java @@ -0,0 +1,24 @@ +package net.hostsharing.hsadminng.hs.office.person; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; + +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; + +class HsOfficePersonTypeConverterUnitTest { + + final HsOfficePersonTypeConverter converter = new HsOfficePersonTypeConverter(); + + @ParameterizedTest + @EnumSource(HsOfficePersonType.class) + void mapsToDatabaseValue(final HsOfficePersonType given) { + assertThat(converter.convertToDatabaseColumn(given)).isEqualTo(given.shortName); + } + + + @ParameterizedTest + @EnumSource(HsOfficePersonType.class) + void mapsFromDatabaseValue(final HsOfficePersonType given) { + assertThat(converter.convertToEntityAttribute(given.shortName)).isEqualTo(given); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java index d394ee56..f8e8bafe 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java @@ -7,7 +7,7 @@ public class TestHsOfficePerson { static public HsOfficePersonEntity hsOfficePerson(final String tradeName) { return HsOfficePersonEntity.builder() - .personType(HsOfficePersonType.NATURAL) + .personType(HsOfficePersonType.NATURAL_PERSON) .tradeName(tradeName) .build(); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipControllerAcceptanceTest.java index bbfa43ff..6105a49e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipControllerAcceptanceTest.java @@ -83,11 +83,11 @@ class HsOfficeRelationshipControllerAcceptanceTest { [ { "relAnchor": { - "personType": "SOLE_REPRESENTATION", + "personType": "INCORPORATED_FIRM", "tradeName": "Third OHG" }, "relHolder": { - "personType": "NATURAL", + "personType": "NATURAL_PERSON", "givenName": "Peter", "familyName": "Smith" }, @@ -96,13 +96,13 @@ class HsOfficeRelationshipControllerAcceptanceTest { }, { "relAnchor": { - "personType": "LEGAL", + "personType": "LEGAL_PERSON", "tradeName": "Second e.K.", "givenName": "Miller", "familyName": "Sandra" }, "relHolder": { - "personType": "NATURAL", + "personType": "NATURAL_PERSON", "givenName": "Peter", "familyName": "Smith" }, @@ -111,11 +111,11 @@ class HsOfficeRelationshipControllerAcceptanceTest { }, { "relAnchor": { - "personType": "LEGAL", + "personType": "LEGAL_PERSON", "tradeName": "First GmbH" }, "relHolder": { - "personType": "NATURAL", + "personType": "NATURAL_PERSON", "tradeName": null, "givenName": "Peter", "familyName": "Smith" diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipRepositoryIntegrationTest.java index 7b2603f8..5eae5b45 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relationship/HsOfficeRelationshipRepositoryIntegrationTest.java @@ -159,9 +159,9 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest { // then allTheseRelationshipsAreReturned( result, - "rel(relAnchor='LEGAL First GmbH', relType='REPRESENTATIVE', relHolder='NATURAL Smith, Peter', contact='first contact')", - "rel(relAnchor='SOLE_REPRESENTATION Third OHG', relType='REPRESENTATIVE', relHolder='NATURAL Smith, Peter', contact='third contact')", - "rel(relAnchor='LEGAL Second e.K.', relType='REPRESENTATIVE', relHolder='NATURAL Smith, Peter', contact='second contact')"); + "rel(relAnchor='LP First GmbH', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='first contact')", + "rel(relAnchor='IF Third OHG', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='third contact')", + "rel(relAnchor='LP Second e.K.', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='second contact')"); } @Test @@ -176,7 +176,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest { // then: exactlyTheseRelationshipsAreReturned( result, - "rel(relAnchor='LEGAL First GmbH', relType='REPRESENTATIVE', relHolder='NATURAL Smith, Peter', contact='first contact')"); + "rel(relAnchor='LP First GmbH', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='first contact')"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java index 70cf53da..eca05c62 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java @@ -376,7 +376,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest { context.define("superuser-alex@hostsharing.net"); assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get() .matches(mandate -> { - assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(1000111: LEGAL First GmbH: fir)"); + assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(1000111: LP First GmbH: fir)"); assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH"); assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z - patched"); assertThat(mandate.getValidFrom()).isEqualTo("2020-06-05"); @@ -417,7 +417,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest { // finally, the sepaMandate is actually updated assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get() .matches(mandate -> { - assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(1000111: LEGAL First GmbH: fir)"); + assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(1000111: LP First GmbH: fir)"); assertThat(mandate.getBankAccount().toShortString()).isEqualTo("First GmbH"); assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z"); assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-01-01)");