|
|
|
@ -111,6 +111,8 @@ import static org.assertj.core.api.Fail.fail;
|
|
|
|
|
@ExtendWith(OrderedDependedTestsExtension.class)
|
|
|
|
|
public class ImportOfficeData extends ContextBasedTest {
|
|
|
|
|
|
|
|
|
|
static int relationshipId = 2000000;
|
|
|
|
|
|
|
|
|
|
@Value("${spring.datasource.username}")
|
|
|
|
|
private String postgresAdminUser;
|
|
|
|
|
|
|
|
|
@ -194,48 +196,54 @@ public class ImportOfficeData extends ContextBasedTest {
|
|
|
|
|
assertThat(toFormattedString(partners)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
17=partner(NATURAL Mellies, Michael: Herr Michael Mellies ),
|
|
|
|
|
20=partner(LEGAL JM e.K.: Herr Philip Meyer-Contract , JM e.K.),
|
|
|
|
|
20=partner(LEGAL JM GmbH: Herr Philip Meyer-Contract , JM GmbH),
|
|
|
|
|
22=partner(LEGAL Test PS: Petra Schmidt , Test PS)
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
|
assertThat(toFormattedString(contacts)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
1101=contact(label='Herr Michael Mellies ', emailAddresses='mih@example.org'),
|
|
|
|
|
1201=contact(label='Frau Dr. Jenny Meyer-Billing , JM e.K.', emailAddresses='jm-billing@example.org'),
|
|
|
|
|
1202=contact(label='Herr Andrew Meyer-Operation , JM e.K.', emailAddresses='am-operation@example.org'),
|
|
|
|
|
1203=contact(label='Herr Philip Meyer-Contract , JM e.K.', emailAddresses='pm-partner@example.org'),
|
|
|
|
|
1200=contact(label='JM e.K.', emailAddresses='jm-ex-partner@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'),
|
|
|
|
|
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')
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
|
assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
1101=person(personType='NATURAL', tradeName='', familyName='Mellies', givenName='Michael'),
|
|
|
|
|
1201=person(personType='LEGAL', tradeName='JM e.K.', familyName='Meyer-Billing', givenName='Jenny'),
|
|
|
|
|
1202=person(personType='LEGAL', tradeName='JM e.K.', familyName='Meyer-Operation', givenName='Andrew'),
|
|
|
|
|
1203=person(personType='LEGAL', tradeName='JM e.K.', familyName='Meyer-Contract', givenName='Philip'),
|
|
|
|
|
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')
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
|
assertThat(toFormattedString(debitors)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
17=debitor(1001700: NATURAL Mellies, Michael: mih),
|
|
|
|
|
20=debitor(1002000: LEGAL JM e.K.: xyz),
|
|
|
|
|
20=debitor(1002000: LEGAL JM GmbH: xyz),
|
|
|
|
|
22=debitor(1102200: LEGAL Test PS: xxx)
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
|
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
17=Membership(10017, NATURAL Mellies, Michael, 1001700, [2000-12-06,), NONE),
|
|
|
|
|
20=Membership(10020, LEGAL JM e.K., 1002000, [2000-12-06,2016-01-01), UNKNOWN),
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
|
assertThat(toFormattedString(relationships)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
1101=rel(relAnchor='NATURAL Mellies, Michael', relType='OPERATIONS', relHolder='NATURAL Mellies, Michael', contact='Herr Michael Mellies '),
|
|
|
|
|
1202=rel(relAnchor='LEGAL JM e.K.', relType='OPERATIONS', relHolder='LEGAL JM e.K.', contact='Herr Andrew Meyer-Operation , JM e.K.'),
|
|
|
|
|
1203=rel(relAnchor='LEGAL JM e.K.', relType='REPRESENTATIVE', relHolder='LEGAL JM e.K.', contact='Herr Philip Meyer-Contract , JM e.K.'),
|
|
|
|
|
1301=rel(relAnchor='LEGAL Test PS', relType='REPRESENTATIVE', relHolder='LEGAL Test PS', contact='Petra Schmidt , Test PS')
|
|
|
|
|
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 ')
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
|
}
|
|
|
|
@ -253,15 +261,17 @@ public class ImportOfficeData extends ContextBasedTest {
|
|
|
|
|
|
|
|
|
|
assumeThat(postgresAdminUser).isEqualTo("admin");
|
|
|
|
|
|
|
|
|
|
assertThat(bankAccounts.toString()).isEqualToIgnoringWhitespace("""
|
|
|
|
|
assertThat(toFormattedString(bankAccounts)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
234234=bankAccount(holder='Michael Mellies', iban='DE37500105177419788228', bic='INGDDEFFXXX'),
|
|
|
|
|
235662=bankAccount(holder='JM e.K.', iban='DE49500105174516484892', bic='INGDDEFFXXX')
|
|
|
|
|
235600=bankAccount(holder='JM e.K.', iban='DE02300209000106531065', bic='CMCIDEDD'),
|
|
|
|
|
235662=bankAccount(holder='JM GmbH', iban='DE49500105174516484892', bic='INGDDEFFXXX')
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
|
assertThat(sepaMandates.toString()).isEqualToIgnoringWhitespace("""
|
|
|
|
|
assertThat(toFormattedString(sepaMandates)).isEqualToIgnoringWhitespace("""
|
|
|
|
|
{
|
|
|
|
|
234234=SEPA-Mandate(DE37500105177419788228, MH12345, 2004-06-12, [2004-06-15,)),
|
|
|
|
|
235600=SEPA-Mandate(DE02300209000106531065, JM33344, 2004-01-15, [2004-01-20,2005-06-28)),
|
|
|
|
|
235662=SEPA-Mandate(DE49500105174516484892, JM33344, 2005-06-28, [2005-07-01,))
|
|
|
|
|
}
|
|
|
|
|
""");
|
|
|
|
@ -686,7 +696,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
|
|
|
|
final var debitor = debitors.get(rec.getInteger("bp_id"));
|
|
|
|
|
|
|
|
|
|
final var partnerPerson = partner.getPerson();
|
|
|
|
|
if (rec.getString("roles").contains("partner")) {
|
|
|
|
|
if (containsRole(rec)) {
|
|
|
|
|
initPerson(partner.getPerson(), rec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -700,43 +710,62 @@ public class ImportOfficeData extends ContextBasedTest {
|
|
|
|
|
final var contact = HsOfficeContactEntity.builder().build();
|
|
|
|
|
initContact(contact, rec);
|
|
|
|
|
|
|
|
|
|
if (rec.getString("roles").contains("partner")) {
|
|
|
|
|
if (containsRole(rec, "partner")) {
|
|
|
|
|
assertThat(partner.getContact()).isNull();
|
|
|
|
|
partner.setContact(contact);
|
|
|
|
|
}
|
|
|
|
|
if (rec.getString("roles").contains("billing")) {
|
|
|
|
|
if (containsRole(rec, "billing")) {
|
|
|
|
|
assertThat(debitor.getBillingContact()).isNull();
|
|
|
|
|
debitor.setBillingContact(contact);
|
|
|
|
|
}
|
|
|
|
|
if (rec.getString("roles").contains("operation")) {
|
|
|
|
|
final var rel = HsOfficeRelationshipEntity.builder()
|
|
|
|
|
.relAnchor(partnerPerson)
|
|
|
|
|
.relHolder(contactPerson)
|
|
|
|
|
.contact(contact)
|
|
|
|
|
.relType(HsOfficeRelationshipType.OPERATIONS)
|
|
|
|
|
.build();
|
|
|
|
|
relationships.put(contactId, rel);
|
|
|
|
|
if (containsRole(rec, "operation")) {
|
|
|
|
|
addRelationship(partnerPerson, contactPerson, contact, HsOfficeRelationshipType.OPERATIONS);
|
|
|
|
|
}
|
|
|
|
|
if (rec.getString("roles").contains("contractual")) {
|
|
|
|
|
final var rel = HsOfficeRelationshipEntity.builder()
|
|
|
|
|
.relAnchor(partnerPerson)
|
|
|
|
|
.relHolder(contactPerson)
|
|
|
|
|
.contact(contact)
|
|
|
|
|
.relType(HsOfficeRelationshipType.REPRESENTATIVE)
|
|
|
|
|
.build();
|
|
|
|
|
relationships.put(contactId, rel);
|
|
|
|
|
if (containsRole(rec, "contractual")) {
|
|
|
|
|
addRelationship(partnerPerson, contactPerson, contact, HsOfficeRelationshipType.REPRESENTATIVE);
|
|
|
|
|
}
|
|
|
|
|
if (rec.getString("roles").contains("ex-partner")) {
|
|
|
|
|
final var rel = HsOfficeRelationshipEntity.builder()
|
|
|
|
|
.relAnchor(partnerPerson)
|
|
|
|
|
.relHolder(contactPerson)
|
|
|
|
|
.contact(contact)
|
|
|
|
|
.relType(HsOfficeRelationshipType.EX_PARTNER)
|
|
|
|
|
.build();
|
|
|
|
|
relationships.put(contactId, rel);
|
|
|
|
|
if (containsRole(rec, "ex-partner")) {
|
|
|
|
|
addRelationship(partnerPerson, contactPerson, contact, HsOfficeRelationshipType.EX_PARTNER);
|
|
|
|
|
}
|
|
|
|
|
verifyContainsOnly(rec.getString("roles"), "partner", "ex-partner", "billing", "contractual", "operation");
|
|
|
|
|
if (containsRole(rec, "vip-contact")) {
|
|
|
|
|
addRelationship(partnerPerson, contactPerson, contact, HsOfficeRelationshipType.VIP_CONTACT);
|
|
|
|
|
}
|
|
|
|
|
verifyContainsOnly(rec.getString("roles"), "partner", "vip-contact", "ex-partner", "billing", "contractual", "operation");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
optionallyAddMissingContractualRelationships();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void optionallyAddMissingContractualRelationships() {
|
|
|
|
|
partners.forEach( (id, partner) -> {
|
|
|
|
|
final var partnerPerson = partner.getPerson();
|
|
|
|
|
if (relationships.values().stream().filter(rel -> rel.getRelHolder() == partnerPerson && rel.getRelType() == HsOfficeRelationshipType.REPRESENTATIVE).findFirst().isEmpty()) {
|
|
|
|
|
addRelationship(partnerPerson, partnerPerson, partner.getContact(), HsOfficeRelationshipType.REPRESENTATIVE);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean containsRole(final Record rec, final String role) {
|
|
|
|
|
final var roles = rec.getString("roles");
|
|
|
|
|
return ("," + roles + ",").contains("," + role + ",");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean containsRole(final Record rec) {
|
|
|
|
|
return containsRole(rec, "partner");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void addRelationship(
|
|
|
|
|
final HsOfficePersonEntity partnerPerson,
|
|
|
|
|
final HsOfficePersonEntity contactPerson,
|
|
|
|
|
final HsOfficeContactEntity contact,
|
|
|
|
|
final HsOfficeRelationshipType representative) {
|
|
|
|
|
final var rel = HsOfficeRelationshipEntity.builder()
|
|
|
|
|
.relAnchor(partnerPerson)
|
|
|
|
|
.relHolder(contactPerson)
|
|
|
|
|
.contact(contact)
|
|
|
|
|
.relType(representative)
|
|
|
|
|
.build();
|
|
|
|
|
relationships.put(relationshipId++, rel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private HsOfficePersonEntity initPerson(final HsOfficePersonEntity person, final Record contactRecord) {
|
|
|
|
@ -880,8 +909,8 @@ public class ImportOfficeData extends ContextBasedTest {
|
|
|
|
|
result.append(firstname + " ");
|
|
|
|
|
if (isNotBlank(lastname))
|
|
|
|
|
result.append(lastname + " ");
|
|
|
|
|
if (result.length() > 0 && isNotBlank(firm)) {
|
|
|
|
|
result.append(", " + firm);
|
|
|
|
|
if (isNotBlank(firm)) {
|
|
|
|
|
result.append( (isBlank(result) ? "" : ", ") + firm);
|
|
|
|
|
}
|
|
|
|
|
return result.toString();
|
|
|
|
|
}
|
|
|
|
|