amendmends according to code-review

This commit is contained in:
Michael Hoennig 2024-04-30 12:05:42 +02:00
parent fed712bf02
commit 7347b2a5fd
7 changed files with 50 additions and 37 deletions

View File

@ -56,4 +56,17 @@ components:
# forces generating a java.lang.Object containing a Map, instead of class HsOfficeContactEmailAddresses # forces generating a java.lang.Object containing a Map, instead of class HsOfficeContactEmailAddresses
anyOf: anyOf:
- type: object - type: object
additionalProperties: true properties:
phone_office:
type: string
nullable: true
phone_private:
type: string
nullable: true
phone_mobile:
type: string
nullable: true
fax:
type: string
nullable: true
additionalProperties: false

View File

@ -11,7 +11,7 @@ create table if not exists hs_office_contact
label varchar(128) not null, label varchar(128) not null,
postalAddress text, postalAddress text,
emailAddresses jsonb not null, emailAddresses jsonb not null,
phoneNumbers text phoneNumbers jsonb not null
); );
--// --//

View File

@ -32,7 +32,7 @@ begin
contLabel, contLabel,
postalAddr, postalAddr,
('{ "main": "' || emailAddr || '" }')::jsonb, ('{ "main": "' || emailAddr || '" }')::jsonb,
('{ "office": "+49 123 1234567" }')::jsonb ('{ "phone_office": "+49 123 1234567" }')::jsonb
); );
end; $$; end; $$;
--// --//

View File

@ -188,7 +188,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
"main": "contact-admin@firstcontact.example.com" "main": "contact-admin@firstcontact.example.com"
}, },
"phoneNumbers": { "phoneNumbers": {
"office": "+49 123 1234567" "phone_office": "+49 123 1234567"
} }
} }
""")); // @formatter:on """)); // @formatter:on
@ -216,7 +216,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
}, },
"postalAddress": "Patched Address", "postalAddress": "Patched Address",
"phoneNumbers": { "phoneNumbers": {
"office": "+01 100 123456" "phone_office": "+01 100 123456"
} }
} }
""") """)
@ -230,7 +230,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.body("label", is("Temp patched contact")) .body("label", is("Temp patched contact"))
.body("emailAddresses", is(Map.of("main", "patched@example.org"))) .body("emailAddresses", is(Map.of("main", "patched@example.org")))
.body("postalAddress", is("Patched Address")) .body("postalAddress", is("Patched Address"))
.body("phoneNumbers", is(Map.of("office", "+01 100 123456"))); .body("phoneNumbers", is(Map.of("phone_office", "+01 100 123456")));
// @formatter:on // @formatter:on
// finally, the contact is actually updated // finally, the contact is actually updated
@ -240,7 +240,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
assertThat(person.getLabel()).isEqualTo("Temp patched contact"); assertThat(person.getLabel()).isEqualTo("Temp patched contact");
assertThat(person.getEmailAddresses()).containsExactlyEntriesOf(Map.of("main", "patched@example.org")); assertThat(person.getEmailAddresses()).containsExactlyEntriesOf(Map.of("main", "patched@example.org"));
assertThat(person.getPostalAddress()).isEqualTo("Patched Address"); assertThat(person.getPostalAddress()).isEqualTo("Patched Address");
assertThat(person.getPhoneNumbers()).containsExactlyEntriesOf(Map.of("office", "+01 100 123456")); assertThat(person.getPhoneNumbers()).containsExactlyEntriesOf(Map.of("phone_office", "+01 100 123456"));
return true; return true;
}); });
} }
@ -261,7 +261,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
"main": "patched@example.org" "main": "patched@example.org"
}, },
"phoneNumbers": { "phoneNumbers": {
"office": "+01 100 123456" "phone_office": "+01 100 123456"
} }
} }
""") """)
@ -275,7 +275,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.body("label", is(givenContact.getLabel())) .body("label", is(givenContact.getLabel()))
.body("emailAddresses", is(Map.of("main", "patched@example.org"))) .body("emailAddresses", is(Map.of("main", "patched@example.org")))
.body("postalAddress", is(givenContact.getPostalAddress())) .body("postalAddress", is(givenContact.getPostalAddress()))
.body("phoneNumbers", is(Map.of("office", "+01 100 123456"))); .body("phoneNumbers", is(Map.of("phone_office", "+01 100 123456")));
// @formatter:on // @formatter:on
// finally, the contact is actually updated // finally, the contact is actually updated
@ -284,7 +284,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
assertThat(person.getLabel()).isEqualTo(givenContact.getLabel()); assertThat(person.getLabel()).isEqualTo(givenContact.getLabel());
assertThat(person.getEmailAddresses()).containsExactlyEntriesOf(Map.of("main", "patched@example.org")); assertThat(person.getEmailAddresses()).containsExactlyEntriesOf(Map.of("main", "patched@example.org"));
assertThat(person.getPostalAddress()).isEqualTo(givenContact.getPostalAddress()); assertThat(person.getPostalAddress()).isEqualTo(givenContact.getPostalAddress());
assertThat(person.getPhoneNumbers()).containsExactlyEntriesOf(Map.of("office", "+01 100 123456")); assertThat(person.getPhoneNumbers()).containsExactlyEntriesOf(Map.of("phone_office", "+01 100 123456"));
return true; return true;
}); });
} }
@ -357,7 +357,7 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu
.label("Temp from " + Context.getCallerMethodNameFromStackFrame(1) ) .label("Temp from " + Context.getCallerMethodNameFromStackFrame(1) )
.emailAddresses(Map.of("main", RandomStringUtils.randomAlphabetic(10) + "@example.org")) .emailAddresses(Map.of("main", RandomStringUtils.randomAlphabetic(10) + "@example.org"))
.postalAddress("Postal Address " + RandomStringUtils.randomAlphabetic(10)) .postalAddress("Postal Address " + RandomStringUtils.randomAlphabetic(10))
.phoneNumbers(Map.of("office", "+01 200 " + RandomStringUtils.randomNumeric(8))) .phoneNumbers(Map.of("phone_office", "+01 200 " + RandomStringUtils.randomNumeric(8)))
.build(); .build();
return contactRepo.save(newContact); return contactRepo.save(newContact);

View File

@ -31,13 +31,13 @@ class HsOfficeContactEntityPatcherUnitTest extends PatchUnitTestBase<
); );
private static final Map<String, String> PATCH_PHONE_NUMBERS = patchMap( private static final Map<String, String> PATCH_PHONE_NUMBERS = patchMap(
entry("mobile", null), entry("phone_mobile", null),
entry("private", "+49 40 987654321"), entry("phone_private", "+49 40 987654321"),
entry("fax", "+49 40 12345-99") entry("fax", "+49 40 12345-99")
); );
private static final Map<String, String> PATCHED_PHONE_NUMBERS = patchMap( private static final Map<String, String> PATCHED_PHONE_NUMBERS = patchMap(
entry("office", "+49 40 12345-00"), entry("phone_office", "+49 40 12345-00"),
entry("private", "+49 40 987654321"), entry("phone_private", "+49 40 987654321"),
entry("fax", "+49 40 12345-99") entry("fax", "+49 40 12345-99")
); );
@ -51,8 +51,8 @@ class HsOfficeContactEntityPatcherUnitTest extends PatchUnitTestBase<
entry("paul", "paul@example.com"), entry("paul", "paul@example.com"),
entry("mila", "mila@example.com"))); entry("mila", "mila@example.com")));
entity.putPhoneNumbers(Map.ofEntries( entity.putPhoneNumbers(Map.ofEntries(
entry("office", "+49 40 12345-00"), entry("phone_office", "+49 40 12345-00"),
entry("mobile", "+49 1555 1234567"), entry("phone_mobile", "+49 1555 1234567"),
entry("fax", "+49 40 12345-90"))); entry("fax", "+49 40 12345-90")));
entity.setPostalAddress("Initialstraße 50\n20000 Hamburg"); entity.setPostalAddress("Initialstraße 50\n20000 Hamburg");
return entity; return entity;

View File

@ -108,7 +108,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"contact": { "contact": {
"label": "first contact", "label": "first contact",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" }, "emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "office": "+49 123 1234567" } "phoneNumbers": { "phone_office": "+49 123 1234567" }
} }
}, },
"debitorNumber": 1000111, "debitorNumber": 1000111,
@ -133,7 +133,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"contact": { "contact": {
"label": "first contact", "label": "first contact",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" }, "emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "office": "+49 123 1234567" } "phoneNumbers": { "phone_office": "+49 123 1234567" }
} }
}, },
"details": { "details": {
@ -231,7 +231,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
void globalAdmin_withoutAssumedRoles_canFindDebitorDebitorByDebitorNumber() throws JSONException { void globalAdmin_withoutAssumedRoles_canFindDebitorDebitorByDebitorNumber() {
RestAssured // @formatter:off RestAssured // @formatter:off
.given() .given()
@ -466,7 +466,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"label": "first contact", "label": "first contact",
"postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt", "postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" }, "emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "office": "+49 123 1234567" } "phoneNumbers": { "phone_office": "+49 123 1234567" }
} }
}, },
"debitorNumber": 1000111, "debitorNumber": 1000111,
@ -482,7 +482,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
"label": "first contact", "label": "first contact",
"postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt", "postalAddress": "Vorname Nachname\\nStraße Hnr\\nPLZ Stadt",
"emailAddresses": { "main": "contact-admin@firstcontact.example.com" }, "emailAddresses": { "main": "contact-admin@firstcontact.example.com" },
"phoneNumbers": { "office": "+49 123 1234567" } "phoneNumbers": { "phone_office": "+49 123 1234567" }
} }
}, },
"details": { "details": {

View File

@ -390,16 +390,16 @@ public class ImportOfficeData extends ContextBasedTest {
assertThat(toFormattedString(coopAssets)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(coopAssets)).isEqualToIgnoringWhitespace("""
{ {
30000=CoopAssetsTransaction(M-1001700: 2000-12-06, DEPOSIT, 1280.00, legacy data import, for subscription A), 30000=CoopAssetsTransaction(M-1001700: 2000-12-06, DEPOSIT, 1280.00, 1001700, for subscription A),
31000=CoopAssetsTransaction(M-1002000: 2000-12-06, DEPOSIT, 128.00, legacy data import, for subscription B), 31000=CoopAssetsTransaction(M-1002000: 2000-12-06, DEPOSIT, 128.00, 1002000, for subscription B),
32000=CoopAssetsTransaction(M-1001700: 2005-01-10, DEPOSIT, 2560.00, legacy data import, for subscription C), 32000=CoopAssetsTransaction(M-1001700: 2005-01-10, DEPOSIT, 2560.00, 1001700, for subscription C),
33001=CoopAssetsTransaction(M-1001700: 2005-01-10, TRANSFER, -512.00, legacy data import, for transfer to 10), 33001=CoopAssetsTransaction(M-1001700: 2005-01-10, TRANSFER, -512.00, 1001700, for transfer to 10),
33002=CoopAssetsTransaction(M-1002000: 2005-01-10, ADOPTION, 512.00, legacy data import, for transfer from 7), 33002=CoopAssetsTransaction(M-1002000: 2005-01-10, ADOPTION, 512.00, 1002000, for transfer from 7),
34001=CoopAssetsTransaction(M-1002000: 2016-12-31, CLEARING, -8.00, legacy data import, for cancellation D), 34001=CoopAssetsTransaction(M-1002000: 2016-12-31, CLEARING, -8.00, 1002000, for cancellation D),
34002=CoopAssetsTransaction(M-1002000: 2016-12-31, DISBURSAL, -100.00, legacy data import, for cancellation D), 34002=CoopAssetsTransaction(M-1002000: 2016-12-31, DISBURSAL, -100.00, 1002000, for cancellation D),
34003=CoopAssetsTransaction(M-1002000: 2016-12-31, LOSS, -20.00, legacy data import, for cancellation D), 34003=CoopAssetsTransaction(M-1002000: 2016-12-31, LOSS, -20.00, 1002000, for cancellation D),
35001=CoopAssetsTransaction(M-1909000: 2024-01-15, DEPOSIT, 128.00, legacy data import, for subscription E), 35001=CoopAssetsTransaction(M-1909000: 2024-01-15, DEPOSIT, 128.00, 1909000, for subscription E),
35002=CoopAssetsTransaction(M-1909000: 2024-01-20, ADJUSTMENT, -128.00, legacy data import, chargeback for subscription E, M-1909000:DEP:+128.00) 35002=CoopAssetsTransaction(M-1909000: 2024-01-20, ADJUSTMENT, -128.00, 1909000, chargeback for subscription E, M-1909000:DEP:+128.00)
} }
"""); """);
} }
@ -867,7 +867,7 @@ public class ImportOfficeData extends ContextBasedTest {
.transactionType(assetTypeMapping.get(rec.getString("action"))) .transactionType(assetTypeMapping.get(rec.getString("action")))
.assetValue(rec.getBigDecimal("amount")) .assetValue(rec.getBigDecimal("amount"))
.comment(rec.getString("comment")) .comment(rec.getString("comment"))
.reference("legacy data import") // TODO.: Kundennummer .reference(member.getMemberNumber().toString())
.build(); .build();
if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.ADJUSTMENT) { if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.ADJUSTMENT) {
@ -1123,13 +1123,13 @@ public class ImportOfficeData extends ContextBasedTest {
private Map<String, String> toPhoneNumbers(final Record rec) { private Map<String, String> toPhoneNumbers(final Record rec) {
final var phoneNumbers = new LinkedHashMap<String, String>(); final var phoneNumbers = new LinkedHashMap<String, String>();
if (isNotBlank(rec.getString("phone_private"))) if (isNotBlank(rec.getString("phone_private")))
phoneNumbers.put("privat", rec.getString("phone_private")); phoneNumbers.put("phone_private", rec.getString("phone_private"));
if (isNotBlank(rec.getString("phone_office"))) if (isNotBlank(rec.getString("phone_office")))
phoneNumbers.put("geschäftlich", rec.getString("phone_office")); phoneNumbers.put("phone_office", rec.getString("phone_office"));
if (isNotBlank(rec.getString("phone_mobile"))) if (isNotBlank(rec.getString("phone_mobile")))
phoneNumbers.put("mobil", rec.getString("phone_mobile")); phoneNumbers.put("phone_mobile", rec.getString("phone_mobile"));
if (isNotBlank(rec.getString("fax"))) if (isNotBlank(rec.getString("fax")))
phoneNumbers.put("Fax", rec.getString("fax")); phoneNumbers.put("fax", rec.getString("fax"));
return phoneNumbers; return phoneNumbers;
} }