Compare commits

..

No commits in common. "70621fd482c770540392f38ea9ecc53549f6ad3b" and "90508df42d3bdae77d7bee22a88cc5f78d98326b" have entirely different histories.

8 changed files with 60 additions and 175 deletions

View File

@ -25,14 +25,11 @@ 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)
.withProp(HsOfficeDebitorEntity::getDefaultPrefix) // TODO: add defaultPrefix?
.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(128) not null, label varchar(96) 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,6 +26,9 @@ 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';
@ -104,7 +107,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,12 +22,11 @@ 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: som)"); assertThat(result).isEqualTo("debitor(1234567: some trade name)");
} }
@Test @Test

View File

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

View File

@ -56,15 +56,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* which reads CSV files from the file system. * which reads CSV files from the file system.
*/ */
@Disabled @DataJpaTest
@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<>();
@ -108,11 +104,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: mih), 7=debitor(1000700: null, null),
10=debitor(1001000: null, null: xyz), 10=debitor(1001000: null, null),
12=debitor(1101200: null, null: xxx)} 12=debitor(1101200: null, null)}
"""); """);
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),
@ -137,7 +133,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: Petra Schmidt , Test PS) 12=partner(Test PS: Paule Schmidt , Test PS)
} }
"""); """);
assertThat(contacts.toString()).isEqualToIgnoringWhitespace(""" assertThat(contacts.toString()).isEqualToIgnoringWhitespace("""
@ -145,21 +141,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='Petra Schmidt , Test PS', emailAddresses='ps@example.com') 121=contact(label='Paule 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='Petra') 12=person(personType='UNKNOWN', tradeName='Test PS', familyName='Schmidt', givenName='Paule')
} }
"""); """);
assertThat(debitors.toString()).isEqualToIgnoringWhitespace(""" assertThat(debitors.toString()).isEqualToIgnoringWhitespace("""
{ {
7=debitor(1000700: Mellies, Michael: mih), 7=debitor(1000700: Mellies, Michael),
10=debitor(1001000: JM e.K.: xyz), 10=debitor(1001000: JM e.K.),
12=debitor(1101200: Test PS: xxx) 12=debitor(1101200: Test PS)
} }
"""); """);
assertThat(memberships.toString()).isEqualToIgnoringWhitespace(""" assertThat(memberships.toString()).isEqualToIgnoringWhitespace("""
@ -245,138 +241,41 @@ public class ImportOfficeTables extends ContextBasedTest {
@Test @Test
@Order(10) @Order(10)
@Commit @Commit
//@Rollback(false)
void persistEntities() { void persistEntities() {
deleteTestDataFromHsOfficeTables(); context("superuser-alex@hostsharing.net"); // TODO: use real user for actual import
resetFromHsOfficeSequences();
deleteFromTestTables();
deleteFromRbacTables();
jpaAttempt.transacted(() -> { contacts.forEach((id, contact) -> em.persist(contact));
context(rbacSuperuser); updateLegacyIds(contacts, "hs_office_contact_legacy_id", "contact_id");
contacts.forEach((id, contact) -> em.persist(contact));
updateLegacyIds(contacts, "hs_office_contact_legacy_id", "contact_id");
}).assertSuccessful();
jpaAttempt.transacted(() -> { persons.forEach((id, person) -> em.persist(person));
context(rbacSuperuser);
persons.forEach((id, person) -> em.persist(person));
}).assertSuccessful();
jpaAttempt.transacted(() -> { partners.forEach((id, partner) -> em.persist(partner));
context(rbacSuperuser); updateLegacyIds(partners, "hs_office_partner_legacy_id", "bp_id");
partners.forEach((id, partner) -> em.persist(partner));
updateLegacyIds(partners, "hs_office_partner_legacy_id", "bp_id");
}).assertSuccessful();
jpaAttempt.transacted(() -> { debitors.forEach((id, debitor) -> em.persist(debitor));
context(rbacSuperuser); memberships.forEach((id, membership) -> em.persist(membership));
debitors.forEach((id, debitor) -> em.persist(debitor)); bankAccounts.forEach((id, account) -> em.persist(account));
}).assertSuccessful();
jpaAttempt.transacted(() -> { sepaMandates.forEach((id, mandate) -> em.persist(mandate));
context(rbacSuperuser); updateLegacyIds(sepaMandates, "hs_office_sepamandate_legacy_id", "sepa_mandate_id");
memberships.forEach((id, membership) -> em.persist(membership));
}).assertSuccessful(); coopShares.forEach((id, shareTransaction) -> em.persist(shareTransaction));
updateLegacyIds(coopShares, "hs_office_coopsharestransaction_legacy_id", "member_share_id");
jpaAttempt.transacted(() -> { coopAssets.forEach((id, assetTransaction) -> em.persist(assetTransaction));
context(rbacSuperuser); updateLegacyIds(coopShares, "hs_office_coopassetstransaction_legacy_id", "member_asset_id");
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 void deleteTestDataFromHsOfficeTables() { private <E extends HasUuid> void updateLegacyIds(Map<Integer, E> entities, final String legacyIdTable, final String legacyIdColumn) {
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)
@ -422,7 +321,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())
@ -439,9 +338,7 @@ 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( .validity(toPostgresDateRange(rec.getLocalDate("member_since"), rec.getLocalDate("member_until")))
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"))
@ -470,10 +367,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();
@ -493,7 +390,6 @@ 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);
@ -506,7 +402,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);
@ -585,12 +481,7 @@ 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( contact.setLabel(toLabel(rec.getString("salut"), rec.getString("title"), rec.getString("first_name"), rec.getString("last_name"), rec.getString("firma")));
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));
@ -604,7 +495,6 @@ 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")))
@ -620,11 +510,7 @@ 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( final var name = toName(rec.getString("salut"), rec.getString("title"), rec.getString("first_name"), rec.getString("last_name"));
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")))
@ -675,6 +561,7 @@ 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));
} }
@ -706,7 +593,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: fir)"); assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(1000111: First GmbH)");
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: fir)"); assertThat(mandate.getDebitor().toString()).isEqualTo("debitor(1000111: First GmbH)");
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; ; Petra; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; billing,operation 121; 12; ; Paule; 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 Petra Paule Schmidt Test PS ps@example.com billing,operation