From 76ad26b747d244b44a24b3ac76cd16d9b6d31da3 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 11 Jan 2024 15:37:01 +0100 Subject: [PATCH] amend test data (Paule -> Petra) which was confusingly similar to basic test data (Paul) + cleanup --- .../changelog/203-hs-office-contact-rbac.sql | 5 +--- .../office/migration/ImportOfficeTables.java | 27 ++++++++++++------- src/test/resources/migration/contacts.csv | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/resources/db/changelog/203-hs-office-contact-rbac.sql b/src/main/resources/db/changelog/203-hs-office-contact-rbac.sql index 39cdbf5e..7ba7891b 100644 --- a/src/main/resources/db/changelog/203-hs-office-contact-rbac.sql +++ b/src/main/resources/db/changelog/203-hs-office-contact-rbac.sql @@ -26,9 +26,6 @@ create or replace function createRbacRolesForHsOfficeContact() returns trigger language plpgsql strict as $$ -declare - ownerRole uuid; - adminRole uuid; begin if TG_OP <> 'INSERT' then raise exception 'invalid usage of TRIGGER AFTER INSERT'; @@ -107,7 +104,7 @@ do language plpgsql $$ declare addCustomerPermissions uuid[]; globalObjectUuid uuid; - globalAdminRoleUuid uuid ; + globalAdminRoleUuid uuid; begin call defineContext('granting global new-contact permission to global admin role', null, null, null); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeTables.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeTables.java index 5c2ca134..6bf9ca94 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeTables.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeTables.java @@ -134,7 +134,7 @@ public class ImportOfficeTables extends ContextBasedTest { { 7=partner(Mellies, Michael: Herr Michael Mellies ), 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(""" @@ -142,14 +142,14 @@ public class ImportOfficeTables extends ContextBasedTest { 71=contact(label='Herr Michael Mellies ', emailAddresses='mih@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'), - 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(""" { 7=person(personType='UNKNOWN', tradeName='', familyName='Mellies', givenName='Michael'), 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(""" @@ -242,7 +242,6 @@ public class ImportOfficeTables extends ContextBasedTest { @Test @Order(10) @Commit - //@Rollback(false) void persistEntities() { context("superuser-alex@hostsharing.net"); // TODO: use real user for actual import @@ -390,6 +389,7 @@ public class ImportOfficeTables extends ContextBasedTest { final var member = memberships.get(rec.getInteger("bp_id")); final var assetTypeMapping = new HashMap() { + { put("HANDOVER", HsOfficeCoopAssetsTransactionType.TRANSFER); put("ADOPTION", HsOfficeCoopAssetsTransactionType.ADOPTION); @@ -402,7 +402,7 @@ public class ImportOfficeTables extends ContextBasedTest { public HsOfficeCoopAssetsTransactionType get(final String key) { final var value = super.get(key); - if ( value != null ) { + if (value != null) { return value; } throw new IllegalStateException("no mapping value found for: " + key); @@ -481,7 +481,12 @@ public class ImportOfficeTables extends ContextBasedTest { private void initContact(final HsOfficeContactEntity contact, final Record rec) { 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.setPostalAddress(toAddress(rec)); contact.setPhoneNumbers(toPhoneNumbers(rec)); @@ -495,6 +500,7 @@ public class ImportOfficeTables extends ContextBasedTest { } return record; } + private String toPhoneNumbers(final Record rec) { final var result = new StringBuilder("{\n"); if (isNotBlank(rec.getString("phone_private"))) @@ -510,7 +516,11 @@ public class ImportOfficeTables extends ContextBasedTest { private String toAddress(final Record rec) { 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)) result.append(name + "\n"); if (isNotBlank(rec.getString("firma"))) @@ -561,7 +571,6 @@ public class ImportOfficeTables extends ContextBasedTest { return toLabel(salut, title, firstname, lastname, null); } - private Reader resourceReader(@NotNull final String resourcePath) { return new InputStreamReader(getClass().getClassLoader().getResourceAsStream(resourcePath)); } @@ -593,7 +602,7 @@ class Columns { int indexOf(final String columnName) { int index = columnNames.indexOf(columnName); - if ( index < 0 ) { + if (index < 0) { throw new RuntimeException("column name '" + columnName + "' not found in: " + columnNames); } return index; diff --git a/src/test/resources/migration/contacts.csv b/src/test/resources/migration/contacts.csv index 341d22d4..edbd183f 100644 --- a/src/test/resources/migration/contacts.csv +++ b/src/test/resources/migration/contacts.csv @@ -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 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 -121; 12; ; Paule; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; billing,operation +121; 12; ; Petra; Schmidt; ; Test PS;; ; ; ; ; ; ; ; ; ps@example.com; billing,operation