amend test data (Paule -> Petra) which was confusingly similar to basic test data (Paul) + cleanup

This commit is contained in:
Michael Hoennig 2024-01-11 15:37:01 +01:00
parent 5162aa0606
commit 76ad26b747
3 changed files with 20 additions and 14 deletions

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

@ -134,7 +134,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("""
@ -142,14 +142,14 @@ 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("""
@ -242,7 +242,6 @@ 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 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 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 +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);
@ -481,7 +481,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 +500,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 +516,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 +571,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 +602,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

@ -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