Compare commits

...

5 Commits

Author SHA1 Message Date
Michael Hoennig
066e19185c add partner without contact data to import test data and improve error message 2024-01-26 11:34:39 +01:00
Michael Hoennig
26bb14ebd7 add test cases for import 2024-01-26 10:23:58 +01:00
Michael Hoennig
5b5e911030 amend person related tests to new test data 2024-01-26 09:07:50 +01:00
Michael Hoennig
78b4fce761 amend relationship related tests 2024-01-26 08:56:30 +01:00
Michael Hoennig
f626311273 added TODO on Contact.emailaddresses: check if we really want multiple, ... 2024-01-25 17:05:42 +01:00
10 changed files with 170 additions and 147 deletions

View File

@ -36,7 +36,7 @@ public class HsOfficeContactEntity implements Stringifyable, HasUuid {
private String label; private String label;
@Column(name = "postaladdress") @Column(name = "postaladdress")
private String postalAddress; private String postalAddress; // TODO: check if we really want multiple, if so: JSON-Array or Postgres-Array?
@Column(name = "emailaddresses", columnDefinition = "json") @Column(name = "emailaddresses", columnDefinition = "json")
private String emailAddresses; // TODO: check if we can really add multiple. format: ["eins@...", "zwei@..."] private String emailAddresses; // TODO: check if we can really add multiple. format: ["eins@...", "zwei@..."]

View File

@ -7,6 +7,7 @@ components:
type: string type: string
enum: enum:
- UNKNOWN - UNKNOWN
- PARTNER
- EX_PARTNER - EX_PARTNER
- REPRESENTATIVE, - REPRESENTATIVE,
- VIP_CONTACT - VIP_CONTACT

View File

@ -65,7 +65,7 @@ do language plpgsql $$
call createHsOfficePersonTestData('NP', null, 'Smith', 'Peter'); call createHsOfficePersonTestData('NP', null, 'Smith', 'Peter');
call createHsOfficePersonTestData('NP', null, 'Tucker', 'Jack'); call createHsOfficePersonTestData('NP', null, 'Tucker', 'Jack');
call createHsOfficePersonTestData('NP', null, 'Fouler', 'Ellie'); call createHsOfficePersonTestData('NP', null, 'Fouler', 'Ellie');
call createHsOfficePersonTestData('LP', 'Second e.K.', 'Sandra', 'Miller'); call createHsOfficePersonTestData('LP', 'Second e.K.', 'Smith', 'Peter');
call createHsOfficePersonTestData('IF', 'Third OHG'); call createHsOfficePersonTestData('IF', 'Third OHG');
call createHsOfficePersonTestData('IF', 'Fourth eG'); call createHsOfficePersonTestData('IF', 'Fourth eG');
call createHsOfficePersonTestData('UF', 'Erben Bessler', 'Mel', 'Bessler'); call createHsOfficePersonTestData('UF', 'Erben Bessler', 'Mel', 'Bessler');

View File

@ -182,7 +182,8 @@ public class ImportOfficeData extends ContextBasedTest {
{ {
17=partner(null null, null), 17=partner(null null, null),
20=partner(null null, null), 20=partner(null null, null),
22=partner(null null, null) 22=partner(null null, null),
99=partner(null null, null)
} }
"""); """);
assertThat(toFormattedString(contacts)).isEqualTo("{}"); assertThat(toFormattedString(contacts)).isEqualTo("{}");
@ -190,7 +191,9 @@ public class ImportOfficeData extends ContextBasedTest {
{ {
17=debitor(D-1001700: null null, null: mih), 17=debitor(D-1001700: null null, null: mih),
20=debitor(D-1002000: null null, null: xyz), 20=debitor(D-1002000: null null, null: xyz),
22=debitor(D-1102200: null null, null: xxx)} 22=debitor(D-1102200: null null, null: xxx),
99=debitor(D-1999900: null null, null: zzz)
}
"""); """);
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
{ {
@ -222,7 +225,8 @@ public class ImportOfficeData extends ContextBasedTest {
{ {
17=partner(NP Mellies, Michael: Herr Michael Mellies ), 17=partner(NP Mellies, Michael: Herr Michael Mellies ),
20=partner(LP JM GmbH: Herr Philip Meyer-Contract , JM GmbH), 20=partner(LP JM GmbH: Herr Philip Meyer-Contract , JM GmbH),
22=partner(?? Test PS: Petra Schmidt , Test PS) 22=partner(?? Test PS: Petra Schmidt , Test PS),
99=partner(null null, null)
} }
"""); """);
assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace("""
@ -232,7 +236,9 @@ public class ImportOfficeData extends ContextBasedTest {
1201=contact(label='Frau Dr. Jenny Meyer-Billing , JM GmbH', emailAddresses='jm-billing@example.org'), 1201=contact(label='Frau Dr. Jenny Meyer-Billing , JM GmbH', emailAddresses='jm-billing@example.org'),
1202=contact(label='Herr Andrew Meyer-Operation , JM GmbH', emailAddresses='am-operation@example.org'), 1202=contact(label='Herr Andrew Meyer-Operation , JM GmbH', emailAddresses='am-operation@example.org'),
1203=contact(label='Herr Philip Meyer-Contract , JM GmbH', emailAddresses='pm-partner@example.org'), 1203=contact(label='Herr Philip Meyer-Contract , JM GmbH', emailAddresses='pm-partner@example.org'),
1301=contact(label='Petra Schmidt , Test PS', emailAddresses='ps@example.com') 1204=contact(label='Frau Tammy Meyer-VIP , JM GmbH', emailAddresses='tm-vip@example.org'),
1301=contact(label='Petra Schmidt , Test PS', emailAddresses='ps@example.com'),
1401=contact(label='Frau Frauke Fanninga ', emailAddresses='ff@example.org')
} }
"""); """);
assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace("""
@ -243,14 +249,17 @@ public class ImportOfficeData extends ContextBasedTest {
1201=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Billing', givenName='Jenny'), 1201=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Billing', givenName='Jenny'),
1202=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Operation', givenName='Andrew'), 1202=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Operation', givenName='Andrew'),
1203=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Contract', givenName='Philip'), 1203=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Contract', givenName='Philip'),
1301=person(personType='??', tradeName='Test PS', familyName='Schmidt', givenName='Petra') 1204=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-VIP', givenName='Tammy'),
1301=person(personType='??', tradeName='Test PS', familyName='Schmidt', givenName='Petra'),
1401=person(personType='NP', tradeName='', familyName='Fanninga', givenName='Frauke')
} }
"""); """);
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
{ {
17=debitor(D-1001700: NP Mellies, Michael: mih), 17=debitor(D-1001700: NP Mellies, Michael: mih),
20=debitor(D-1002000: LP JM GmbH: xyz), 20=debitor(D-1002000: LP JM GmbH: xyz),
22=debitor(D-1102200: ?? Test PS: xxx) 22=debitor(D-1102200: ?? Test PS: xxx),
99=debitor(D-1999900: null null, null: zzz)
} }
"""); """);
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
@ -265,17 +274,21 @@ public class ImportOfficeData extends ContextBasedTest {
2000000=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '), 2000000=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '),
2000001=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'), 2000001=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
2000002=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'), 2000002=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
2000003=rel(relAnchor='NP Mellies, Michael', relType='OPERATIONS', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '), 2000003=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='null null, null'),
2000004=rel(relAnchor='LP JM GmbH', relType='EX_PARTNER', relHolder='LP JM e.K.', contact='JM e.K.'), 2000004=rel(relAnchor='NP Mellies, Michael', relType='OPERATIONS', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '),
2000005=rel(relAnchor='LP JM GmbH', relType='OPERATIONS', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'), 2000005=rel(relAnchor='LP JM GmbH', relType='EX_PARTNER', relHolder='LP JM e.K.', contact='JM e.K.'),
2000006=rel(relAnchor='LP JM GmbH', relType='VIP_CONTACT', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'), 2000006=rel(relAnchor='LP JM GmbH', relType='OPERATIONS', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
2000007=rel(relAnchor='LP JM GmbH', relType='SUBSCRIBER', relMark='operations-announce', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'), 2000007=rel(relAnchor='LP JM GmbH', relType='VIP_CONTACT', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
2000008=rel(relAnchor='LP JM GmbH', relType='REPRESENTATIVE', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'), 2000008=rel(relAnchor='LP JM GmbH', relType='SUBSCRIBER', relMark='operations-announce', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
2000009=rel(relAnchor='LP JM GmbH', relType='SUBSCRIBER', relMark='members-announce', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'), 2000009=rel(relAnchor='LP JM GmbH', relType='REPRESENTATIVE', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
2000010=rel(relAnchor='LP JM GmbH', relType='SUBSCRIBER', relMark='customers-announce', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'), 2000010=rel(relAnchor='LP JM GmbH', relType='SUBSCRIBER', relMark='members-announce', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
2000011=rel(relAnchor='?? Test PS', relType='OPERATIONS', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'), 2000011=rel(relAnchor='LP JM GmbH', relType='SUBSCRIBER', relMark='customers-announce', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
2000012=rel(relAnchor='?? Test PS', relType='REPRESENTATIVE', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'), 2000012=rel(relAnchor='LP JM GmbH', relType='VIP_CONTACT', relHolder='LP JM GmbH', contact='Frau Tammy Meyer-VIP , JM GmbH'),
2000013=rel(relAnchor='NP Mellies, Michael', relType='REPRESENTATIVE', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies ') 2000013=rel(relAnchor='?? Test PS', relType='OPERATIONS', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
2000014=rel(relAnchor='?? Test PS', relType='REPRESENTATIVE', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
2000015=rel(relAnchor='NP Mellies, Michael', relType='SUBSCRIBER', relMark='operations-announce', relHolder='NP Fanninga, Frauke', contact='Frau Frauke Fanninga '),
2000016=rel(relAnchor='NP Mellies, Michael', relType='REPRESENTATIVE', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '),
2000017=rel(relAnchor='null null, null', relType='REPRESENTATIVE', relHolder='null null, null')
} }
"""); """);
} }
@ -372,6 +385,73 @@ public class ImportOfficeData extends ContextBasedTest {
@Test @Test
@Order(2000) @Order(2000)
void verifyAllPartnersHavePersons() {
partners.forEach((id, p) -> {
if ( id != 99 ) {
assertThat(p.getContact()).describedAs("partner " + id + " without contact").isNotNull();
assertThat(p.getContact().getLabel()).describedAs("partner " + id + " without valid contact").isNotNull();
assertThat(p.getPerson()).describedAs("partner " + id + " without person").isNotNull();
assertThat(p.getPerson().getPersonType()).describedAs("partner " + id + " without valid person").isNotNull();
}
});
}
@Test
@Order(2001)
void removeEmptyRelationships() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberetely invalid partner entry #99
final var idsToRemove = new HashSet<Integer>();
relationships.forEach( (id, r) -> {
// such a record
if (r.getContact() == null || r.getContact().getLabel() == null ||
r.getRelHolder() == null | r.getRelHolder().getPersonType() == null ) {
idsToRemove.add(id);
}
});
assertThat(idsToRemove.size()).isEqualTo(2); // only from partner #99 (partner+contractual roles)
idsToRemove.forEach(id -> relationships.remove(id));
}
@Test
@Order(2002)
void removeEmptyPartners() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberetely invalid partner entry #99
final var idsToRemove = new HashSet<Integer>();
partners.forEach( (id, r) -> {
// such a record
if (r.getContact() == null || r.getContact().getLabel() == null ||
r.getPerson() == null | r.getPerson().getPersonType() == null ) {
idsToRemove.add(id);
}
});
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99
idsToRemove.forEach(id -> partners.remove(id));
}
@Test
@Order(2003)
void removeEmptyDebitors() {
assumeThatWeAreImportingControlledTestData();
// avoid a error when persisting the deliberetely invalid partner entry #99
final var idsToRemove = new HashSet<Integer>();
debitors.forEach( (id, r) -> {
// such a record
if (r.getBillingContact() == null || r.getBillingContact().getLabel() == null ||
r.getPartner().getPerson() == null | r.getPartner().getPerson().getPersonType() == null ) {
idsToRemove.add(id);
}
});
assertThat(idsToRemove.size()).isEqualTo(1); // only from partner #99
idsToRemove.forEach(id -> debitors.remove(id));
}
@Test
@Order(3000)
@Commit @Commit
void persistEntities() { void persistEntities() {
@ -441,13 +521,13 @@ public class ImportOfficeData extends ContextBasedTest {
private void persist(final Integer id, final HasUuid entity) { private void persist(final Integer id, final HasUuid entity) {
try { try {
System.out.println("persisting #" + entity.hashCode() + ": " + entity.toString()); System.out.println("persisting #" + entity.hashCode() + ": " + entity);
em.persist(entity); em.persist(entity);
em.flush(); em.flush();
System.out.println("persisted #" + entity.hashCode() + " as " + entity.getUuid()); System.out.println("persisted #" + entity.hashCode() + " as " + entity.getUuid());
} catch (Exception x) { } catch (Exception exc) {
System.out.println("failed to persist: " + entity.toString()); System.err.println("failed to persist #" + entity.hashCode() + ": " + entity);
throw x; System.err.println(exc);
} }
} }
@ -602,8 +682,6 @@ public class ImportOfficeData extends ContextBasedTest {
.build(); .build();
debitors.put(rec.getInteger("bp_id"), debitor); debitors.put(rec.getInteger("bp_id"), debitor);
partners.put(rec.getInteger("bp_id"), partner);
if (isNotBlank(rec.getString("member_since"))) { if (isNotBlank(rec.getString("member_since"))) {
assertThat(rec.getInteger("member_id")).isEqualTo(partner.getPartnerNumber()); assertThat(rec.getInteger("member_id")).isEqualTo(partner.getPartnerNumber());
final var membership = HsOfficeMembershipEntity.builder() final var membership = HsOfficeMembershipEntity.builder()

View File

@ -23,8 +23,7 @@ import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals; import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.startsWith;
@SpringBootTest( @SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
@ -66,59 +65,7 @@ class HsOfficePersonControllerAcceptanceTest {
.then().log().all().assertThat() .then().log().all().assertThat()
.statusCode(200) .statusCode(200)
.contentType("application/json") .contentType("application/json")
.body("", lenientlyEquals(""" .body("", hasSize(12));
[
{
"personType": "LEGAL_PERSON",
"tradeName": "First GmbH",
"givenName": null,
"familyName": null
},
{
"personType": "LEGAL_PERSON",
"tradeName": "Second e.K.",
"givenName": "Miller",
"familyName": "Sandra"
},
{
"personType": "INCORPORATED_FIRM",
"tradeName": "Third OHG",
"givenName": null,
"familyName": null
},
{
"personType": "INCORPORATED_FIRM",
"tradeName": "Fourth eG",
"givenName": null,
"familyName": null
},
{
"personType": "NATURAL_PERSON",
"tradeName": null,
"givenName": "Anita",
"familyName": "Bessler"
},
{
"personType": "UNINCORPORATED_FIRM",
"tradeName": "Erben Bessler",
"givenName": "Bessler",
"familyName": "Mel"
},
{
"personType": "NATURAL_PERSON",
"tradeName": null,
"givenName": "Peter",
"familyName": "Smith"
},
{
"personType": "NATURAL_PERSON",
"tradeName": null,
"givenName": "Paul",
"familyName": "Winkler"
}
]
"""
));
// @formatter:on // @formatter:on
} }
} }

View File

@ -273,7 +273,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTest {
// then // then
assertThat(customerLogEntries).map(Arrays::toString).contains( assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating person test-data First GmbH, hs_office_person, INSERT]", "[creating person test-data First GmbH, hs_office_person, INSERT]",
"[creating person test-data Second e.K., Sandra, Miller, hs_office_person, INSERT]"); "[creating person test-data Second e.K., Smith, Peter, hs_office_person, INSERT]");
} }
@AfterEach @AfterEach

View File

@ -35,6 +35,7 @@ import static org.hamcrest.Matchers.startsWith;
@Transactional @Transactional
class HsOfficeRelationshipControllerAcceptanceTest { class HsOfficeRelationshipControllerAcceptanceTest {
public static final UUID GIVEN_NON_EXISTING_HOLDER_PERSON_UUID = UUID.fromString("3fa85f64-5717-4562-b3fc-2c963f66afa6");
@LocalServerPort @LocalServerPort
private Integer port; private Integer port;
@ -67,7 +68,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
// given // given
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPerson = personRepo.findPersonByOptionalNameLike("Smith").get(0); final var givenPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -75,55 +76,47 @@ class HsOfficeRelationshipControllerAcceptanceTest {
.port(port) .port(port)
.when() .when()
.get("http://localhost/api/hs/office/relationships?personUuid=%s&relationshipType=%s" .get("http://localhost/api/hs/office/relationships?personUuid=%s&relationshipType=%s"
.formatted(givenPerson.getUuid(), HsOfficeRelationshipTypeResource.REPRESENTATIVE)) .formatted(givenPerson.getUuid(), HsOfficeRelationshipTypeResource.PARTNER))
.then().log().all().assertThat() .then().log().all().assertThat()
.statusCode(200) .statusCode(200)
.contentType("application/json") .contentType("application/json")
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
[ [
{ {
"relAnchor": { "relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
"personType": "INCORPORATED_FIRM", "relHolder": { "personType": "LEGAL_PERSON", "tradeName": "First GmbH" },
"tradeName": "Third OHG" "relType": "PARTNER",
}, "relMark": null,
"relHolder": { "contact": { "label": "first contact" }
"personType": "NATURAL_PERSON", },
"givenName": "Peter", {
"familyName": "Smith" "relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
}, "relHolder": { "personType": "INCORPORATED_FIRM", "tradeName": "Fourth eG" },
"relType": "REPRESENTATIVE", "relType": "PARTNER",
"contact": { "label": "third contact" } "contact": { "label": "fourth contact" }
}, },
{ {
"relAnchor": { "relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
"personType": "LEGAL_PERSON", "relHolder": { "personType": "LEGAL_PERSON", "tradeName": "Second e.K.", "givenName": "Peter", "familyName": "Smith" },
"tradeName": "Second e.K.", "relType": "PARTNER",
"givenName": "Miller", "relMark": null,
"familyName": "Sandra" "contact": { "label": "second contact" }
}, },
"relHolder": { {
"personType": "NATURAL_PERSON", "relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
"givenName": "Peter", "relHolder": { "personType": "NATURAL_PERSON", "givenName": "Peter", "familyName": "Smith" },
"familyName": "Smith" "relType": "PARTNER",
}, "relMark": null,
"relType": "REPRESENTATIVE", "contact": { "label": "sixth contact" }
"contact": { "label": "second contact" } },
}, {
{ "relAnchor": { "personType": "LEGAL_PERSON", "tradeName": "Hostsharing eG" },
"relAnchor": { "relHolder": { "personType": "INCORPORATED_FIRM", "tradeName": "Third OHG" },
"personType": "LEGAL_PERSON", "relType": "PARTNER",
"tradeName": "First GmbH" "relMark": null,
}, "contact": { "label": "third contact" }
"relHolder": { }
"personType": "NATURAL_PERSON", ]
"tradeName": null,
"givenName": "Peter",
"familyName": "Smith"
},
"relType": "REPRESENTATIVE",
"contact": { "label": "first contact" }
}
]
""")); """));
// @formatter:on // @formatter:on
} }
@ -139,7 +132,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0); final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Paul").get(0); final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Paul").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth").get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike("second").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -167,7 +160,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
.body("relType", is("ACCOUNTING")) .body("relType", is("ACCOUNTING"))
.body("relAnchor.tradeName", is("Third OHG")) .body("relAnchor.tradeName", is("Third OHG"))
.body("relHolder.givenName", is("Paul")) .body("relHolder.givenName", is("Paul"))
.body("contact.label", is("fourth contact")) .body("contact.label", is("second contact"))
.header("Location", startsWith("http://localhost")) .header("Location", startsWith("http://localhost"))
.extract().header("Location"); // @formatter:on .extract().header("Location"); // @formatter:on
@ -181,9 +174,9 @@ class HsOfficeRelationshipControllerAcceptanceTest {
void globalAdmin_canNotAddRelationship_ifAnchorPersonDoesNotExist() { void globalAdmin_canNotAddRelationship_ifAnchorPersonDoesNotExist() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenAnchorPersonUuid = UUID.fromString("3fa85f64-5717-4562-b3fc-2c963f66afa6"); final var givenAnchorPersonUuid = GIVEN_NON_EXISTING_HOLDER_PERSON_UUID;
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Smith").get(0); final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Smith").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth").get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -206,7 +199,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
.post("http://localhost/api/hs/office/relationships") .post("http://localhost/api/hs/office/relationships")
.then().log().all().assertThat() .then().log().all().assertThat()
.statusCode(404) .statusCode(404)
.body("message", is("cannot find relAnchorUuid 3fa85f64-5717-4562-b3fc-2c963f66afa6")); .body("message", is("cannot find relAnchorUuid " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID));
// @formatter:on // @formatter:on
} }
@ -215,8 +208,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0); final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
final var givenHolderPersonUuid = UUID.fromString("3fa85f64-5717-4562-b3fc-2c963f66afa6"); final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0);
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()
@ -232,14 +224,14 @@ class HsOfficeRelationshipControllerAcceptanceTest {
""".formatted( """.formatted(
HsOfficeRelationshipTypeResource.ACCOUNTING, HsOfficeRelationshipTypeResource.ACCOUNTING,
givenAnchorPerson.getUuid(), givenAnchorPerson.getUuid(),
givenHolderPersonUuid, GIVEN_NON_EXISTING_HOLDER_PERSON_UUID,
givenContact.getUuid())) givenContact.getUuid()))
.port(port) .port(port)
.when() .when()
.post("http://localhost/api/hs/office/relationships") .post("http://localhost/api/hs/office/relationships")
.then().log().all().assertThat() .then().log().all().assertThat()
.statusCode(404) .statusCode(404)
.body("message", is("cannot find relHolderUuid 3fa85f64-5717-4562-b3fc-2c963f66afa6")); .body("message", is("cannot find relHolderUuid " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID));
// @formatter:on // @formatter:on
} }
@ -284,7 +276,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
@Test @Test
void globalAdmin_withoutAssumedRole_canGetArbitraryRelationship() { void globalAdmin_withoutAssumedRole_canGetArbitraryRelationship() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final UUID givenRelationshipUuid = findRelationship("First", "Smith").getUuid(); final UUID givenRelationshipUuid = findRelationship("First", "Firby").getUuid();
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -298,7 +290,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
{ {
"relAnchor": { "tradeName": "First GmbH" }, "relAnchor": { "tradeName": "First GmbH" },
"relHolder": { "familyName": "Smith" }, "relHolder": { "familyName": "Firby" },
"contact": { "label": "first contact" } "contact": { "label": "first contact" }
} }
""")); // @formatter:on """)); // @formatter:on
@ -308,7 +300,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
@Accepts({ "Relationship:X(Access Control)" }) @Accepts({ "Relationship:X(Access Control)" })
void normalUser_canNotGetUnrelatedRelationship() { void normalUser_canNotGetUnrelatedRelationship() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final UUID givenRelationshipUuid = findRelationship("First", "Smith").getUuid(); final UUID givenRelationshipUuid = findRelationship("First", "Firby").getUuid();
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -324,7 +316,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
@Accepts({ "Relationship:X(Access Control)" }) @Accepts({ "Relationship:X(Access Control)" })
void contactAdminUser_canGetRelatedRelationship() { void contactAdminUser_canGetRelatedRelationship() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenRelationship = findRelationship("First", "Smith"); final var givenRelationship = findRelationship("First", "Firby");
assertThat(givenRelationship.getContact().getLabel()).isEqualTo("first contact"); assertThat(givenRelationship.getContact().getLabel()).isEqualTo("first contact");
RestAssured // @formatter:off RestAssured // @formatter:off
@ -339,7 +331,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
.body("", lenientlyEquals(""" .body("", lenientlyEquals("""
{ {
"relAnchor": { "tradeName": "First GmbH" }, "relAnchor": { "tradeName": "First GmbH" },
"relHolder": { "familyName": "Smith" }, "relHolder": { "familyName": "Firby" },
"contact": { "label": "first contact" } "contact": { "label": "first contact" }
} }
""")); // @formatter:on """)); // @formatter:on
@ -369,7 +361,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenRelationship = givenSomeTemporaryRelationshipBessler(); final var givenRelationship = givenSomeTemporaryRelationshipBessler();
assertThat(givenRelationship.getContact().getLabel()).isEqualTo("seventh contact"); assertThat(givenRelationship.getContact().getLabel()).isEqualTo("seventh contact");
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth").get(0); final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth").get(0);
final var location = RestAssured // @formatter:off final var location = RestAssured // @formatter:off
.given() .given()

View File

@ -151,7 +151,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
public void globalAdmin_withoutAssumedRole_canViewAllRelationshipsOfArbitraryPerson() { public void globalAdmin_withoutAssumedRole_canViewAllRelationshipsOfArbitraryPerson() {
// given // given
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
final var person = personRepo.findPersonByOptionalNameLike("Smith").stream().findFirst().orElseThrow(); final var person = personRepo.findPersonByOptionalNameLike("Second e.K.").stream().findFirst().orElseThrow();
// when // when
final var result = relationshipRepo.findRelationshipRelatedToPersonUuid(person.getUuid()); final var result = relationshipRepo.findRelationshipRelatedToPersonUuid(person.getUuid());
@ -159,8 +159,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
// then // then
allTheseRelationshipsAreReturned( allTheseRelationshipsAreReturned(
result, result,
"rel(relAnchor='LP First GmbH', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='first contact')", "rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='LP Second e.K.', contact='second 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')"); "rel(relAnchor='LP Second e.K.', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='second contact')");
} }
@ -176,7 +175,8 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
// then: // then:
exactlyTheseRelationshipsAreReturned( exactlyTheseRelationshipsAreReturned(
result, result,
"rel(relAnchor='LP First GmbH', relType='REPRESENTATIVE', relHolder='NP Smith, Peter', contact='first contact')"); "rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='LP First GmbH', contact='first contact')",
"rel(relAnchor='LP First GmbH', relType='REPRESENTATIVE', relHolder='NP Firby, Susan', contact='first contact')");
} }
} }
@ -380,8 +380,8 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
// then // then
assertThat(customerLogEntries).map(Arrays::toString).contains( assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating relationship test-data FirstGmbH-Smith, hs_office_relationship, INSERT]", "[creating relationship test-data HostsharingeG-FirstGmbH, hs_office_relationship, INSERT]",
"[creating relationship test-data Seconde.K.-Smith, hs_office_relationship, INSERT]"); "[creating relationship test-data FirstGmbH-Firby, hs_office_relationship, INSERT]");
} }
private HsOfficeRelationshipEntity givenSomeTemporaryRelationshipBessler(final String holderPerson, final String contact) { private HsOfficeRelationshipEntity givenSomeTemporaryRelationshipBessler(final String holderPerson, final String contact) {

View File

@ -2,3 +2,4 @@ bp_id;member_id;member_code;member_since;member_until;member_role;author_contrac
17;10017;hsh00-mih;2000-12-06;;Aufsichtsrat;2006-10-15;2001-10-15;false;false;NET;DE-VAT-007 17;10017;hsh00-mih;2000-12-06;;Aufsichtsrat;2006-10-15;2001-10-15;false;false;NET;DE-VAT-007
20;10020;hsh00-xyz;2000-12-06;2015-12-31;;;;false;false;GROSS; 20;10020;hsh00-xyz;2000-12-06;2015-12-31;;;;false;false;GROSS;
22;11022;hsh00-xxx;2021-04-01;;;;;true;true;GROSS; 22;11022;hsh00-xxx;2021-04-01;;;;;true;true;GROSS;
99;19999;hsh00-zzz;;;;;;false;false;GROSS;

1 bp_id member_id member_code member_since member_until member_role author_contract nondisc_contract free exempt_vat indicator_vat uid_vat
2 17 10017 hsh00-mih 2000-12-06 Aufsichtsrat 2006-10-15 2001-10-15 false false NET DE-VAT-007
3 20 10020 hsh00-xyz 2000-12-06 2015-12-31 false false GROSS
4 22 11022 hsh00-xxx 2021-04-01 true true GROSS
5 99 19999 hsh00-zzz false false GROSS

View File

@ -8,6 +8,10 @@ contact_id; bp_id; salut; first_name; last_name; title; firma; co; street; zip
1201; 20; Frau; Jenny; Meyer-Billing; Dr.; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 7777777; +49 30 1111111; ; +49 30 2222222; jm-billing@example.org; billing 1201; 20; Frau; Jenny; Meyer-Billing; Dr.; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 7777777; +49 30 1111111; ; +49 30 2222222; jm-billing@example.org; billing
1202; 20; Herr; Andrew; Meyer-Operation; ; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 6666666; +49 30 3333333; ; +49 30 4444444; am-operation@example.org; operation,vip-contact,subscriber:operations-announce 1202; 20; Herr; Andrew; Meyer-Operation; ; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 6666666; +49 30 3333333; ; +49 30 4444444; am-operation@example.org; operation,vip-contact,subscriber:operations-announce
1203; 20; Herr; Philip; Meyer-Contract; ; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 6666666; +49 30 5555555; ; +49 30 6666666; pm-partner@example.org; partner,contractual,subscriber:members-announce,subscriber:customers-announce 1203; 20; Herr; Philip; Meyer-Contract; ; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 6666666; +49 30 5555555; ; +49 30 6666666; pm-partner@example.org; partner,contractual,subscriber:members-announce,subscriber:customers-announce
1204; 20; Frau; Tammy; Meyer-VIP; ; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 999999; +49 30 999999; ; +49 30 6666666; tm-vip@example.org; vip-contact
# eine juristische Person mit nur einem Ansprechpartner und explizitem contractual # eine juristische Person mit nur einem Ansprechpartner und explizitem contractual
1301; 22; ; Petra; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; partner,billing,contractual,operation 1301; 22; ; Petra; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; partner,billing,contractual,operation
# eine natürliche Person, die nur Subscriber ist
1401; 17; Frau; Frauke; Fanninga; ; ; ; Am Walde 1; 29456; Hitzacker; DE; ; ; ;; ff@example.org; subscriber:operations-announce

1 contact_id; bp_id; salut; first_name; last_name; title; firma; co; street; zipcode;city; country; phone_private; phone_office; phone_mobile; fax; email; roles
8 1203; 20; Herr; Philip; Meyer-Contract; ; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 6666666; +49 30 5555555; ; +49 30 6666666; pm-partner@example.org; partner,contractual,subscriber:members-announce,subscriber:customers-announce
9 # eine juristische Person mit nur einem Ansprechpartner und explizitem contractual 1204; 20; Frau; Tammy; Meyer-VIP; ; JM GmbH;; Waldweg 5; 11001; Berlin; DE; +49 30 999999; +49 30 999999; ; +49 30 6666666; tm-vip@example.org; vip-contact
10 1301; 22; ; Petra; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; partner,billing,contractual,operation # eine juristische Person mit nur einem Ansprechpartner und explizitem contractual
11 1301; 22; ; Petra; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; partner,billing,contractual,operation
12 # eine natürliche Person, die nur Subscriber ist
13 1401; 17; Frau; Frauke; Fanninga; ; ; ; Am Walde 1; 29456; Hitzacker; DE; ; ; ;; ff@example.org; subscriber:operations-announce
14
15
16
17