WIP: more detailed person type #11

Closed
hsh-michaelhoennig wants to merge 1 commits from more-detailed-person-type into master
31 changed files with 226 additions and 141 deletions
Showing only changes of commit 9af7dfdfb1 - Show all commits

View File

@ -11,7 +11,6 @@ import org.hibernate.annotations.GenericGenerator;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.UUID; import java.util.UUID;

View File

@ -40,6 +40,14 @@ class HsOfficeDebitorEntityPatcher implements EntityPatcher<HsOfficeDebitorPatch
verifyNotNull(newValue, "refundBankAccount"); verifyNotNull(newValue, "refundBankAccount");
entity.setRefundBankAccount(em.getReference(HsOfficeBankAccountEntity.class, newValue)); entity.setRefundBankAccount(em.getReference(HsOfficeBankAccountEntity.class, newValue));
}); });
OptionalFromJson.of(resource.getDefaultPrefix()).ifPresent(newValue -> {
verifyNotNull(newValue, "defaultPrefix");
entity.setDefaultPrefix(newValue);
});
OptionalFromJson.of(resource.getRefundBankAccountUuid()).ifPresent(newValue -> {
verifyNotNull(newValue, "refundBankAccount");
entity.setRefundBankAccount(em.getReference(HsOfficeBankAccountEntity.class, newValue));
});
} }
private void verifyNotNull(final Object newValue, final String propertyName) { private void verifyNotNull(final Object newValue, final String propertyName) {

View File

@ -35,7 +35,6 @@ public class HsOfficePersonEntity implements HasUuid, Stringifyable {
private UUID uuid; private UUID uuid;
@Column(name = "persontype") @Column(name = "persontype")
@Enumerated(EnumType.STRING)
private HsOfficePersonType personType; private HsOfficePersonType personType;
@Column(name = "tradename") @Column(name = "tradename")

View File

@ -1,9 +1,21 @@
package net.hostsharing.hsadminng.hs.office.person; package net.hostsharing.hsadminng.hs.office.person;
public enum HsOfficePersonType { public enum HsOfficePersonType {
UNKNOWN, UNKNOWN_PERSON_TYPE("??"),
NATURAL, NATURAL_PERSON("NP"), // a human being
LEGAL, LEGAL_PERSON("LP"), // incorporated legal entity like A/S, GmbH, e.K., eG, e.V.
SOLE_REPRESENTATION, INCORPORATED_FIRM("IF"), // registered business partnership like OHG, Partnerschaftsgesellschaft
JOINT_REPRESENTATION 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;
}
} }

View File

@ -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<HsOfficePersonType, String> {
@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);
}
}

View File

@ -6,10 +6,12 @@ components:
HsOfficePersonType: HsOfficePersonType:
type: string type: string
enum: enum:
- NATURAL # a human - UNKNOWN_PERSON
- LEGAL # e.g. Corp., Inc., AG, GmbH, eG - NATURAL_PERSON
- SOLE_REPRESENTATION # e.g. OHG, GbR - LEGAL_PERSON
- JOINT_REPRESENTATION # e.g. community of heirs - INCORPORATED_FIRM
- UNINCORPORATED_FIRM
- PUBLIC_INSTITUTION
HsOfficePerson: HsOfficePerson:
type: object type: object

View File

@ -770,8 +770,8 @@ do $$
if '${HSADMINNG_POSTGRES_RESTRICTED_USERNAME}'='restricted' then if '${HSADMINNG_POSTGRES_RESTRICTED_USERNAME}'='restricted' then
create role restricted; create role restricted;
grant all privileges on all tables in schema public to restricted;
end if; end if;
-- grant all privileges on all tables in schema public to ${HSADMINNG_POSTGRES_RESTRICTED_USERNAME};
end $$ end $$
--// --//

View File

@ -4,7 +4,13 @@
--changeset hs-office-person-MAIN-TABLE:1 endDelimiter:--// --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; CREATE CAST (character varying as HsOfficePersonType) WITH INOUT AS IMPLICIT;

View File

@ -59,14 +59,14 @@ end; $$;
do language plpgsql $$ do language plpgsql $$
begin begin
call createHsOfficePersonTestData('LEGAL', 'First GmbH'); call createHsOfficePersonTestData('LP', 'First GmbH');
call createHsOfficePersonTestData('NATURAL', null, 'Smith', 'Peter'); call createHsOfficePersonTestData('NP', null, 'Smith', 'Peter');
call createHsOfficePersonTestData('LEGAL', 'Second e.K.', 'Sandra', 'Miller'); call createHsOfficePersonTestData('LP', 'Second e.K.', 'Sandra', 'Miller');
call createHsOfficePersonTestData('SOLE_REPRESENTATION', 'Third OHG'); call createHsOfficePersonTestData('IF', 'Third OHG');
call createHsOfficePersonTestData('SOLE_REPRESENTATION', 'Fourth e.G.'); call createHsOfficePersonTestData('IF', 'Fourth e.G.');
call createHsOfficePersonTestData('JOINT_REPRESENTATION', 'Erben Bessler', 'Mel', 'Bessler'); call createHsOfficePersonTestData('UF', 'Erben Bessler', 'Mel', 'Bessler');
call createHsOfficePersonTestData('NATURAL', null, 'Bessler', 'Anita'); call createHsOfficePersonTestData('NP', null, 'Bessler', 'Anita');
call createHsOfficePersonTestData('NATURAL', null, 'Winkler', 'Paul'); call createHsOfficePersonTestData('NP', null, 'Winkler', 'Paul');
end; end;
$$; $$;
--// --//

View File

@ -19,7 +19,6 @@ declare
relatedPerson hs_office_person; relatedPerson hs_office_person;
relatedContact hs_office_contact; relatedContact hs_office_contact;
relatedDetailsUuid uuid; relatedDetailsUuid uuid;
birthday date;
begin begin
idName := cleanIdentifier( personTradeOrFamilyName|| '-' || contactLabel); idName := cleanIdentifier( personTradeOrFamilyName|| '-' || contactLabel);
currentTask := 'creating partner test-data ' || idName; currentTask := 'creating partner test-data ' || idName;
@ -33,18 +32,14 @@ begin
where c.label = contactLabel where c.label = contactLabel
into relatedContact; into relatedContact;
if relatedPerson.persontype = 'NATURAL' then
birthday := '1987-10-31'::date;
end if;
raise notice 'creating test partner: %', idName; raise notice 'creating test partner: %', idName;
raise notice '- using person (%): %', relatedPerson.uuid, relatedPerson; raise notice '- using person (%): %', relatedPerson.uuid, relatedPerson;
raise notice '- using contact (%): %', relatedContact.uuid, relatedContact; raise notice '- using contact (%): %', relatedContact.uuid, relatedContact;
if relatedPerson.persontype = 'NATURAL' then if relatedPerson.persontype = 'NP' then
insert insert
into hs_office_partner_details (uuid, birthName, birthday) into hs_office_partner_details (uuid, birthName, birthday, birthPlace)
values (uuid_generate_v4(), 'Meyer', '1987-10-31') values (uuid_generate_v4(), 'Meyer', '1987-10-31', 'Hamburg')
returning uuid into relatedDetailsUuid; returning uuid into relatedDetailsUuid;
else else
insert insert

View File

@ -83,7 +83,7 @@ class HsOfficeDebitorControllerAcceptanceTest {
{ {
"debitorNumber": 1000111, "debitorNumber": 1000111,
"debitorNumberSuffix": 11, "debitorNumberSuffix": 11,
"partner": { "person": { "personType": "LEGAL" } }, "partner": { "person": { "personType": "LEGAL_PERSON" } },
"billingContact": { "label": "first contact" }, "billingContact": { "label": "first contact" },
"vatId": null, "vatId": null,
"vatCountryCode": null, "vatCountryCode": null,

View File

@ -17,7 +17,7 @@ class HsOfficeDebitorEntityUnitTest {
.debitorNumberSuffix((byte)67) .debitorNumberSuffix((byte)67)
.partner(HsOfficePartnerEntity.builder() .partner(HsOfficePartnerEntity.builder()
.person(HsOfficePersonEntity.builder() .person(HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.LEGAL) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.build()) .build())
.details(HsOfficePartnerDetailsEntity.builder().birthName("some birth name").build()) .details(HsOfficePartnerDetailsEntity.builder().birthName("some birth name").build())
@ -29,7 +29,7 @@ class HsOfficeDebitorEntityUnitTest {
final var result = given.toString(); 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 @Test

View File

@ -211,9 +211,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
// then // then
allTheseDebitorsAreReturned( allTheseDebitorsAreReturned(
result, result,
"debitor(1000111: LEGAL First GmbH: fir)", "debitor(1000111: LP First GmbH: fir)",
"debitor(1000212: LEGAL Second e.K.: sec)", "debitor(1000212: LP Second e.K.: sec)",
"debitor(1000313: SOLE_REPRESENTATION Third OHG: thi)"); "debitor(1000313: IF Third OHG: thi)");
} }
@ParameterizedTest @ParameterizedTest
@ -231,8 +231,8 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
// then: // then:
exactlyTheseDebitorsAreReturned(result, exactlyTheseDebitorsAreReturned(result,
"debitor(1000111: LEGAL First GmbH: fir)", "debitor(1000111: LP First GmbH: fir)",
"debitor(1000120: LEGAL First GmbH: fif)"); "debitor(1000120: LP First GmbH: fif)");
} }
@Test @Test
@ -260,7 +260,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
final var result = debitorRepo.findDebitorByDebitorNumber(1000313); final var result = debitorRepo.findDebitorByDebitorNumber(1000313);
// then // 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"); final var result = debitorRepo.findDebitorByOptionalNameLike("third contact");
// then // then
exactlyTheseDebitorsAreReturned(result, "debitor(1000313: SOLE_REPRESENTATION Third OHG: thi)"); exactlyTheseDebitorsAreReturned(result, "debitor(1000313: IF Third OHG: thi)");
} }
} }

View File

@ -288,7 +288,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
// finally, the Membership is actually updated // finally, the Membership is actually updated
assertThat(membershipRepo.findByUuid(givenMembership.getUuid())).isPresent().get() assertThat(membershipRepo.findByUuid(givenMembership.getUuid())).isPresent().get()
.matches(mandate -> { .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.getMainDebitor().toString()).isEqualTo(givenMembership.getMainDebitor().toString());
assertThat(mandate.getMemberNumber()).isEqualTo(givenMembership.getMemberNumber()); assertThat(mandate.getMemberNumber()).isEqualTo(givenMembership.getMemberNumber());
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2024-01-01)"); assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2024-01-01)");
@ -331,7 +331,7 @@ class HsOfficeMembershipControllerAcceptanceTest {
// finally, the Membership is actually updated // finally, the Membership is actually updated
assertThat(membershipRepo.findByUuid(givenMembership.getUuid())).isPresent().get() assertThat(membershipRepo.findByUuid(givenMembership.getUuid())).isPresent().get()
.matches(mandate -> { .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.getMainDebitor().toString()).isEqualTo(givenMembership.getMainDebitor().toString());
assertThat(mandate.getMemberNumber()).isEqualTo(givenMembership.getMemberNumber()); assertThat(mandate.getMemberNumber()).isEqualTo(givenMembership.getMemberNumber());
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,)"); assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,)");

View File

@ -27,7 +27,7 @@ class HsOfficeMembershipEntityUnitTest {
void toStringContainsAllProps() { void toStringContainsAllProps() {
final var result = givenMembership.toString(); 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 @Test

View File

@ -184,9 +184,9 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
// then // then
exactlyTheseMembershipsAreReturned( exactlyTheseMembershipsAreReturned(
result, result,
"Membership(10001, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)", "Membership(10001, LP First GmbH, 1000111, [2022-10-01,), NONE)",
"Membership(10002, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)", "Membership(10002, LP Second e.K., 1000212, [2022-10-01,), NONE)",
"Membership(10003, SOLE_REPRESENTATION Third OHG, 1000313, [2022-10-01,), NONE)"); "Membership(10003, IF Third OHG, 1000313, [2022-10-01,), NONE)");
} }
@Test @Test
@ -201,7 +201,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
null); null);
// then // 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 @Test
@ -213,7 +213,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002); final var result = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002);
// then // 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)");
} }
} }

View File

@ -208,9 +208,9 @@ public class ImportOfficeData extends ContextBasedTest {
assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace("""
{ {
17=partner(NATURAL Mellies, Michael: Herr Michael Mellies ), 17=partner(NP Mellies, Michael: Herr Michael Mellies ),
20=partner(LEGAL JM GmbH: Herr Philip Meyer-Contract , JM GmbH), 20=partner(LP JM GmbH: Herr Philip Meyer-Contract , JM GmbH),
22=partner(LEGAL Test PS: Petra Schmidt , Test PS) 22=partner(?? Test PS: Petra Schmidt , Test PS)
} }
"""); """);
assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace("""
@ -225,38 +225,38 @@ public class ImportOfficeData extends ContextBasedTest {
"""); """);
assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace("""
{ {
1101=person(personType='NATURAL', tradeName='', familyName='Mellies', givenName='Michael'), 1101=person(personType='NP', tradeName='', familyName='Mellies', givenName='Michael'),
1200=person(personType='LEGAL', tradeName='JM e.K.', familyName='', givenName=''), 1200=person(personType='LP', tradeName='JM e.K.', familyName='', givenName=''),
1201=person(personType='LEGAL', tradeName='JM GmbH', familyName='Meyer-Billing', givenName='Jenny'), 1201=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Billing', givenName='Jenny'),
1202=person(personType='LEGAL', tradeName='JM GmbH', familyName='Meyer-Operation', givenName='Andrew'), 1202=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Operation', givenName='Andrew'),
1203=person(personType='LEGAL', tradeName='JM GmbH', familyName='Meyer-Contract', givenName='Philip'), 1203=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Contract', givenName='Philip'),
1301=person(personType='LEGAL', tradeName='Test PS', familyName='Schmidt', givenName='Petra') 1301=person(personType='??', tradeName='Test PS', familyName='Schmidt', givenName='Petra')
} }
"""); """);
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
{ {
17=debitor(1001700: NATURAL Mellies, Michael: mih), 17=debitor(1001700: NP Mellies, Michael: mih),
20=debitor(1002000: LEGAL JM GmbH: xyz), 20=debitor(1002000: LP JM GmbH: xyz),
22=debitor(1102200: LEGAL Test PS: xxx) 22=debitor(1102200: ?? Test PS: xxx)
} }
"""); """);
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
{ {
17=Membership(10017, NATURAL Mellies, Michael, 1001700, [2000-12-06,), NONE), 17=Membership(10017, NP Mellies, Michael, 1001700, [2000-12-06,), NONE),
20=Membership(10020, LEGAL JM GmbH, 1002000, [2000-12-06,2016-01-01), UNKNOWN), 20=Membership(10020, LP JM GmbH, 1002000, [2000-12-06,2016-01-01), UNKNOWN),
22=Membership(11022, LEGAL Test PS, 1102200, [2021-04-01,), NONE) 22=Membership(11022, ?? Test PS, 1102200, [2021-04-01,), NONE)
} }
"""); """);
assertThat(toFormattedString(relationships)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(relationships)).isEqualToIgnoringWhitespace("""
{ {
2000000=rel(relAnchor='NATURAL Mellies, Michael', relType='OPERATIONS', 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='LEGAL JM GmbH', relType='EX_PARTNER', relHolder='LEGAL JM e.K.', contact='JM e.K.'), 2000001=rel(relAnchor='LP JM GmbH', relType='EX_PARTNER', relHolder='LP 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'), 2000002=rel(relAnchor='LP JM GmbH', relType='OPERATIONS', relHolder='LP 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'), 2000003=rel(relAnchor='LP JM GmbH', relType='VIP_CONTACT', relHolder='LP 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'), 2000004=rel(relAnchor='LP JM GmbH', relType='REPRESENTATIVE', relHolder='LP 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'), 2000005=rel(relAnchor='?? Test PS', relType='OPERATIONS', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
2000006=rel(relAnchor='LEGAL Test PS', relType='REPRESENTATIVE', relHolder='LEGAL 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='NATURAL Mellies, Michael', relType='REPRESENTATIVE', relHolder='NATURAL Mellies, Michael', contact='Herr Michael Mellies ') 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) { private static void determinePersonType(final HsOfficePersonEntity person, final String roles) {
if (person.getTradeName().isBlank()) { if (person.getTradeName().isBlank()) {
person.setPersonType(HsOfficePersonType.NATURAL); person.setPersonType(HsOfficePersonType.NATURAL_PERSON);
} else if (roles.contains("partner")) { } else
person.setPersonType(HsOfficePersonType.LEGAL); // contractual && !partner with a firm and a natural person name
} else if (roles.contains("contractual") && // 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.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") ) { } 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 { } else {
// TODO: detect the other person types as soon as we've switche to the new person types person.setPersonType(HsOfficePersonType.UNKNOWN_PERSON_TYPE);
person.setPersonType(HsOfficePersonType.UNKNOWN);
} }
} }
@ -1029,10 +1034,7 @@ class OrderedDependedTestsExtension implements TestWatcher, BeforeEachCallback {
} }
@Override @Override
public void beforeEach(final ExtensionContext extensionContext) { public void beforeEach(final ExtensionContext extensionContext) throws Exception {
if (!previousTestsPassed) {
System.err.println("ignoring because previous fest has failed");
}
assumeThat(previousTestsPassed).isTrue(); assumeThat(previousTestsPassed).isTrue();
} }
} }

View File

@ -97,7 +97,7 @@ class HsOfficePartnerControllerAcceptanceTest {
"details": { "registrationOffice": "Hamburg" } "details": { "registrationOffice": "Hamburg" }
}, },
{ {
"person": { "personType": "SOLE_REPRESENTATION" }, "person": { "personType": "INCORPORATED_FIRM" },
"contact": { "label": "forth contact" }, "contact": { "label": "forth contact" },
"details": { "registrationOffice": "Hamburg" } "details": { "registrationOffice": "Hamburg" }
} }

View File

@ -13,7 +13,7 @@ class HsOfficePartnerEntityUnitTest {
void toStringContainsPersonAndContact() { void toStringContainsPersonAndContact() {
final var given = HsOfficePartnerEntity.builder() final var given = HsOfficePartnerEntity.builder()
.person(HsOfficePersonEntity.builder() .person(HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.LEGAL) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.build()) .build())
.contact(HsOfficeContactEntity.builder().label("some label").build()) .contact(HsOfficeContactEntity.builder().label("some label").build())
@ -21,14 +21,14 @@ class HsOfficePartnerEntityUnitTest {
final var result = given.toString(); 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 @Test
void toShortStringContainsPersonAndContact() { void toShortStringContainsPersonAndContact() {
final var given = HsOfficePartnerEntity.builder() final var given = HsOfficePartnerEntity.builder()
.person(HsOfficePersonEntity.builder() .person(HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.LEGAL) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.build()) .build())
.contact(HsOfficeContactEntity.builder().label("some label").build()) .contact(HsOfficeContactEntity.builder().label("some label").build())
@ -36,6 +36,6 @@ class HsOfficePartnerEntityUnitTest {
final var result = given.toShortString(); final var result = given.toShortString();
assertThat(result).isEqualTo("LEGAL some trade name"); assertThat(result).isEqualTo("LP some trade name");
} }
} }

View File

@ -177,9 +177,9 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest {
// then // then
allThesePartnersAreReturned( allThesePartnersAreReturned(
result, result,
"partner(SOLE_REPRESENTATION Third OHG: third contact)", "partner(IF Third OHG: third contact)",
"partner(LEGAL Second e.K.: second contact)", "partner(LP Second e.K.: second contact)",
"partner(LEGAL First GmbH: first contact)"); "partner(LP First GmbH: first contact)");
} }
@Test @Test
@ -191,7 +191,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest {
final var result = partnerRepo.findPartnerByOptionalNameLike(null); final var result = partnerRepo.findPartnerByOptionalNameLike(null);
// then: // 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"); final var result = partnerRepo.findPartnerByOptionalNameLike("third contact");
// then // then
exactlyThesePartnersAreReturned(result, "partner(SOLE_REPRESENTATION Third OHG: third contact)"); exactlyThesePartnersAreReturned(result, "partner(IF Third OHG: third contact)");
} }
} }

View File

@ -4,7 +4,7 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; 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 { public class TestHsOfficePartner {
@ -14,7 +14,7 @@ public class TestHsOfficePartner {
return HsOfficePartnerEntity.builder() return HsOfficePartnerEntity.builder()
.debitorNumberPrefix(10001) .debitorNumberPrefix(10001)
.person(HsOfficePersonEntity.builder() .person(HsOfficePersonEntity.builder()
.personType(LEGAL) .personType(LEGAL_PERSON)
.tradeName(tradeName) .tradeName(tradeName)
.build()) .build())
.contact(HsOfficeContactEntity.builder() .contact(HsOfficeContactEntity.builder()

View File

@ -69,49 +69,49 @@ class HsOfficePersonControllerAcceptanceTest {
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
[ [
{ {
"personType": "LEGAL", "personType": "LEGAL_PERSON",
"tradeName": "First GmbH", "tradeName": "First GmbH",
"givenName": null, "givenName": null,
"familyName": null "familyName": null
}, },
{ {
"personType": "LEGAL", "personType": "LEGAL_PERSON",
"tradeName": "Second e.K.", "tradeName": "Second e.K.",
"givenName": "Miller", "givenName": "Miller",
"familyName": "Sandra" "familyName": "Sandra"
}, },
{ {
"personType": "SOLE_REPRESENTATION", "personType": "INCORPORATED_FIRM",
"tradeName": "Third OHG", "tradeName": "Third OHG",
"givenName": null, "givenName": null,
"familyName": null "familyName": null
}, },
{ {
"personType": "SOLE_REPRESENTATION", "personType": "INCORPORATED_FIRM",
"tradeName": "Fourth e.G.", "tradeName": "Fourth e.G.",
"givenName": null, "givenName": null,
"familyName": null "familyName": null
}, },
{ {
"personType": "NATURAL", "personType": "NATURAL_PERSON",
"tradeName": null, "tradeName": null,
"givenName": "Anita", "givenName": "Anita",
"familyName": "Bessler" "familyName": "Bessler"
}, },
{ {
"personType": "JOINT_REPRESENTATION", "personType": "UNINCORPORATED_FIRM",
"tradeName": "Erben Bessler", "tradeName": "Erben Bessler",
"givenName": "Bessler", "givenName": "Bessler",
"familyName": "Mel" "familyName": "Mel"
}, },
{ {
"personType": "NATURAL", "personType": "NATURAL_PERSON",
"tradeName": null, "tradeName": null,
"givenName": "Peter", "givenName": "Peter",
"familyName": "Smith" "familyName": "Smith"
}, },
{ {
"personType": "NATURAL", "personType": "NATURAL_PERSON",
"tradeName": null, "tradeName": null,
"givenName": "Paul", "givenName": "Paul",
"familyName": "Winkler" "familyName": "Winkler"
@ -136,7 +136,7 @@ class HsOfficePersonControllerAcceptanceTest {
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body(""" .body("""
{ {
"personType": "NATURAL", "personType": "NATURAL_PERSON",
"familyName": "Tester", "familyName": "Tester",
"givenName": "Temp Testi" "givenName": "Temp Testi"
} }
@ -148,7 +148,7 @@ class HsOfficePersonControllerAcceptanceTest {
.statusCode(201) .statusCode(201)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("personType", is("NATURAL")) .body("personType", is("NATURAL_PERSON"))
.body("familyName", is("Tester")) .body("familyName", is("Tester"))
.body("givenName", is("Temp Testi")) .body("givenName", is("Temp Testi"))
.header("Location", startsWith("http://localhost")) .header("Location", startsWith("http://localhost"))
@ -224,7 +224,7 @@ class HsOfficePersonControllerAcceptanceTest {
.contentType("application/json") .contentType("application/json")
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
{ {
"personType": "JOINT_REPRESENTATION", "personType": "UNINCORPORATED_FIRM",
"tradeName": "Erben Bessler", "tradeName": "Erben Bessler",
"givenName": "Bessler", "givenName": "Bessler",
"familyName": "Mel" "familyName": "Mel"
@ -249,7 +249,7 @@ class HsOfficePersonControllerAcceptanceTest {
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body(""" .body("""
{ {
"personType": "JOINT_REPRESENTATION", "personType": "UNINCORPORATED_FIRM",
"tradeName": "Temp Trade Name - patched", "tradeName": "Temp Trade Name - patched",
"familyName": "Temp Family Name - patched", "familyName": "Temp Family Name - patched",
"givenName": "Temp Given Name - patched" "givenName": "Temp Given Name - patched"
@ -262,7 +262,7 @@ class HsOfficePersonControllerAcceptanceTest {
.statusCode(200) .statusCode(200)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("personType", is("JOINT_REPRESENTATION")) .body("personType", is("UNINCORPORATED_FIRM"))
.body("tradeName", is("Temp Trade Name - patched")) .body("tradeName", is("Temp Trade Name - patched"))
.body("familyName", is("Temp Family Name - patched")) .body("familyName", is("Temp Family Name - patched"))
.body("givenName", is("Temp Given Name - patched")); .body("givenName", is("Temp Given Name - patched"));
@ -272,7 +272,7 @@ class HsOfficePersonControllerAcceptanceTest {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
assertThat(personRepo.findByUuid(givenPerson.getUuid())).isPresent().get() assertThat(personRepo.findByUuid(givenPerson.getUuid())).isPresent().get()
.matches(person -> { .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.getTradeName()).isEqualTo("Temp Trade Name - patched");
assertThat(person.getFamilyName()).isEqualTo("Temp Family Name - patched"); assertThat(person.getFamilyName()).isEqualTo("Temp Family Name - patched");
assertThat(person.getGivenName()).isEqualTo("Temp Given Name - patched"); assertThat(person.getGivenName()).isEqualTo("Temp Given Name - patched");
@ -302,7 +302,7 @@ class HsOfficePersonControllerAcceptanceTest {
.statusCode(200) .statusCode(200)
.contentType(ContentType.JSON) .contentType(ContentType.JSON)
.body("uuid", isUuidValid()) .body("uuid", isUuidValid())
.body("personType", is(givenPerson.getPersonType().toString())) .body("personType", is(givenPerson.getPersonType().name()))
.body("tradeName", is(givenPerson.getTradeName())) .body("tradeName", is(givenPerson.getTradeName()))
.body("familyName", is("Temp Family Name - patched")) .body("familyName", is("Temp Family Name - patched"))
.body("givenName", is("Temp Given Name - patched")); .body("givenName", is("Temp Given Name - patched"));
@ -389,7 +389,7 @@ class HsOfficePersonControllerAcceptanceTest {
context.define(creatingUser); context.define(creatingUser);
final var newPerson = HsOfficePersonEntity.builder() final var newPerson = HsOfficePersonEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.personType(HsOfficePersonType.LEGAL) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("Temp " + Context.getCallerMethodNameFromStackFrame(2)) .tradeName("Temp " + Context.getCallerMethodNameFromStackFrame(2))
.familyName(RandomStringUtils.randomAlphabetic(10) + "@example.org") .familyName(RandomStringUtils.randomAlphabetic(10) + "@example.org")
.givenName("Temp Given Name " + RandomStringUtils.randomAlphabetic(10)) .givenName("Temp Given Name " + RandomStringUtils.randomAlphabetic(10))

View File

@ -22,7 +22,7 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
protected HsOfficePersonEntity newInitialEntity() { protected HsOfficePersonEntity newInitialEntity() {
final var entity = new HsOfficePersonEntity(); final var entity = new HsOfficePersonEntity();
entity.setUuid(INITIAL_PERSON_UUID); entity.setUuid(INITIAL_PERSON_UUID);
entity.setPersonType(HsOfficePersonType.LEGAL); entity.setPersonType(HsOfficePersonType.LEGAL_PERSON);
entity.setTradeName("initial@example.org"); entity.setTradeName("initial@example.org");
entity.setFamilyName("initial postal address"); entity.setFamilyName("initial postal address");
entity.setGivenName("+01 100 123456789"); entity.setGivenName("+01 100 123456789");
@ -45,9 +45,9 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
new SimpleProperty<>( new SimpleProperty<>(
"personType", "personType",
HsOfficePersonPatchResource::setPersonType, HsOfficePersonPatchResource::setPersonType,
HsOfficePersonTypeResource.SOLE_REPRESENTATION, HsOfficePersonTypeResource.INCORPORATED_FIRM,
HsOfficePersonEntity::setPersonType, HsOfficePersonEntity::setPersonType,
HsOfficePersonType.SOLE_REPRESENTATION) HsOfficePersonType.INCORPORATED_FIRM)
.notNullable(), .notNullable(),
new JsonNullableProperty<>( new JsonNullableProperty<>(
"tradeName", "tradeName",

View File

@ -11,32 +11,32 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void getDisplayReturnsTradeNameIfAvailable() { void getDisplayReturnsTradeNameIfAvailable() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.LEGAL) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.build(); .build();
final var actualDisplay = givenPersonEntity.toShortString(); final var actualDisplay = givenPersonEntity.toShortString();
assertThat(actualDisplay).isEqualTo("LEGAL some trade name"); assertThat(actualDisplay).isEqualTo("LP some trade name");
} }
@Test @Test
void getDisplayReturnsFamilyAndGivenNameIfNoTradeNameAvailable() { void getDisplayReturnsFamilyAndGivenNameIfNoTradeNameAvailable() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.NATURAL) .personType(HsOfficePersonType.NATURAL_PERSON)
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
.build(); .build();
final var actualDisplay = givenPersonEntity.toShortString(); 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 @Test
void toShortStringWithTradeNameReturnsTradeName() { void toShortStringWithTradeNameReturnsTradeName() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.LEGAL) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
@ -44,27 +44,27 @@ class HsOfficePersonEntityUnitTest {
final var actualDisplay = givenPersonEntity.toShortString(); final var actualDisplay = givenPersonEntity.toShortString();
assertThat(actualDisplay).isEqualTo("LEGAL some trade name"); assertThat(actualDisplay).isEqualTo("LP some trade name");
} }
@Test @Test
void toShortStringWithoutTradeNameReturnsFamilyAndGivenName() { void toShortStringWithoutTradeNameReturnsFamilyAndGivenName() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.NATURAL) .personType(HsOfficePersonType.NATURAL_PERSON)
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
.build(); .build();
final var actualDisplay = givenPersonEntity.toShortString(); 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 @Test
void toStringWithAllFieldsReturnsAllButUuid() { void toStringWithAllFieldsReturnsAllButUuid() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.personType(HsOfficePersonType.NATURAL) .personType(HsOfficePersonType.NATURAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
@ -72,7 +72,7 @@ class HsOfficePersonEntityUnitTest {
final var actualDisplay = givenPersonEntity.toString(); 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 @Test

View File

@ -144,10 +144,10 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTest {
// then // then
allThesePersonsAreReturned( allThesePersonsAreReturned(
result, result,
"NATURAL Smith, Peter", "NP Smith, Peter",
"LEGAL Second e.K.", "LP Second e.K.",
"SOLE_REPRESENTATION Third OHG", "IF Third OHG",
"JOINT_REPRESENTATION Erben Bessler"); "UF Erben Bessler");
} }
@Test @Test

View File

@ -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);
}
}

View File

@ -7,7 +7,7 @@ public class TestHsOfficePerson {
static public HsOfficePersonEntity hsOfficePerson(final String tradeName) { static public HsOfficePersonEntity hsOfficePerson(final String tradeName) {
return HsOfficePersonEntity.builder() return HsOfficePersonEntity.builder()
.personType(HsOfficePersonType.NATURAL) .personType(HsOfficePersonType.NATURAL_PERSON)
.tradeName(tradeName) .tradeName(tradeName)
.build(); .build();
} }

View File

@ -83,11 +83,11 @@ class HsOfficeRelationshipControllerAcceptanceTest {
[ [
{ {
"relAnchor": { "relAnchor": {
"personType": "SOLE_REPRESENTATION", "personType": "INCORPORATED_FIRM",
"tradeName": "Third OHG" "tradeName": "Third OHG"
}, },
"relHolder": { "relHolder": {
"personType": "NATURAL", "personType": "NATURAL_PERSON",
"givenName": "Peter", "givenName": "Peter",
"familyName": "Smith" "familyName": "Smith"
}, },
@ -96,13 +96,13 @@ class HsOfficeRelationshipControllerAcceptanceTest {
}, },
{ {
"relAnchor": { "relAnchor": {
"personType": "LEGAL", "personType": "LEGAL_PERSON",
"tradeName": "Second e.K.", "tradeName": "Second e.K.",
"givenName": "Miller", "givenName": "Miller",
"familyName": "Sandra" "familyName": "Sandra"
}, },
"relHolder": { "relHolder": {
"personType": "NATURAL", "personType": "NATURAL_PERSON",
"givenName": "Peter", "givenName": "Peter",
"familyName": "Smith" "familyName": "Smith"
}, },
@ -111,11 +111,11 @@ class HsOfficeRelationshipControllerAcceptanceTest {
}, },
{ {
"relAnchor": { "relAnchor": {
"personType": "LEGAL", "personType": "LEGAL_PERSON",
"tradeName": "First GmbH" "tradeName": "First GmbH"
}, },
"relHolder": { "relHolder": {
"personType": "NATURAL", "personType": "NATURAL_PERSON",
"tradeName": null, "tradeName": null,
"givenName": "Peter", "givenName": "Peter",
"familyName": "Smith" "familyName": "Smith"

View File

@ -159,9 +159,9 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
// then // then
allTheseRelationshipsAreReturned( allTheseRelationshipsAreReturned(
result, 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')",
"rel(relAnchor='SOLE_REPRESENTATION Third OHG', relType='REPRESENTATIVE', relHolder='NATURAL Smith, Peter', contact='third contact')", "rel(relAnchor='IF Third OHG', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='third contact')",
"rel(relAnchor='LEGAL Second e.K.', relType='REPRESENTATIVE', relHolder='NATURAL Smith, Peter', contact='second contact')"); "rel(relAnchor='LP Second e.K.', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='second contact')");
} }
@Test @Test
@ -176,7 +176,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
// then: // then:
exactlyTheseRelationshipsAreReturned( exactlyTheseRelationshipsAreReturned(
result, 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')");
} }
} }

View File

@ -376,7 +376,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get() assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
.matches(mandate -> { .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.getBankAccount().toShortString()).isEqualTo("First GmbH");
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z - patched"); assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z - patched");
assertThat(mandate.getValidFrom()).isEqualTo("2020-06-05"); assertThat(mandate.getValidFrom()).isEqualTo("2020-06-05");
@ -417,7 +417,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest {
// finally, the sepaMandate is actually updated // finally, the sepaMandate is actually updated
assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get() assertThat(sepaMandateRepo.findByUuid(givenSepaMandate.getUuid())).isPresent().get()
.matches(mandate -> { .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.getBankAccount().toShortString()).isEqualTo("First GmbH");
assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z"); assertThat(mandate.getReference()).isEqualTo("temp ref CAT Z");
assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-01-01)"); assertThat(mandate.getValidity().asString()).isEqualTo("[2022-11-01,2023-01-01)");

View File

@ -9,6 +9,7 @@ import net.hostsharing.test.JpaAttempt;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -42,6 +43,14 @@ class RbacUserControllerAcceptanceTest {
@Autowired @Autowired
RbacUserRepository rbacUserRepository; RbacUserRepository rbacUserRepository;
@Value("${HSADMINNG_POSTGRES_RESTRICTED_USERNAME}")
String restrictedUser;
@Test
void testEnv() {
assertThat(restrictedUser).isEqualTo("restricted");
}
@Nested @Nested
class CreateRbacUser { class CreateRbacUser {