Compare commits

...

5 Commits

Author SHA1 Message Date
Michael Hoennig
70621fd482 always use jdbc:postgresql://localhost:5432/postgres for ImportTestData 2024-01-11 16:49:36 +01:00
Michael Hoennig
e9a8699aa1 delete test data before import 2024-01-11 16:49:10 +01:00
Michael Hoennig
1299b4e20a increase length of hs_office_contact.label to 96 2024-01-11 15:37:38 +01:00
Michael Hoennig
76ad26b747 amend test data (Paule -> Petra) which was confusingly similar to basic test data (Paul) + cleanup 2024-01-11 15:37:01 +01:00
Michael Hoennig
5162aa0606 add defaultPrefix to HsOfficeDebitorEntity.toString() 2024-01-11 15:34:23 +01:00
8 changed files with 175 additions and 60 deletions

View File

@ -25,11 +25,14 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
@DisplayName("Debitor") @DisplayName("Debitor")
public class HsOfficeDebitorEntity implements Stringifyable { public class HsOfficeDebitorEntity implements Stringifyable {
// TODO: I would rather like to generate something matching this example:
// debitor(1234500: Test AG, tes)
// maybe remove withSepararator (always use ', ') and add withBusinessIdProp (with ': ' afterwards)?
private static Stringify<HsOfficeDebitorEntity> stringify = private static Stringify<HsOfficeDebitorEntity> stringify =
stringify(HsOfficeDebitorEntity.class, "debitor") stringify(HsOfficeDebitorEntity.class, "debitor")
.withProp(HsOfficeDebitorEntity::getDebitorNumber) .withProp(HsOfficeDebitorEntity::getDebitorNumber)
.withProp(HsOfficeDebitorEntity::getPartner) .withProp(HsOfficeDebitorEntity::getPartner)
// TODO: add defaultPrefix? .withProp(HsOfficeDebitorEntity::getDefaultPrefix)
.withSeparator(": ") .withSeparator(": ")
.quotedValues(false); .quotedValues(false);

View File

@ -7,7 +7,7 @@
create table if not exists hs_office_contact create table if not exists hs_office_contact
( (
uuid uuid unique references RbacObject (uuid) initially deferred, uuid uuid unique references RbacObject (uuid) initially deferred,
label varchar(96) not null, label varchar(128) not null,
postalAddress text, postalAddress text,
emailAddresses text, -- TODO.feat: change to json emailAddresses text, -- TODO.feat: change to json
phoneNumbers text -- TODO.feat: change to json phoneNumbers text -- TODO.feat: change to json

View File

@ -26,9 +26,6 @@ create or replace function createRbacRolesForHsOfficeContact()
returns trigger returns trigger
language plpgsql language plpgsql
strict as $$ strict as $$
declare
ownerRole uuid;
adminRole uuid;
begin begin
if TG_OP <> 'INSERT' then if TG_OP <> 'INSERT' then
raise exception 'invalid usage of TRIGGER AFTER INSERT'; raise exception 'invalid usage of TRIGGER AFTER INSERT';
@ -107,7 +104,7 @@ do language plpgsql $$
declare declare
addCustomerPermissions uuid[]; addCustomerPermissions uuid[];
globalObjectUuid uuid; globalObjectUuid uuid;
globalAdminRoleUuid uuid ; globalAdminRoleUuid uuid;
begin begin
call defineContext('granting global new-contact permission to global admin role', null, null, null); call defineContext('granting global new-contact permission to global admin role', null, null, null);

View File

@ -22,11 +22,12 @@ class HsOfficeDebitorEntityUnitTest {
.debitorNumberPrefix(12345) .debitorNumberPrefix(12345)
.build()) .build())
.billingContact(HsOfficeContactEntity.builder().label("some label").build()) .billingContact(HsOfficeContactEntity.builder().label("some label").build())
.defaultPrefix("som")
.build(); .build();
final var result = given.toString(); final var result = given.toString();
assertThat(result).isEqualTo("debitor(1234567: some trade name)"); assertThat(result).isEqualTo("debitor(1234567: some trade name: som)");
} }
@Test @Test

View File

@ -215,9 +215,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
// then // then
allTheseDebitorsAreReturned( allTheseDebitorsAreReturned(
result, result,
"debitor(1000111: First GmbH)", "debitor(1000111: First GmbH: fir)",
"debitor(1000212: Second e.K.)", "debitor(1000212: Second e.K.: sec)",
"debitor(1000313: Third OHG)"); "debitor(1000313: Third OHG: thi)");
} }
@ParameterizedTest @ParameterizedTest
@ -234,7 +234,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
final var result = debitorRepo.findDebitorByOptionalNameLike(null); final var result = debitorRepo.findDebitorByOptionalNameLike(null);
// then: // then:
exactlyTheseDebitorsAreReturned(result, "debitor(1000111: First GmbH)", "debitor(1000120: First GmbH)"); exactlyTheseDebitorsAreReturned(result,
"debitor(1000111: First GmbH: fir)",
"debitor(1000120: First GmbH: fif)");
} }
@Test @Test
@ -262,8 +264,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
final var result = debitorRepo.findDebitorByDebitorNumber(1000313); final var result = debitorRepo.findDebitorByDebitorNumber(1000313);
// then // then
// exactlyTheseDebitorsAreReturned(result, "debitor(1000313: Third OHG)", "debitor(1000413: Fourth e.G.)"); exactlyTheseDebitorsAreReturned(result, "debitor(1000313: Third OHG: thi)");
exactlyTheseDebitorsAreReturned(result, "debitor(1000313: Third OHG)");
} }
} }
@ -279,7 +280,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: Third OHG)"); exactlyTheseDebitorsAreReturned(result, "debitor(1000313: Third OHG: thi)");
} }
} }

View File

@ -56,11 +56,15 @@ import static org.assertj.core.api.Assertions.assertThat;
* which reads CSV files from the file system. * which reads CSV files from the file system.
*/ */
@DataJpaTest @Disabled
@DataJpaTest(properties = "spring.datasource.url=jdbc:postgresql://localhost:5432/postgres")
@Import({ Context.class, JpaAttempt.class }) @Import({ Context.class, JpaAttempt.class })
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class ImportOfficeTables extends ContextBasedTest { public class ImportOfficeTables extends ContextBasedTest {
// TODO: use real rbacSuperuser for actual import
private static final String rbacSuperuser = "superuser-alex@hostsharing.net";
private static NavigableMap<Integer, HsOfficeContactEntity> contacts = new TreeMap<>(); private static NavigableMap<Integer, HsOfficeContactEntity> contacts = new TreeMap<>();
private static NavigableMap<Integer, HsOfficePersonEntity> persons = new TreeMap<>(); private static NavigableMap<Integer, HsOfficePersonEntity> persons = new TreeMap<>();
private static NavigableMap<Integer, HsOfficePartnerEntity> partners = new TreeMap<>(); private static NavigableMap<Integer, HsOfficePartnerEntity> partners = new TreeMap<>();
@ -104,11 +108,11 @@ public class ImportOfficeTables extends ContextBasedTest {
"""); """);
assertThat(contacts.toString()).isEqualTo("{}"); assertThat(contacts.toString()).isEqualTo("{}");
assertThat(debitors.toString()).isEqualToIgnoringWhitespace(""" assertThat(debitors.toString()).isEqualToIgnoringWhitespace("""
{ {
7=debitor(1000700: null, null), 7=debitor(1000700: null, null: mih),
10=debitor(1001000: null, null), 10=debitor(1001000: null, null: xyz),
12=debitor(1101200: null, null)} 12=debitor(1101200: null, null: xxx)}
"""); """);
assertThat(memberships.toString()).isEqualToIgnoringWhitespace(""" assertThat(memberships.toString()).isEqualToIgnoringWhitespace("""
{ {
7=Membership(10007, null, null, 1000700, [2000-12-06,), NONE), 7=Membership(10007, null, null, 1000700, [2000-12-06,), NONE),
@ -133,7 +137,7 @@ public class ImportOfficeTables extends ContextBasedTest {
{ {
7=partner(Mellies, Michael: Herr Michael Mellies ), 7=partner(Mellies, Michael: Herr Michael Mellies ),
10=partner(JM e.K.: Frau Dr. Jenny Meyer , JM e.K.), 10=partner(JM e.K.: Frau Dr. Jenny Meyer , JM e.K.),
12=partner(Test PS: Paule Schmidt , Test PS) 12=partner(Test PS: Petra Schmidt , Test PS)
} }
"""); """);
assertThat(contacts.toString()).isEqualToIgnoringWhitespace(""" assertThat(contacts.toString()).isEqualToIgnoringWhitespace("""
@ -141,21 +145,21 @@ public class ImportOfficeTables extends ContextBasedTest {
71=contact(label='Herr Michael Mellies ', emailAddresses='mih@example.org'), 71=contact(label='Herr Michael Mellies ', emailAddresses='mih@example.org'),
101=contact(label='Frau Dr. Jenny Meyer , JM e.K.', emailAddresses='jm@example.org'), 101=contact(label='Frau Dr. Jenny Meyer , JM e.K.', emailAddresses='jm@example.org'),
102=contact(label='Herr Andrew Meyer , JM e.K.', emailAddresses='am@example.org'), 102=contact(label='Herr Andrew Meyer , JM e.K.', emailAddresses='am@example.org'),
121=contact(label='Paule Schmidt , Test PS', emailAddresses='ps@example.com') 121=contact(label='Petra Schmidt , Test PS', emailAddresses='ps@example.com')
} }
"""); """);
assertThat(persons.toString()).isEqualToIgnoringWhitespace(""" assertThat(persons.toString()).isEqualToIgnoringWhitespace("""
{ {
7=person(personType='UNKNOWN', tradeName='', familyName='Mellies', givenName='Michael'), 7=person(personType='UNKNOWN', tradeName='', familyName='Mellies', givenName='Michael'),
10=person(personType='UNKNOWN', tradeName='JM e.K.', familyName='Meyer', givenName='Jenny'), 10=person(personType='UNKNOWN', tradeName='JM e.K.', familyName='Meyer', givenName='Jenny'),
12=person(personType='UNKNOWN', tradeName='Test PS', familyName='Schmidt', givenName='Paule') 12=person(personType='UNKNOWN', tradeName='Test PS', familyName='Schmidt', givenName='Petra')
} }
"""); """);
assertThat(debitors.toString()).isEqualToIgnoringWhitespace(""" assertThat(debitors.toString()).isEqualToIgnoringWhitespace("""
{ {
7=debitor(1000700: Mellies, Michael), 7=debitor(1000700: Mellies, Michael: mih),
10=debitor(1001000: JM e.K.), 10=debitor(1001000: JM e.K.: xyz),
12=debitor(1101200: Test PS) 12=debitor(1101200: Test PS: xxx)
} }
"""); """);
assertThat(memberships.toString()).isEqualToIgnoringWhitespace(""" assertThat(memberships.toString()).isEqualToIgnoringWhitespace("""
@ -241,41 +245,138 @@ public class ImportOfficeTables extends ContextBasedTest {
@Test @Test
@Order(10) @Order(10)
@Commit @Commit
//@Rollback(false)
void persistEntities() { void persistEntities() {
context("superuser-alex@hostsharing.net"); // TODO: use real user for actual import deleteTestDataFromHsOfficeTables();
resetFromHsOfficeSequences();
deleteFromTestTables();
deleteFromRbacTables();
contacts.forEach((id, contact) -> em.persist(contact)); jpaAttempt.transacted(() -> {
updateLegacyIds(contacts, "hs_office_contact_legacy_id", "contact_id"); context(rbacSuperuser);
contacts.forEach((id, contact) -> em.persist(contact));
updateLegacyIds(contacts, "hs_office_contact_legacy_id", "contact_id");
}).assertSuccessful();
persons.forEach((id, person) -> em.persist(person)); jpaAttempt.transacted(() -> {
context(rbacSuperuser);
persons.forEach((id, person) -> em.persist(person));
}).assertSuccessful();
partners.forEach((id, partner) -> em.persist(partner)); jpaAttempt.transacted(() -> {
updateLegacyIds(partners, "hs_office_partner_legacy_id", "bp_id"); context(rbacSuperuser);
partners.forEach((id, partner) -> em.persist(partner));
updateLegacyIds(partners, "hs_office_partner_legacy_id", "bp_id");
}).assertSuccessful();
debitors.forEach((id, debitor) -> em.persist(debitor)); jpaAttempt.transacted(() -> {
memberships.forEach((id, membership) -> em.persist(membership)); context(rbacSuperuser);
bankAccounts.forEach((id, account) -> em.persist(account)); debitors.forEach((id, debitor) -> em.persist(debitor));
}).assertSuccessful();
sepaMandates.forEach((id, mandate) -> em.persist(mandate)); jpaAttempt.transacted(() -> {
updateLegacyIds(sepaMandates, "hs_office_sepamandate_legacy_id", "sepa_mandate_id"); context(rbacSuperuser);
memberships.forEach((id, membership) -> em.persist(membership));
coopShares.forEach((id, shareTransaction) -> em.persist(shareTransaction)); }).assertSuccessful();
updateLegacyIds(coopShares, "hs_office_coopsharestransaction_legacy_id", "member_share_id");
coopAssets.forEach((id, assetTransaction) -> em.persist(assetTransaction)); jpaAttempt.transacted(() -> {
updateLegacyIds(coopShares, "hs_office_coopassetstransaction_legacy_id", "member_asset_id"); context(rbacSuperuser);
bankAccounts.forEach((id, account) -> em.persist(account));
}).assertSuccessful();
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
sepaMandates.forEach((id, mandate) -> em.persist(mandate));
updateLegacyIds(sepaMandates, "hs_office_sepamandate_legacy_id", "sepa_mandate_id");
}).assertSuccessful();
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
coopShares.forEach((id, shareTransaction) -> em.persist(shareTransaction));
updateLegacyIds(coopShares, "hs_office_coopsharestransaction_legacy_id", "member_share_id");
}).assertSuccessful();
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
coopAssets.forEach((id, assetTransaction) -> em.persist(assetTransaction));
updateLegacyIds(coopShares, "hs_office_coopassetstransaction_legacy_id", "member_asset_id");
}).assertSuccessful();
em.flush();
} }
private <E extends HasUuid> void updateLegacyIds(Map<Integer, E> entities, final String legacyIdTable, final String legacyIdColumn) { private void deleteTestDataFromHsOfficeTables() {
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
em.createNativeQuery("DELETE FROM hs_office_relationship WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_coopassetstransaction WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_coopassetstransaction_legacy_id WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_coopsharestransaction WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_coopsharestransaction_legacy_id WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_membership WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_sepamandate WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_sepamandate_legacy_id WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_debitor WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_bankaccount WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_partner WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_partner_details WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_contact WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM hs_office_person WHERE true").executeUpdate();
}).assertSuccessful();
}
private void resetFromHsOfficeSequences() {
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
em.createNativeQuery("ALTER SEQUENCE hs_office_contact_legacy_id_seq RESTART WITH 1000000000;").executeUpdate();
em.createNativeQuery("ALTER SEQUENCE hs_office_coopassetstransaction_legacy_id_seq RESTART WITH 1000000000;").executeUpdate();
em.createNativeQuery("ALTER SEQUENCE public.hs_office_coopsharestransaction_legacy_id_seq RESTART WITH 1000000000;").executeUpdate();
em.createNativeQuery("ALTER SEQUENCE public.hs_office_partner_legacy_id_seq RESTART WITH 1000000000;").executeUpdate();
em.createNativeQuery("ALTER SEQUENCE public.hs_office_sepamandate_legacy_id_seq RESTART WITH 1000000000;").executeUpdate();
});
}
private void deleteFromTestTables() {
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
em.createNativeQuery("DELETE FROM test_domain WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM test_package WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM test_customer WHERE true").executeUpdate();
}).assertSuccessful();
}
private void deleteFromRbacTables() {
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
final var usersNotToDelete = em.createNativeQuery("SELECT name FROM rbacuser WHERE name like 'superuser-%'").getResultList();
final var usersToDelete = em.createNativeQuery("SELECT name FROM rbacuser WHERE name not like 'superuser-%'").getResultList();
System.getenv();
});
jpaAttempt.transacted(() -> {
context(rbacSuperuser);
// em.createNativeQuery("DELETE FROM rbacobject WHERE objecttable like 'hs_%'").executeUpdate();
// em.createNativeQuery("DELETE FROM rbacgrants WHERE true").executeUpdate();
// em.createNativeQuery("DELETE FROM rbacpermission WHERE true").executeUpdate();
// em.createNativeQuery("DELETE FROM rbacreference WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM rbacuser_rv WHERE name not like 'superuser-%'").executeUpdate();
em.createNativeQuery("DELETE FROM tx_journal WHERE true").executeUpdate();
em.createNativeQuery("DELETE FROM tx_context WHERE true").executeUpdate();
}).assertSuccessful();
}
private <E extends HasUuid> void updateLegacyIds(
Map<Integer, E> entities,
final String legacyIdTable,
final String legacyIdColumn) {
entities.forEach((id, entity) -> em.createNativeQuery(""" entities.forEach((id, entity) -> em.createNativeQuery("""
UPDATE ${legacyIdTable} UPDATE ${legacyIdTable}
SET ${legacyIdColumn} = :legacyId SET ${legacyIdColumn} = :legacyId
WHERE uuid = :uuid WHERE uuid = :uuid
""" """
.replace("${legacyIdTable}", legacyIdTable) .replace("${legacyIdTable}", legacyIdTable)
.replace("${legacyIdColumn}", legacyIdColumn)) .replace("${legacyIdColumn}", legacyIdColumn))
.setParameter("legacyId", id) .setParameter("legacyId", id)
@ -321,7 +422,7 @@ public class ImportOfficeTables extends ContextBasedTest {
final var debitor = HsOfficeDebitorEntity.builder() final var debitor = HsOfficeDebitorEntity.builder()
.partner(partner) .partner(partner)
.debitorNumberSuffix((byte)0) .debitorNumberSuffix((byte) 0)
.defaultPrefix(rec.getString("member_code").replace("hsh00-", "")) .defaultPrefix(rec.getString("member_code").replace("hsh00-", ""))
.partner(partner) .partner(partner)
.billingContact(partner.getContact()) .billingContact(partner.getContact())
@ -338,7 +439,9 @@ public class ImportOfficeTables extends ContextBasedTest {
final var membership = HsOfficeMembershipEntity.builder() final var membership = HsOfficeMembershipEntity.builder()
.partner(partner) .partner(partner)
.memberNumber(rec.getInteger("member_id")) .memberNumber(rec.getInteger("member_id"))
.validity(toPostgresDateRange(rec.getLocalDate("member_since"), rec.getLocalDate("member_until"))) .validity(toPostgresDateRange(
rec.getLocalDate("member_since"),
rec.getLocalDate("member_until")))
.membershipFeeBillable(rec.isEmpty("member_role")) .membershipFeeBillable(rec.isEmpty("member_role"))
.reasonForTermination( .reasonForTermination(
isBlank(rec.getString("member_until")) isBlank(rec.getString("member_until"))
@ -367,10 +470,10 @@ public class ImportOfficeTables extends ContextBasedTest {
.transactionType( .transactionType(
"SUBSCRIPTION".equals(rec.getString("action")) "SUBSCRIPTION".equals(rec.getString("action"))
? HsOfficeCoopSharesTransactionType.SUBSCRIPTION ? HsOfficeCoopSharesTransactionType.SUBSCRIPTION
: "UNSUBSCRIPTION".equals(rec.getString("action")) : "UNSUBSCRIPTION".equals(rec.getString("action"))
? HsOfficeCoopSharesTransactionType.CANCELLATION ? HsOfficeCoopSharesTransactionType.CANCELLATION
: HsOfficeCoopSharesTransactionType.ADJUSTMENT : HsOfficeCoopSharesTransactionType.ADJUSTMENT
) )
.shareCount(rec.getInteger("quantity")) .shareCount(rec.getInteger("quantity"))
.reference(rec.getString("comment")) .reference(rec.getString("comment"))
.build(); .build();
@ -390,6 +493,7 @@ public class ImportOfficeTables extends ContextBasedTest {
final var member = memberships.get(rec.getInteger("bp_id")); final var member = memberships.get(rec.getInteger("bp_id"));
final var assetTypeMapping = new HashMap<String, HsOfficeCoopAssetsTransactionType>() { final var assetTypeMapping = new HashMap<String, HsOfficeCoopAssetsTransactionType>() {
{ {
put("HANDOVER", HsOfficeCoopAssetsTransactionType.TRANSFER); put("HANDOVER", HsOfficeCoopAssetsTransactionType.TRANSFER);
put("ADOPTION", HsOfficeCoopAssetsTransactionType.ADOPTION); put("ADOPTION", HsOfficeCoopAssetsTransactionType.ADOPTION);
@ -402,7 +506,7 @@ public class ImportOfficeTables extends ContextBasedTest {
public HsOfficeCoopAssetsTransactionType get(final String key) { public HsOfficeCoopAssetsTransactionType get(final String key) {
final var value = super.get(key); final var value = super.get(key);
if ( value != null ) { if (value != null) {
return value; return value;
} }
throw new IllegalStateException("no mapping value found for: " + key); throw new IllegalStateException("no mapping value found for: " + key);
@ -481,7 +585,12 @@ public class ImportOfficeTables extends ContextBasedTest {
private void initContact(final HsOfficeContactEntity contact, final Record rec) { private void initContact(final HsOfficeContactEntity contact, final Record rec) {
contacts.put(rec.getInteger("contact_id"), contact); contacts.put(rec.getInteger("contact_id"), contact);
contact.setLabel(toLabel(rec.getString("salut"), rec.getString("title"), rec.getString("first_name"), rec.getString("last_name"), rec.getString("firma"))); contact.setLabel(toLabel(
rec.getString("salut"),
rec.getString("title"),
rec.getString("first_name"),
rec.getString("last_name"),
rec.getString("firma")));
contact.setEmailAddresses(rec.getString("email")); contact.setEmailAddresses(rec.getString("email"));
contact.setPostalAddress(toAddress(rec)); contact.setPostalAddress(toAddress(rec));
contact.setPhoneNumbers(toPhoneNumbers(rec)); contact.setPhoneNumbers(toPhoneNumbers(rec));
@ -495,6 +604,7 @@ public class ImportOfficeTables extends ContextBasedTest {
} }
return record; return record;
} }
private String toPhoneNumbers(final Record rec) { private String toPhoneNumbers(final Record rec) {
final var result = new StringBuilder("{\n"); final var result = new StringBuilder("{\n");
if (isNotBlank(rec.getString("phone_private"))) if (isNotBlank(rec.getString("phone_private")))
@ -510,7 +620,11 @@ public class ImportOfficeTables extends ContextBasedTest {
private String toAddress(final Record rec) { private String toAddress(final Record rec) {
final var result = new StringBuilder(); final var result = new StringBuilder();
final var name = toName(rec.getString("salut"), rec.getString("title"), rec.getString("first_name"), rec.getString("last_name")); final var name = toName(
rec.getString("salut"),
rec.getString("title"),
rec.getString("first_name"),
rec.getString("last_name"));
if (isNotBlank(name)) if (isNotBlank(name))
result.append(name + "\n"); result.append(name + "\n");
if (isNotBlank(rec.getString("firma"))) if (isNotBlank(rec.getString("firma")))
@ -561,7 +675,6 @@ public class ImportOfficeTables extends ContextBasedTest {
return toLabel(salut, title, firstname, lastname, null); return toLabel(salut, title, firstname, lastname, null);
} }
private Reader resourceReader(@NotNull final String resourcePath) { private Reader resourceReader(@NotNull final String resourcePath) {
return new InputStreamReader(getClass().getClassLoader().getResourceAsStream(resourcePath)); return new InputStreamReader(getClass().getClassLoader().getResourceAsStream(resourcePath));
} }
@ -593,7 +706,7 @@ class Columns {
int indexOf(final String columnName) { int indexOf(final String columnName) {
int index = columnNames.indexOf(columnName); int index = columnNames.indexOf(columnName);
if ( index < 0 ) { if (index < 0) {
throw new RuntimeException("column name '" + columnName + "' not found in: " + columnNames); throw new RuntimeException("column name '" + columnName + "' not found in: " + columnNames);
} }
return index; return index;

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: First GmbH)"); assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(1000111: 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: First GmbH)"); assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(1000111: 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

@ -2,4 +2,4 @@ contact_id; bp_id; salut; first_name; last_name; title; firma; co; street; zip
71; 7; Herr; Michael; Mellies; ; ; ; Kleine Freiheit 50; 26524; Hage; DE; ; +49 4931 123456; +49 1522 123456;; mih@example.org; billing,operation 71; 7; Herr; Michael; Mellies; ; ; ; Kleine Freiheit 50; 26524; Hage; DE; ; +49 4931 123456; +49 1522 123456;; mih@example.org; billing,operation
101; 10; Frau; Jenny; Meyer; Dr.; JM e.K.;; Waldweg 5; 11001; Berlin; DE; +49 30 7777777; +49 30 8888888; ; +49 30 9999999; jm@example.org; billing 101; 10; Frau; Jenny; Meyer; Dr.; JM e.K.;; Waldweg 5; 11001; Berlin; DE; +49 30 7777777; +49 30 8888888; ; +49 30 9999999; jm@example.org; billing
102; 10; Herr; Andrew; Meyer; ; JM e.K.;; Waldweg 5; 11001; Berlin; DE; +49 30 6666666; +49 30 5555555; ; +49 30 9999999; am@example.org; operation 102; 10; Herr; Andrew; Meyer; ; JM e.K.;; Waldweg 5; 11001; Berlin; DE; +49 30 6666666; +49 30 5555555; ; +49 30 9999999; am@example.org; operation
121; 12; ; Paule; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; billing,operation 121; 12; ; Petra; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; billing,operation

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
2 71 7 Herr Michael Mellies Kleine Freiheit 50 26524 Hage DE +49 4931 123456 +49 1522 123456 mih@example.org billing,operation
3 101 10 Frau Jenny Meyer Dr. JM e.K. Waldweg 5 11001 Berlin DE +49 30 7777777 +49 30 8888888 +49 30 9999999 jm@example.org billing
4 102 10 Herr Andrew Meyer JM e.K. Waldweg 5 11001 Berlin DE +49 30 6666666 +49 30 5555555 +49 30 9999999 am@example.org operation
5 121 12 Paule Petra Schmidt Test PS ps@example.com billing,operation