From e38ccc9d83706d19c5585fad5aaee648fd429537 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 9 Nov 2024 14:17:13 +0100 Subject: [PATCH 01/38] use .uuid in API instead of a directly attached Uuid --- .../hs-booking/hs-booking-item-schemas.yaml | 6 ++--- .../hs-booking-project-schemas.yaml | 4 +-- .../hs-hosting/hs-hosting-asset-schemas.yaml | 18 ++++++------- .../hs-office-coopassets-schemas.yaml | 6 ++--- .../hs-office-coopshares-schemas.yaml | 6 ++--- .../hs-office/hs-office-debitor-schemas.yaml | 8 +++--- .../hs-office-membership-schemas.yaml | 4 +-- .../hs-office/hs-office-partner-schemas.yaml | 14 +++++----- .../hs-office/hs-office-relation-schemas.yaml | 26 +++++++++---------- .../hs-office-sepamandate-schemas.yaml | 8 +++--- .../rbac/rbac-grant-schemas.yaml | 10 +++---- .../rbac/rbac-role-schemas.yaml | 2 +- .../rbac/rbac-subject-schemas.yaml | 6 ++--- 13 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/main/resources/api-definition/hs-booking/hs-booking-item-schemas.yaml b/src/main/resources/api-definition/hs-booking/hs-booking-item-schemas.yaml index ef0ac307..97ed69f6 100644 --- a/src/main/resources/api-definition/hs-booking/hs-booking-item-schemas.yaml +++ b/src/main/resources/api-definition/hs-booking/hs-booking-item-schemas.yaml @@ -52,11 +52,11 @@ components: HsBookingItemInsert: type: object properties: - projectUuid: + project.uuid: type: string format: uuid nullable: false - parentItemUuid: + parentItem.uuid: type: string format: uuid nullable: false @@ -77,7 +77,7 @@ components: $ref: '../hs-hosting/hs-hosting-asset-schemas.yaml#/components/schemas/HsHostingAssetAutoInsert' required: - caption - - projectUuid + - project.uuid - validFrom - resources additionalProperties: false diff --git a/src/main/resources/api-definition/hs-booking/hs-booking-project-schemas.yaml b/src/main/resources/api-definition/hs-booking/hs-booking-project-schemas.yaml index de95203d..56626290 100644 --- a/src/main/resources/api-definition/hs-booking/hs-booking-project-schemas.yaml +++ b/src/main/resources/api-definition/hs-booking/hs-booking-project-schemas.yaml @@ -25,7 +25,7 @@ components: HsBookingProjectInsert: type: object properties: - debitorUuid: + debitor.uuid: type: string format: uuid nullable: false @@ -35,6 +35,6 @@ components: maxLength: 80 nullable: false required: - - debitorUuid + - debitor.uuid - caption additionalProperties: false diff --git a/src/main/resources/api-definition/hs-hosting/hs-hosting-asset-schemas.yaml b/src/main/resources/api-definition/hs-hosting/hs-hosting-asset-schemas.yaml index 44813162..39fafaeb 100644 --- a/src/main/resources/api-definition/hs-hosting/hs-hosting-asset-schemas.yaml +++ b/src/main/resources/api-definition/hs-hosting/hs-hosting-asset-schemas.yaml @@ -54,7 +54,7 @@ components: caption: type: string nullable: true - alarmContactUuid: + alarmContact.uuid: type: string format: uuid nullable: true @@ -64,11 +64,11 @@ components: HsHostingAssetInsert: type: object properties: - bookingItemUuid: + bookingItem.uuid: type: string format: uuid nullable: true - parentAssetUuid: + parentAsset.uuid: type: string format: uuid nullable: true @@ -84,7 +84,7 @@ components: minLength: 3 maxLength: 80 nullable: false - alarmContactUuid: + alarmContact.uuid: type: string format: uuid nullable: true @@ -99,11 +99,11 @@ components: HsHostingAssetAutoInsert: type: object properties: - parentAssetUuid: + parentAsset.uuid: type: string format: uuid nullable: true - assignedToAssetUuid: + assignedToAsset.uuid: type: string format: uuid type: @@ -118,7 +118,7 @@ components: minLength: 3 maxLength: 80 nullable: false - alarmContactUuid: + alarmContact.uuid: type: string format: uuid nullable: true @@ -147,10 +147,10 @@ components: minLength: 3 maxLength: 80 nullable: false - assignedToAssetUuid: + assignedToAsset.uuid: type: string format: uuid - alarmContactUuid: + alarmContact.uuid: type: string format: uuid nullable: true diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopassets-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopassets-schemas.yaml index 0c937767..16f4806b 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopassets-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopassets-schemas.yaml @@ -62,7 +62,7 @@ components: HsOfficeCoopAssetsTransactionInsert: type: object properties: - membershipUuid: + membership.uuid: type: string format: uuid nullable: false @@ -80,11 +80,11 @@ components: maxLength: 48 comment: type: string - reverseEntryUuid: + reverseEntry.uuid: type: string format: uuid required: - - membershipUuid + - membership.uuid - transactionType - assetValue - valueDate diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml index 680321be..50ea65a5 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml @@ -56,7 +56,7 @@ components: HsOfficeCoopSharesTransactionInsert: type: object properties: - membershipUuid: + membership.uuid: type: string format: uuid nullable: false @@ -73,11 +73,11 @@ components: maxLength: 48 comment: type: string - adjustedShareTxUuid: + adjustedShareTx.uuid: type: string format: uuid required: - - membershipUuid + - membership.uuid - transactionType - shareCount - valueDate diff --git a/src/main/resources/api-definition/hs-office/hs-office-debitor-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-debitor-schemas.yaml index ed4d8c26..bc3d402e 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-debitor-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-debitor-schemas.yaml @@ -41,7 +41,7 @@ components: HsOfficeDebitorPatch: type: object properties: - debitorRelUuid: + debitorRel.uuid: type: string format: uuid nullable: true @@ -61,7 +61,7 @@ components: vatReverseCharge: type: boolean nullable: false - refundBankAccountUuid: + refundBankAccount.uuid: type: string format: uuid nullable: true @@ -75,7 +75,7 @@ components: properties: debitorRel: $ref: 'hs-office-relation-schemas.yaml#/components/schemas/HsOfficeRelationSubInsert' - debitorRelUuid: + debitorRel.uuid: type: string format: uuid debitorNumberSuffix: @@ -92,7 +92,7 @@ components: type: boolean vatReverseCharge: type: boolean - refundBankAccountUuid: + refundBankAccount.uuid: type: string format: uuid defaultPrefix: diff --git a/src/main/resources/api-definition/hs-office/hs-office-membership-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-membership-schemas.yaml index 7132cff4..20459f4e 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-membership-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-membership-schemas.yaml @@ -62,7 +62,7 @@ components: HsOfficeMembershipInsert: type: object properties: - partnerUuid: + partner.uuid: type: string format: uuid nullable: false @@ -86,7 +86,7 @@ components: nullable: false type: boolean required: - - partnerUuid + - partner.uuid - memberNumberSuffix - validFrom - membershipFeeBillable diff --git a/src/main/resources/api-definition/hs-office/hs-office-partner-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-partner-schemas.yaml index 0e5952e1..bd327e10 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-partner-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-partner-schemas.yaml @@ -50,7 +50,7 @@ components: HsOfficePartnerPatch: type: object properties: - partnerRelUuid: + partnerRel.uuid: type: string format: uuid nullable: true @@ -103,19 +103,19 @@ components: type: object nullable: false properties: - anchorUuid: + anchor.uuid: type: string format: uuid - holderUuid: + holder.uuid: type: string format: uuid - contactUuid: + contact.uuid: type: string format: uuid required: - - anchorUuid - - holderUuid - - relContactUuid + - anchor.uuid + - holder.uuid + - relContact.uuid HsOfficePartnerDetailsInsert: type: object diff --git a/src/main/resources/api-definition/hs-office/hs-office-relation-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-relation-schemas.yaml index cbad776c..16ba6070 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-relation-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-relation-schemas.yaml @@ -36,7 +36,7 @@ components: HsOfficeRelationPatch: type: object properties: - contactUuid: + contact.uuid: type: string format: uuid nullable: true @@ -45,10 +45,10 @@ components: HsOfficeRelationInsert: type: object properties: - anchorUuid: + anchor.uuid: type: string format: uuid - holderUuid: + holder.uuid: type: string format: uuid type: @@ -57,32 +57,32 @@ components: mark: type: string nullable: true - contactUuid: + contact.uuid: type: string format: uuid required: - - anchorUuid - - holderUuid + - anchor.uuid + - holder.uuid - type - - contactUuid + - contact.uuid # relation created as a sub-element with implicitly known type HsOfficeRelationSubInsert: type: object properties: - anchorUuid: + anchor.uuid: type: string format: uuid - holderUuid: + holder.uuid: type: string format: uuid mark: type: string nullable: true - contactUuid: + contact.uuid: type: string format: uuid required: - - anchorUuid - - holderUuid - - contactUuid + - anchor.uuid + - holder.uuid + - contact.uuid diff --git a/src/main/resources/api-definition/hs-office/hs-office-sepamandate-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-sepamandate-schemas.yaml index 80668ba8..2afd4127 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-sepamandate-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-sepamandate-schemas.yaml @@ -48,11 +48,11 @@ components: HsOfficeSepaMandateInsert: type: object properties: - debitorUuid: + debitor.uuid: type: string format: uuid nullable: false - bankAccountUuid: + bankAccount.uuid: type: string format: uuid nullable: false @@ -72,8 +72,8 @@ components: format: date nullable: true required: - - debitorUuid - - bankAccountUuid + - debitor.uuid + - bankAccount.uuid - reference - agreement - validFrom diff --git a/src/main/resources/api-definition/rbac/rbac-grant-schemas.yaml b/src/main/resources/api-definition/rbac/rbac-grant-schemas.yaml index 90700354..c713ebc6 100644 --- a/src/main/resources/api-definition/rbac/rbac-grant-schemas.yaml +++ b/src/main/resources/api-definition/rbac/rbac-grant-schemas.yaml @@ -8,21 +8,21 @@ components: properties: grantedByRoleIdName: type: string - grantedByRoleUuid: + grantedByRole.uuid: type: string format: uuid assumed: type: boolean grantedRoleIdName: type: string - grantedRoleUuid: + grantedRole.uuid: type: string format: uuid granteeSubjectName: type: string - granteeSubjectUuid: + granteeSubject.uuid: type: string format: uuid required: - - grantedRoleUuid - - granteeSubjectUuid + - grantedRole.uuid + - granteeSubject.uuid diff --git a/src/main/resources/api-definition/rbac/rbac-role-schemas.yaml b/src/main/resources/api-definition/rbac/rbac-role-schemas.yaml index 4e5b5f4d..bf72a8e5 100644 --- a/src/main/resources/api-definition/rbac/rbac-role-schemas.yaml +++ b/src/main/resources/api-definition/rbac/rbac-role-schemas.yaml @@ -9,7 +9,7 @@ components: uuid: type: string format: uuid - objectUuid: + object.uuid: type: string format: uuid objectTable: diff --git a/src/main/resources/api-definition/rbac/rbac-subject-schemas.yaml b/src/main/resources/api-definition/rbac/rbac-subject-schemas.yaml index 9cb8ec0f..b907093a 100644 --- a/src/main/resources/api-definition/rbac/rbac-subject-schemas.yaml +++ b/src/main/resources/api-definition/rbac/rbac-subject-schemas.yaml @@ -14,7 +14,7 @@ components: RbacSubjectPermission: type: object properties: - objectUuid: + object.uuid: type: string format: uuid objectTable: @@ -23,10 +23,10 @@ components: type: string roleName: type: string - roleUuid: + role.uuid: type: string format: uuid - permissionUuid: + permission.uuid: type: string format: uuid op: -- 2.39.5 From 1f19bbbcac501d7004bc3304bb65b80f2b760046 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 9 Nov 2024 14:28:20 +0100 Subject: [PATCH 02/38] amend ScenarioTests according to .uuid --- .../hs/office/scenarios/contact/ReplaceContactData.java | 2 +- .../debitor/CreateExternalDebitorForPartner.java | 8 ++++---- .../scenarios/debitor/CreateSelfDebitorForPartner.java | 8 ++++---- .../scenarios/debitor/CreateSepaMandateForDebitor.java | 4 ++-- .../hs/office/scenarios/membership/CreateMembership.java | 2 +- .../scenarios/partner/AddOperationsContactToPartner.java | 6 +++--- .../scenarios/partner/AddRepresentativeToPartner.java | 6 +++--- .../hs/office/scenarios/partner/CreatePartner.java | 6 +++--- .../scenarios/subscription/SubscribeToMailinglist.java | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java index e60bbc8e..2638a4e5 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java @@ -47,7 +47,7 @@ public class ReplaceContactData extends UseCase { withTitle("Replace the Contact-Reference in the Partner-Relation", () -> httpPatch("/api/hs/office/relations/%{partnerRelationUuid}", usingJsonBody(""" { - "contactUuid": ${Contact: %{newContactCaption}} + "contact.uuid": ${Contact: %{newContactCaption}} } """)) .expecting(OK) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/CreateExternalDebitorForPartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/CreateExternalDebitorForPartner.java index 194d4513..cf525c30 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/CreateExternalDebitorForPartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/CreateExternalDebitorForPartner.java @@ -55,9 +55,9 @@ public class CreateExternalDebitorForPartner extends UseCase { protected HttpResponse run() { return httpPost("/api/hs/office/memberships", usingJsonBody(""" { - "partnerUuid": ${Partner: Test AG}, + "partner.uuid": ${Partner: Test AG}, "memberNumberSuffix": ${memberNumberSuffix}, "status": "ACTIVE", "validFrom": ${validFrom}, diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/AddOperationsContactToPartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/AddOperationsContactToPartner.java index 8cef6e10..f862c782 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/AddOperationsContactToPartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/AddOperationsContactToPartner.java @@ -57,9 +57,9 @@ public class AddOperationsContactToPartner extends UseCase { { "partnerNumber": ${partnerNumber}, "partnerRel": { - "anchorUuid": ${Person: Hostsharing eG}, - "holderUuid": ${Person: %{%{tradeName???}???%{givenName???} %{familyName???}}}, - "contactUuid": ${Contact: %{contactCaption}} + "anchor.uuid": ${Person: Hostsharing eG}, + "holder.uuid": ${Person: %{%{tradeName???}???%{givenName???} %{familyName???}}}, + "contact.uuid": ${Contact: %{contactCaption}} }, "details": { "registrationOffice": "Registergericht Hamburg", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/SubscribeToMailinglist.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/SubscribeToMailinglist.java index 3e4ae74b..7cca9ba4 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/SubscribeToMailinglist.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/SubscribeToMailinglist.java @@ -52,9 +52,9 @@ public class SubscribeToMailinglist extends UseCase { { "type": "SUBSCRIBER", "mark": ${mailingList}, - "anchorUuid": ${Person: %{partnerPersonTradeName}}, - "holderUuid": ${Person: %{subscriberGivenName} %{subscriberFamilyName}}, - "contactUuid": ${Contact: %{subscriberGivenName} %{subscriberFamilyName}} + "anchor.uuid": ${Person: %{partnerPersonTradeName}}, + "holder.uuid": ${Person: %{subscriberGivenName} %{subscriberFamilyName}}, + "contact.uuid": ${Contact: %{subscriberGivenName} %{subscriberFamilyName}} } """)) .expecting(CREATED).expecting(JSON); -- 2.39.5 From 3a910468b403863cc0ceeae8eceff22de3bf13ee Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 9 Nov 2024 14:55:31 +0100 Subject: [PATCH 03/38] amend AcceptanceTests according to .uuid --- ...HsBookingItemControllerAcceptanceTest.java | 14 ++++---- .../item/HsBookingItemControllerRestTest.java | 4 +-- ...ookingProjectControllerAcceptanceTest.java | 2 +- ...sHostingAssetControllerAcceptanceTest.java | 14 ++++---- ...omainSetupHostingAssetFactoryUnitTest.java | 8 ++--- ...tsTransactionControllerAcceptanceTest.java | 12 +++---- ...opAssetsTransactionControllerRestTest.java | 2 +- ...esTransactionControllerAcceptanceTest.java | 8 ++--- ...opSharesTransactionControllerRestTest.java | 4 +-- ...OfficeDebitorControllerAcceptanceTest.java | 18 +++++------ ...iceMembershipControllerAcceptanceTest.java | 2 +- .../HsOfficeMembershipControllerRestTest.java | 8 ++--- ...OfficePartnerControllerAcceptanceTest.java | 32 +++++++++---------- .../HsOfficePartnerControllerRestTest.java | 20 ++++++------ ...fficeRelationControllerAcceptanceTest.java | 28 ++++++++-------- ...ceSepaMandateControllerAcceptanceTest.java | 14 ++++---- 16 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index 6b4a4b29..3598c0ce 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -150,7 +150,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "projectUuid": "{projectUuid}", + "project.uuid": "{projectUuid}", "type": "MANAGED_SERVER", "caption": "some new booking", "validTo": "{validTo}", @@ -200,8 +200,8 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "projectUuid": "{projectUuid}", - "parentItemUuid": "{managedServerUuid}", + "project.uuid": "{projectUuid}", + "parentItem.uuid": "{managedServerUuid}", "type": "MANAGED_WEBSPACE", "caption": "some managed webspace", "resources": { @@ -270,7 +270,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "projectUuid": "{projectUuid}", + "project.uuid": "{projectUuid}", "type": "DOMAIN_SETUP", "caption": "Domain-Setup for example.org", "resources": { @@ -285,7 +285,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup }, { "type": "DOMAIN_HTTP_SETUP", - "assignedToAssetUuid": "{unixUserUuid}" + "assignedToAsset.uuid": "{unixUserUuid}" }, { "type": "DOMAIN_MBOX_SETUP" @@ -360,7 +360,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "projectUuid": "{projectUuid}", + "project.uuid": "{projectUuid}", "type": "DOMAIN_SETUP", "caption": "some new domain-setup booking", "resources": { @@ -375,7 +375,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup }, { "type": "DOMAIN_HTTP_SETUP", - "assignedToAssetUuid": "{unixUserUuid}" + "assignedToAsset.uuid": "{unixUserUuid}" }, { "type": "DOMAIN_MBOX_SETUP" diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java index 11ecf5bc..6b2bf5df 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java @@ -105,7 +105,7 @@ class HsBookingItemControllerRestTest { .contentType(MediaType.APPLICATION_JSON) .content(""" { - "projectUuid": "{projectUuid}", + "project.uuid": "{projectUuid}", "type": "MANAGED_SERVER", "caption": "some new booking", "validTo": "{validTo}", @@ -155,7 +155,7 @@ class HsBookingItemControllerRestTest { .contentType(MediaType.APPLICATION_JSON) .content(""" { - "projectUuid": "{projectUuid}", + "project.uuid": "{projectUuid}", "type": "MANAGED_SERVER", "caption": "some new booking", "validFrom": "{validFrom}", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java index 69c11d9f..2e281882 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java @@ -92,7 +92,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean .contentType(ContentType.JSON) .body(""" { - "debitorUuid": "%s", + "debitor.uuid": "%s", "caption": "some new project" } """.formatted(givenDebitor.getUuid())) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java index 30b62a5a..2eff25de 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java @@ -165,10 +165,10 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "bookingItemUuid": "%s", + "bookingItem.uuid": "%s", "type": "MANAGED_WEBSPACE", "identifier": "fir10", - "parentAssetUuid": "%s", + "parentAsset.uuid": "%s", "caption": "some separate ManagedWebspace HA", "config": {} } @@ -227,7 +227,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "parentAssetUuid": "%s", + "parentAsset.uuid": "%s", "type": "UNIX_USER", "identifier": "fir01-temp", "caption": "some new UnixUser in client's ManagedWebspace", @@ -280,7 +280,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "bookingItemUuid": "%s", + "bookingItem.uuid": "%s", "type": "DOMAIN_SETUP", "identifier": "example.com", "caption": "some unrelated domain-setup", @@ -326,7 +326,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "bookingItemUuid": "%s", + "bookingItem.uuid": "%s", "type": "MANAGED_SERVER", "identifier": "vm1400", "caption": "some new ManagedServer", @@ -381,7 +381,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "parentAssetUuid": "%s", + "parentAsset.uuid": "%s", "type": "UNIX_USER", "identifier": "fir01-extra", "caption": "some extra UnixUser", @@ -508,7 +508,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup .contentType(ContentType.JSON) .body(""" { - "alarmContactUuid": "%s", + "alarmContact.uuid": "%s", "config": { "monit_max_ssd_usage": 85, "monit_max_hdd_usage": null, diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/DomainSetupHostingAssetFactoryUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/DomainSetupHostingAssetFactoryUnitTest.java index 14762bd0..cf2fc350 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/DomainSetupHostingAssetFactoryUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/DomainSetupHostingAssetFactoryUnitTest.java @@ -83,7 +83,7 @@ class DomainSetupHostingAssetFactoryUnitTest { "subHostingAssets": [ { "type": "DOMAIN_HTTP_SETUP", - "assignedToAssetUuid": "{unixUserHostingAssetUuid}" + "assignedToAsset.uuid": "{unixUserHostingAssetUuid}" }, { "type": "DOMAIN_DNS_SETUP" @@ -124,7 +124,7 @@ class DomainSetupHostingAssetFactoryUnitTest { "subHostingAssets": [ { "type": "DOMAIN_HTTP_SETUP", - "assignedToAssetUuid": "{unixUserHostingAssetUuid}" + "assignedToAsset.uuid": "{unixUserHostingAssetUuid}" }, { "type": "DOMAIN_DNS_SETUP" @@ -164,7 +164,7 @@ class DomainSetupHostingAssetFactoryUnitTest { "subHostingAssets": [ { "type": "DOMAIN_HTTP_SETUP", - "assignedToAssetUuid": "{unixUserHostingAssetUuid}" + "assignedToAsset.uuid": "{unixUserHostingAssetUuid}" }, { "type": "DOMAIN_DNS_SETUP" @@ -206,7 +206,7 @@ class DomainSetupHostingAssetFactoryUnitTest { "subHostingAssets": [ { "type": "DOMAIN_HTTP_SETUP", - "assignedToAssetUuid": "{unixUserHostingAssetUuid}" + "assignedToAsset.uuid": "{unixUserHostingAssetUuid}" }, { "type": "DOMAIN_DNS_SETUP" diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java index e8766490..6ac97292 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java @@ -180,7 +180,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased .contentType(ContentType.JSON) .body(""" { - "membershipUuid": "%s", + "membership.uuid": "%s", "transactionType": "DEPOSIT", "assetValue": 1024.00, "valueDate": "2022-10-13", @@ -237,13 +237,13 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased .contentType(ContentType.JSON) .body(""" { - "membershipUuid": "%s", + "membership.uuid": "%s", "transactionType": "ADJUSTMENT", "assetValue": %s, "valueDate": "2022-10-30", "reference": "test ref adjustment", "comment": "some coop assets adjustment transaction", - "reverseEntryUuid": "%s" + "reverseEntry.uuid": "%s" } """.formatted( givenMembership.getUuid(), @@ -270,7 +270,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased "reference": "test ref" } } - """.formatted(givenTransaction.getUuid()))) + """)) .header("Location", startsWith("http://localhost")) .extract().header("Location"); // @formatter:on @@ -293,14 +293,14 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased .contentType(ContentType.JSON) .body(""" { - "membershipUuid": "%s", + "membership.uuid": "%s", "transactionType": "DISBURSAL", "assetValue": -10240.00, "valueDate": "2022-10-13", "reference": "temp ref X", "comment": "just some test coop assets transaction" } - """.formatted(givenMembership.getUuid())) + """.formatted(givenMembership.getUuid())) .port(port) .when() .post("http://localhost/api/hs/office/coopassetstransactions") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java index 03a1c71b..f00edff8 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java @@ -37,7 +37,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { static final String VALID_INSERT_REQUEST_BODY = """ { - "membershipUuid": "%s", + "membership.uuid": "%s", "transactionType": "DEPOSIT", "assetValue": 128.00, "valueDate": "2022-10-13", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java index 28a7723e..a1e8a675 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java @@ -168,7 +168,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased final var location = RestAssured // @formatter:off .given().header("current-subject", "superuser-alex@hostsharing.net").contentType(ContentType.JSON).body(""" { - "membershipUuid": "%s", + "membership.uuid": "%s", "transactionType": "SUBSCRIPTION", "shareCount": 8, "valueDate": "2022-10-13", @@ -214,13 +214,13 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased .contentType(ContentType.JSON) .body(""" { - "membershipUuid": "%s", + "membership.uuid": "%s", "transactionType": "ADJUSTMENT", "shareCount": %s, "valueDate": "2022-10-30", "reference": "test ref adjustment", "comment": "some coop shares adjustment transaction", - "adjustedShareTxUuid": "%s" + "adjustedShareTx.uuid": "%s" } """.formatted( givenMembership.getUuid(), @@ -267,7 +267,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased RestAssured // @formatter:off .given().header("current-subject", "superuser-alex@hostsharing.net").contentType(ContentType.JSON).body(""" { - "membershipUuid": "%s", + "membership.uuid": "%s", "transactionType": "CANCELLATION", "shareCount": -80, "valueDate": "2022-10-13", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java index 1e33fde9..7024c668 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java @@ -37,7 +37,7 @@ class HsOfficeCoopSharesTransactionControllerRestTest { static final String VALID_INSERT_REQUEST_BODY = """ { - "membershipUuid": "%s", + "membership.uuid": "%s", "transactionType": "SUBSCRIPTION", "shareCount": 8, "valueDate": "2022-10-13", @@ -48,7 +48,7 @@ class HsOfficeCoopSharesTransactionControllerRestTest { enum BadRequestTestCases { MEMBERSHIP_UUID_MISSING( - requestBody -> requestBody.without("membershipUuid"), + requestBody -> requestBody.without("membership.uuid"), "[membershipUuid must not be null but is \"null\"]"), TRANSACTION_TYPE_MISSING( diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java index a15ffbce..f6623fe0 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java @@ -287,14 +287,14 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body(""" { - "debitorRelUuid": "%s", + "debitorRel.uuid": "%s", "debitorNumberSuffix": "%s", "billable": "true", "vatId": "VAT123456", "vatCountryCode": "DE", "vatBusiness": true, "vatReverseCharge": "false", - "refundBankAccountUuid": "%s", + "refundBankAccount.uuid": "%s", "defaultPrefix": "for" } """.formatted( givenDebitorRelUUid, ++nextDebitorSuffix, givenBankAccount.getUuid())) @@ -333,9 +333,9 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu .body(""" { "debitorRel": { - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" }, "debitorNumberSuffix": "%s", "defaultPrefix": "for", @@ -384,9 +384,9 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu .body(""" { "debitorRel": { - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" }, "debitorNumberSuffix": "%s", "defaultPrefix": "for", @@ -418,7 +418,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body(""" { - "debitorRelUuid": "%s", + "debitorRel.uuid": "%s", "debitorNumberSuffix": "%s", "defaultPrefix": "for", "billable": "true", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java index 55f2fbd7..f3793da1 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java @@ -182,7 +182,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .contentType(ContentType.JSON) .body(""" { - "partnerUuid": "%s", + "partner.uuid": "%s", "memberNumberSuffix": "%s", "validFrom": "2022-10-13", "membershipFeeBillable": "true" diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java index 1fcc9f11..455008a2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java @@ -56,12 +56,12 @@ public class HsOfficeMembershipControllerRestTest { .contentType(MediaType.APPLICATION_JSON) .content(""" { - "partnerUuid": null, + "partner.uuid": null, "memberNumberSuffix": "01", "validFrom": "2022-10-13", "membershipFeeBillable": "true" } - """.formatted(UUID.randomUUID())) + """) .accept(MediaType.APPLICATION_JSON)) // then @@ -86,7 +86,7 @@ public class HsOfficeMembershipControllerRestTest { .contentType(MediaType.APPLICATION_JSON) .content(""" { - "partnerUuid": "%s", + "partner.uuid": "%s", "memberNumberSuffix": "01", "validFrom": "2022-10-13", "membershipFeeBillable": "true" @@ -112,7 +112,7 @@ public class HsOfficeMembershipControllerRestTest { .contentType(MediaType.APPLICATION_JSON) .content(""" { - "partnerUuid": "%s", + "partner.uuid": "%s", %s "validFrom": "2022-10-13", "membershipFeeBillable": "true" diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java index 8c75ed16..c2ec1271 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java @@ -102,9 +102,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu { "partnerNumber": "20002", "partnerRel": { - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" }, "details": { "registrationOffice": "Temp Registergericht Aurich", @@ -161,12 +161,12 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu { "partnerNumber": "20003", "partnerRel": { - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" }, - "personUuid": "%s", - "contactUuid": "%s", + "person.uuid": "%s", + "contact.uuid": "%s", "details": {} } """.formatted( @@ -199,12 +199,12 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu { "partnerNumber": "20004", "partnerRel": { - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" }, - "personUuid": "%s", - "contactUuid": "%s", + "person.uuid": "%s", + "contact.uuid": "%s", "details": {} } """.formatted( @@ -321,7 +321,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .body(""" { "partnerNumber": "20011", - "partnerRelUuid": "%s", + "partnerRel.uuid": "%s", "details": { "registrationOffice": "Temp Registergericht Aurich", "registrationNumber": "222222", @@ -330,7 +330,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu "dateOfDeath": "2022-01-12" } } - """.formatted(givenPartnerRel.getUuid())) + """.formatted(givenPartnerRel.getUuid())) .port(port) .when() .patch("http://localhost/api/hs/office/partners/" + givenPartner.getUuid()) @@ -387,7 +387,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body(""" { - "partnerRelUuid": "%s" + "partnerRel.uuid": "%s" } """.formatted(givenPartnerRel.getUuid())) .port(port) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java index 42d0566c..889e776f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java @@ -101,12 +101,12 @@ class HsOfficePartnerControllerRestTest { { "partnerNumber": "20002", "partnerRel": { - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" }, - "personUuid": "%s", - "contactUuid": "%s", + "person.uuid": "%s", + "contact.uuid": "%s", "details": { "registrationOffice": "Temp Registergericht Aurich", "registrationNumber": "111111" @@ -138,12 +138,12 @@ class HsOfficePartnerControllerRestTest { { "partnerNumber": "20002", "partnerRel": { - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" }, - "personUuid": "%s", - "contactUuid": "%s", + "person.uuid": "%s", + "contact.uuid": "%s", "details": { "registrationOffice": "Temp Registergericht Aurich", "registrationNumber": "111111" diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java index 2dac741b..9bc4eafa 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java @@ -235,9 +235,9 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean { "type": "%s", "mark": "%s", - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" } """.formatted( HsOfficeRelationTypeResource.SUBSCRIBER, @@ -281,9 +281,9 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .body(""" { "type": "%s", - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" } """.formatted( HsOfficeRelationTypeResource.DEBITOR, @@ -313,9 +313,9 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .body(""" { "type": "%s", - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" } """.formatted( HsOfficeRelationTypeResource.DEBITOR, @@ -346,9 +346,9 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .body(""" { "type": "%s", - "anchorUuid": "%s", - "holderUuid": "%s", - "contactUuid": "%s" + "anchor.uuid": "%s", + "holder.uuid": "%s", + "contact.uuid": "%s" } """.formatted( HsOfficeRelationTypeResource.DEBITOR, @@ -461,9 +461,9 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .contentType(ContentType.JSON) .body(""" { - "contactUuid": "%s" + "contact.uuid": "%s" } - """.formatted(givenContact.getUuid())) + """.formatted(givenContact.getUuid())) .port(port) .when() .patch("http://localhost/api/hs/office/relations/" + givenRelation.getUuid()) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java index 48ed0d9c..82a011dc 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java @@ -144,8 +144,8 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .contentType(ContentType.JSON) .body(""" { - "debitorUuid": "%s", - "bankAccountUuid": "%s", + "debitor.uuid": "%s", + "bankAccount.uuid": "%s", "reference": "temp ref CAT A", "agreement": "2020-01-02", "validFrom": "2022-10-13" @@ -186,7 +186,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .contentType(ContentType.JSON) .body(""" { - "bankAccountUuid": "%s", + "bankAccount.uuid": "%s", "reference": "temp ref CAT B", "validFrom": "2022-10-13" } @@ -211,8 +211,8 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .contentType(ContentType.JSON) .body(""" { - "debitorUuid": "%s", - "bankAccountUuid": "%s", + "debitor.uuid": "%s", + "bankAccount.uuid": "%s", "reference": "temp ref CAT C", "agreement": "2022-10-12", "validFrom": "2022-10-13", @@ -241,8 +241,8 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .contentType(ContentType.JSON) .body(""" { - "debitorUuid": "%s", - "bankAccountUuid": "%s", + "debitor.uuid": "%s", + "bankAccount.uuid": "%s", "reference": "temp refCAT D", "agreement": "2022-10-12", "validFrom": "2022-10-13", -- 2.39.5 From ca4397736108aa5b2cdae5d1fae3f026a6837a83 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 9 Nov 2024 17:03:50 +0100 Subject: [PATCH 04/38] amend RestTests according to .uuid --- .../HsOfficeCoopAssetsTransactionControllerRestTest.java | 2 +- .../rbac/grant/RbacGrantControllerAcceptanceTest.java | 8 ++++---- .../hsadminng/rbac/role/RbacRoleControllerRestTest.java | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java index f00edff8..7fa7e3f5 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java @@ -49,7 +49,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { enum BadRequestTestCases { MEMBERSHIP_UUID_MISSING( requestBody -> requestBody.without("membershipUuid"), - "[membershipUuid must not be null but is \"null\"]"), + "[membership.uuid must not be null but is \"null\"]"), TRANSACTION_TYPE_MISSING( requestBody -> requestBody.without("transactionType"), diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java index 5906f3e3..0dff3e75 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java @@ -388,8 +388,8 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { .body(""" { "assumed": true, - "grantedRoleUuid": "%s", - "granteeSubjectUuid": "%s" + "grantedRole.uuid": "%s", + "granteeSubject.uuid": "%s" } """.formatted( grantedRole.getUuid(), @@ -424,8 +424,8 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { .body(""" { "assumed": true, - "grantedRoleUuid": "%s", - "granteeSubjectUuid": "%s" + "grantedRole.uuid": "%s", + "granteeSubject.uuid": "%s" } """.formatted( grantedRole.getUuid(), diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleControllerRestTest.java index 0f1abce6..a9f09345 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleControllerRestTest.java @@ -76,8 +76,8 @@ class RbacRoleControllerRestTest { .andExpect(jsonPath("$[1].roleName", is("rbactest.customer#xxx:OWNER"))) .andExpect(jsonPath("$[2].roleName", is("rbactest.customer#xxx:ADMIN"))) .andExpect(jsonPath("$[2].uuid", is(customerXxxAdmin.getUuid().toString()))) - .andExpect(jsonPath("$[2].objectUuid", is(customerXxxAdmin.getObjectUuid().toString()))) - .andExpect(jsonPath("$[2].objectTable", is(customerXxxAdmin.getObjectTable().toString()))) - .andExpect(jsonPath("$[2].objectIdName", is(customerXxxAdmin.getObjectIdName().toString()))); + .andExpect(jsonPath("$[2].['object.uuid']", is(customerXxxAdmin.getObjectUuid().toString()))) + .andExpect(jsonPath("$[2].objectTable", is(customerXxxAdmin.getObjectTable()))) + .andExpect(jsonPath("$[2].objectIdName", is(customerXxxAdmin.getObjectIdName()))); } } -- 2.39.5 From 1d4d985a3e9ae4b928ed8815022f004294f1b47c Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 9 Nov 2024 18:34:27 +0100 Subject: [PATCH 05/38] amend RestTests according to .uuid --- .../HsOfficeCoopAssetsTransactionControllerRestTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java index 7fa7e3f5..b64e0cae 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java @@ -121,10 +121,10 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { .accept(MediaType.APPLICATION_JSON)) // then - .andExpect(status().is4xxClientError()) + .andExpect(jsonPath("message", is("ERROR: [400] " + testCase.expectedErrorMessage))) .andExpect(jsonPath("statusCode", is(400))) .andExpect(jsonPath("statusPhrase", is("Bad Request"))) - .andExpect(jsonPath("message", is("ERROR: [400] " + testCase.expectedErrorMessage))); + .andExpect(status().is4xxClientError()); } } -- 2.39.5 From 9531f6a881bac0b0e2f1f84862ba2d4633aa76e0 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 9 Nov 2024 20:54:59 +0100 Subject: [PATCH 06/38] amend RestTests according to .uuid - wrong error-message mapping in SpringValidation --- .../coopassets/HsOfficeCoopAssetsTransactionController.java | 1 - .../HsOfficeCoopAssetsTransactionControllerRestTest.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index 9154b8f0..b8da7580 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -77,7 +77,6 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) - public ResponseEntity getCoopAssetTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java index b64e0cae..b7f44b35 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java @@ -48,8 +48,8 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { enum BadRequestTestCases { MEMBERSHIP_UUID_MISSING( - requestBody -> requestBody.without("membershipUuid"), - "[membership.uuid must not be null but is \"null\"]"), + requestBody -> requestBody.without("membership.uuid"), + "[membershipUuid must not be null but is \"null\"]"), // TODO.impl: should be membership.uuid, Spring validation-problem? TRANSACTION_TYPE_MISSING( requestBody -> requestBody.without("transactionType"), -- 2.39.5 From e8b74ad1c0faf17aa6b74422e296da5391252f11 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 11 Nov 2024 07:48:39 +0100 Subject: [PATCH 07/38] add testCoopShares-scenario-tests - WIP --- .../hsadminng/errors/CustomErrorResponse.java | 1 + .../HsOfficeMembershipController.java | 5 +- .../scenarios/HsOfficeScenarioTests.java | 64 ++++++++++++++++--- .../hs/office/scenarios/PathAssertion.java | 21 +++++- .../hs/office/scenarios/UseCase.java | 5 +- .../CoopSharesTransactionUseCase.java | 51 +++++++++++++++ .../membership/CreateMembership.java | 4 +- 7 files changed, 136 insertions(+), 15 deletions(-) create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CoopSharesTransactionUseCase.java diff --git a/src/main/java/net/hostsharing/hsadminng/errors/CustomErrorResponse.java b/src/main/java/net/hostsharing/hsadminng/errors/CustomErrorResponse.java index 3df51ebb..2455ee76 100644 --- a/src/main/java/net/hostsharing/hsadminng/errors/CustomErrorResponse.java +++ b/src/main/java/net/hostsharing/hsadminng/errors/CustomErrorResponse.java @@ -46,6 +46,7 @@ public class CustomErrorResponse { this.path = path; this.statusCode = status.value(); this.statusPhrase = status.getReasonPhrase(); + // HOWTO: debug serverside error response - set a breakpoint here this.message = message.startsWith("ERROR: [") ? message : "ERROR: [" + statusCode + "] " + message; } } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java index 7a491961..12c373da 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java @@ -16,6 +16,8 @@ import java.util.List; import java.util.UUID; import java.util.function.BiConsumer; +import static java.util.Optional.ofNullable; + @RestController public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @@ -39,7 +41,8 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { context.define(currentSubject, assumedRoles); final var entities = ( memberNumber != null) - ? List.of(membershipRepo.findMembershipByMemberNumber(memberNumber)) + // FIXME: RestTest for the case that findMembershipByMemberNumber returns null + ? ofNullable(membershipRepo.findMembershipByMemberNumber(memberNumber)).stream().toList() : membershipRepo.findMembershipsByOptionalPartnerUuid(partnerUuid); final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class, diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index b08e9f3c..2ed73c37 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -12,6 +12,7 @@ import net.hostsharing.hsadminng.hs.office.scenarios.debitor.FinallyDeleteSepaMa import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DontDeleteDefaultDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.InvalidateSepaMandateForDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.membership.CancelMembership; +import net.hostsharing.hsadminng.hs.office.scenarios.membership.CoopSharesTransactionUseCase; import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateMembership; import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddOperationsContactToPartner; import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner; @@ -49,7 +50,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1010) - @Produces(explicitly = "Partner: Test AG", implicitly = {"Person: Test AG", "Contact: Test AG - Hamburg"}) + @Produces(explicitly = "Partner: P-31010 - Test AG", implicitly = {"Person: Test AG", "Contact: Test AG - Hamburg"}) void shouldCreateLegalPersonAsPartner() { new CreatePartner(this) .given("partnerNumber", 31010) @@ -71,7 +72,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1011) - @Produces(explicitly = "Partner: Michelle Matthieu", implicitly = {"Person: Michelle Matthieu", "Contact: Michelle Matthieu"}) + @Produces(explicitly = "Partner: P-31011 - Michelle Matthieu", implicitly = {"Person: Michelle Matthieu", "Contact: Michelle Matthieu"}) void shouldCreateNaturalPersonAsPartner() { new CreatePartner(this) .given("partnerNumber", 31011) @@ -148,7 +149,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1100) - @Requires("Partner: Michelle Matthieu") + @Requires("Partner: P-31011 - Michelle Matthieu") void shouldAmendContactData() { new AmendContactData(this) .given("partnerName", "Matthieu") @@ -158,7 +159,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1101) - @Requires("Partner: Michelle Matthieu") + @Requires("Partner: P-31011 - Michelle Matthieu") void shouldAddPhoneNumberToContactData() { new AddPhoneNumberToContactData(this) .given("partnerName", "Matthieu") @@ -169,7 +170,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1102) - @Requires("Partner: Michelle Matthieu") + @Requires("Partner: P-31011 - Michelle Matthieu") void shouldRemovePhoneNumberFromContactData() { new RemovePhoneNumberFromContactData(this) .given("partnerName", "Matthieu") @@ -179,7 +180,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1103) - @Requires("Partner: Test AG") + @Requires("Partner: P-31010 - Test AG") void shouldReplaceContactData() { new ReplaceContactData(this) .given("partnerName", "Test AG") @@ -201,7 +202,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1201) - @Requires("Partner: Michelle Matthieu") + @Requires("Partner: P-31011 - Michelle Matthieu") void shouldUpdatePersonData() { new ShouldUpdatePersonData(this) .given("oldFamilyName", "Matthieu") @@ -211,7 +212,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(2010) - @Requires("Partner: Test AG") + @Requires("Partner: P-31010 - Test AG") @Produces("Debitor: Test AG - main debitor") void shouldCreateSelfDebitorForPartner() { new CreateSelfDebitorForPartner(this, "Debitor: Test AG - main debitor") @@ -313,7 +314,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(4000) - @Requires("Partner: Test AG") + @Requires("Partner: P-31010 - Test AG") @Produces("Membership: Test AG 00") void shouldCreateMembershipForPartner() { new CreateMembership(this) @@ -326,6 +327,51 @@ class HsOfficeScenarioTests extends ScenarioTest { .keep(); } + @Test + @Order(4200) + @Requires("Membership: Test AG 00") + @Produces("Coop-Shares SUBSCRIPTION Transaction") + void testCoopSharesSubscriptionTransaction() { + new CoopSharesTransactionUseCase(this) + .given("memberNumber", "3101000") + .given("transactionType", "SUBSCRIPTION") + .given("reference", "sign 2024-01-15") + .given("shareCount", "100") + .given("comment", "Signing the Membership") + .given("transactionDate", "2024-01-15") + .doRun(); + } + + @Test + @Order(4201) + @Requires("Coop-Shares SUBSCRIPTION Transaction") + @Produces("Coop-Shares ADJUSTMENT Transaction") + void testCoopSharesAdjustmentTransaction() { + new CoopSharesTransactionUseCase(this) + .given("memberNumber", "3102000") + .given("transactionType", "ADJUSTMENT") + .given("reference", "adjust 2024-01-16") + .given("shareCount", "-90") + .given("comment", "Cancelling 90 Shares, correcting wrong number of digits in subscription") + .given("transactionDate", "2024-01-16") + .doRun(); + } + + @Test + @Order(4202) + @Requires("Coop-Shares SUBSCRIPTION Transaction") + @Produces("Coop-Shares CANCELLATION Transaction") + void testCoopSharesCancellationTransaction() { + new CoopSharesTransactionUseCase(this) + .given("memberNumber", "3102000") + .given("transactionType", "CANCELLATION") + .given("reference", "cancel 2024-01-15") + .given("shareCount", "8") + .given("comment", "Cancelling 8 Shares") + .given("transactionDate", "2024-02-15") + .doRun(); + } + @Test @Order(4900) @Requires("Membership: Test AG 00") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java index ffd9df8e..baf8d358 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java @@ -4,6 +4,8 @@ import net.hostsharing.hsadminng.hs.office.scenarios.UseCase.HttpResponse; import java.util.function.Consumer; +import static org.junit.jupiter.api.Assertions.fail; + public class PathAssertion { private final String path; @@ -14,10 +16,25 @@ public class PathAssertion { @SuppressWarnings({ "unchecked", "rawtypes" }) public Consumer contains(final String resolvableValue) { - return response -> response.path(path).contains(ScenarioTest.resolve(resolvableValue)); + return response -> { + try { + // FIXME: typed check instead of .map(Object::toString) possible? + response.path(path).map(Object::toString).contains(ScenarioTest.resolve(resolvableValue)); + } catch (final AssertionError e) { + // without this, the error message is often lacking important context + fail(e.getMessage() + " in `path(\"" + path + "\").contains(\"" + resolvableValue + "\")`" ); + } + }; } public Consumer doesNotExist() { - return response -> response.path(path).isNull(); // here, null Optional means key not found in JSON + return response -> { + try { + response.path(path).isNull(); // here, null Optional means key not found in JSON + } catch (final AssertionError e) { + // without this, the error message is often lacking important context + fail(e.getMessage() + " in `path(\"" + path + "\").doesNotExist()`" ); + } + }; } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java index f224fff2..ccd4200f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java @@ -302,16 +302,17 @@ public abstract class UseCase> { } @SneakyThrows - public Optional getFromBodyAsOptional(final String path) { + public Optional getFromBodyAsOptional(final String path) { try { return Optional.ofNullable(JsonPath.parse(response.body()).read(ScenarioTest.resolve(path))); } catch (final Exception e) { + // FIXME: catch more precise exception class return null; // means the property did not exist at all, not that it was there with value null } } @SneakyThrows - public OptionalAssert path(final String path) { + public OptionalAssert path(final String path) { return assertThat(getFromBodyAsOptional(path)); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CoopSharesTransactionUseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CoopSharesTransactionUseCase.java new file mode 100644 index 00000000..589469da --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CoopSharesTransactionUseCase.java @@ -0,0 +1,51 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.membership; + +import io.restassured.http.ContentType; +import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; +import org.springframework.http.HttpStatus; + +import static io.restassured.http.ContentType.JSON; +import static org.springframework.http.HttpStatus.OK; + +public class CoopSharesTransactionUseCase extends UseCase { + + public CoopSharesTransactionUseCase(final ScenarioTest testSuite) { + super(testSuite); + } + + @Override + protected HttpResponse run() { + + obtain("membershipUuid", () -> + httpGet("/api/hs/office/memberships?memberNumber=&{memberNumber}") + .expecting(OK).expecting(JSON).expectArrayElements(1), + response -> response.getFromBody("$[0].uuid") + ); + + return httpPost("/api/hs/office/coopsharestransactions", usingJsonBody(""" + { + "membership.uuid": ${membershipUuid}, + "transactionType": ${transactionType}, + "reference": ${reference}, + "shareCount": ${shareCount}, + "comment": ${comment}, + "valueDate": ${transactionDate} + } + """)) + .expecting(HttpStatus.CREATED).expecting(ContentType.JSON); + } + + @Override + protected void verify(final HttpResponse response) { + verify("Verify Coop-Shares %{transactionType}-Transaction", + () -> httpGet("/api/hs/office/coopsharestransactions/" + response.getLocationUuid()) + .expecting(HttpStatus.OK).expecting(ContentType.JSON), +// path("transactionType").contains("%{transactionType}"), +// path("memberNumber").contains("%{memberNumber}"), + path("shareCount").contains("%{shareCount}"), + path("comment").contains("%{comment}"), + path("valueDate").contains("%{transactionDate}") + ); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java index 379bba1e..f66a0202 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java @@ -16,9 +16,11 @@ public class CreateMembership extends UseCase { @Override protected HttpResponse run() { + // FIXME: httpGet "partner.uuid": ${Partner: Test AG} + return httpPost("/api/hs/office/memberships", usingJsonBody(""" { - "partner.uuid": ${Partner: Test AG}, + "partner.uuid": ${Partner: P-31010 - Test AG}, "memberNumberSuffix": ${memberNumberSuffix}, "status": "ACTIVE", "validFrom": ${validFrom}, -- 2.39.5 From 6177e32051b237289120603488c9108addb2f92d Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 11 Nov 2024 11:54:40 +0100 Subject: [PATCH 08/38] add M-memberNumber to identifier names --- .../hs/office/scenarios/HsOfficeScenarioTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index 2ed73c37..23ea8647 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -315,7 +315,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(4000) @Requires("Partner: P-31010 - Test AG") - @Produces("Membership: Test AG 00") + @Produces("Membership: M-3101000 - Test AG") void shouldCreateMembershipForPartner() { new CreateMembership(this) .given("partnerName", "Test AG") @@ -329,7 +329,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(4200) - @Requires("Membership: Test AG 00") + @Requires("Membership: M-3101000 - Test AG") @Produces("Coop-Shares SUBSCRIPTION Transaction") void testCoopSharesSubscriptionTransaction() { new CoopSharesTransactionUseCase(this) @@ -374,7 +374,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(4900) - @Requires("Membership: Test AG 00") + @Requires("Membership: M-3101000 - Test AG") void shouldCancelMembershipOfPartner() { new CancelMembership(this) .given("memberNumber", "3101000") -- 2.39.5 From cbf68f8657fa0647057a649dec4fd38a032510d5 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 12 Nov 2024 20:01:04 +0100 Subject: [PATCH 09/38] add coop-shares-tests --- ...OfficeCoopSharesTransactionController.java | 8 ++-- .../HsOfficeMembershipRepository.java | 16 +++++-- .../hs-office-coopassets-schemas.yaml | 8 ++-- .../hs-office-coopshares-schemas.yaml | 8 ++-- .../hs-office/hs-office-coopshares.yaml | 2 +- .../503-relation/5030-hs-office-relation.sql | 3 ++ .../scenarios/HsOfficeScenarioTests.java | 44 +++++++++---------- .../hs/office/scenarios/TestReport.java | 34 ++++++++++---- .../hs/office/scenarios/UseCase.java | 21 +++++---- ...eateCoopSharesCancellationTransaction.java | 17 +++++++ .../CreateCoopSharesRevertTransaction.java | 27 ++++++++++++ ...eateCoopSharesSubscriptionTransaction.java | 12 +++++ ....java => CreateCoopSharesTransaction.java} | 16 ++++--- 13 files changed, 153 insertions(+), 63 deletions(-) create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesCancellationTransaction.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesSubscriptionTransaction.java rename src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/{CoopSharesTransactionUseCase.java => CreateCoopSharesTransaction.java} (74%) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java index 6712fefd..ed84b7b6 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java @@ -57,7 +57,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional - public ResponseEntity addCoopSharesTransaction( + public ResponseEntity postCoopSharesTransaction( final String currentSubject, final String assumedRoles, final HsOfficeCoopSharesTransactionInsertResource requestBody) { @@ -131,9 +131,9 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar } final BiConsumer RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { - if ( resource.getAdjustedShareTxUuid() != null ) { - entity.setAdjustedShareTx(coopSharesTransactionRepo.findByUuid(resource.getAdjustedShareTxUuid()) - .orElseThrow(() -> new EntityNotFoundException("ERROR: [400] adjustedShareTxUuid %s not found".formatted(resource.getAdjustedShareTxUuid())))); + if ( resource.getRevertedShareTxUuid() != null ) { + entity.setAdjustedShareTx(coopSharesTransactionRepo.findByUuid(resource.getRevertedShareTxUuid()) + .orElseThrow(() -> new EntityNotFoundException("ERROR: [400] adjustedShareTxUuid %s not found".formatted(resource.getRevertedShareTxUuid())))); } }; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java index c61a863e..282bfaf6 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java @@ -14,14 +14,16 @@ public interface HsOfficeMembershipRepository extends Repository findAll(); @Query(""" SELECT membership FROM HsOfficeMembershipEntity membership WHERE ( CAST(:partnerUuid as org.hibernate.type.UUIDCharType) IS NULL OR membership.partner.uuid = :partnerUuid ) ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix - """) + """) List findMembershipsByOptionalPartnerUuid(UUID partnerUuid); + @Query(""" SELECT membership FROM HsOfficeMembershipEntity membership WHERE (:partnerNumber = membership.partner.partnerNumber) @@ -31,10 +33,18 @@ public interface HsOfficeMembershipRepository extends Repository aliases; - private final StringBuilder markdownLog = new StringBuilder(); // records everything for debugging purposes + private final static File markdownLogFile = new File("doc/scenarios/last-debug-log.md"); - private PrintWriter markdownReport; + private final Map aliases; + private final PrintWriter markdownLog; // records everything for debugging purposes + private File markdownReportFile; + private PrintWriter markdownReport; // records only the use-case under test, without its pre-requisites private int silent; // do not print anything to test-report if >0 + @SneakyThrows public TestReport(final Map aliases) { this.aliases = aliases; + this.markdownLog = new PrintWriter(new FileWriter(markdownLogFile)); } public void createTestLogMarkdownFile(final TestInfo testInfo) throws IOException { final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow(); final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow(); assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue(); - markdownReport = new PrintWriter(new FileWriter("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md")); - print("## Scenario #" + testInfo.getTestMethod().map(TestReport::orderNumber).orElseThrow() + ": " + - testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2")); + markdownReportFile = new File("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"); + markdownReport = new PrintWriter(new FileWriter(markdownReportFile)); + print("## Scenario #" + determineScenarioTitle(testInfo)); } @SneakyThrows @@ -45,7 +50,7 @@ public class TestReport { } // but the debugLog should contain all output, even if silent - markdownLog.append(outputWithCommentsForUuids); + markdownLog.print(outputWithCommentsForUuids); } public void printLine(final String output) { @@ -59,7 +64,21 @@ public class TestReport { public void close() { if (markdownReport != null) { markdownReport.close(); + System.out.println("SCENARIO REPORT: " + asClickableLink(markdownReportFile)); } + markdownLog.close(); + System.out.println("DEBUG LOG: " + asClickableLink(markdownLogFile)); + } + + private static @NotNull String determineScenarioTitle(final TestInfo testInfo) { + final var convertedTestMethodName = + testInfo.getTestMethod().map(TestReport::orderNumber).orElseThrow() + ": " + + testInfo.getTestMethod().map(Method::getName).map(t -> t.replaceAll("([a-z])([A-Z]+)", "$1 $2")).orElseThrow(); + return convertedTestMethodName.replaceAll(": should ", ": "); + } + + private String asClickableLink(final File file) { + return file.toURI().toString().replace("file:/", "file:///"); } private static Object orderNumber(final Method method) { @@ -88,5 +107,4 @@ public class TestReport { code.run(); silent--; } - } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java index ccd4200f..2111349c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java @@ -3,6 +3,7 @@ package net.hostsharing.hsadminng.hs.office.scenarios; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.PathNotFoundException; import io.restassured.http.ContentType; import lombok.Getter; import lombok.SneakyThrows; @@ -81,7 +82,7 @@ public abstract class UseCase> { testReport.silent(() -> requirements.forEach((alias, factory) -> { if (!ScenarioTest.containsAlias(alias)) { - factory.apply(alias).run().keep(); + factory.apply(alias).run().keepAs(alias); } }) ); @@ -126,7 +127,7 @@ public abstract class UseCase> { } public HttpResponse withTitle(final String title, final Supplier code) { - this.nextTitle = title; + this.nextTitle = ScenarioTest.resolve(title); final var response = code.get(); this.nextTitle = null; return response; @@ -276,15 +277,20 @@ public abstract class UseCase> { return this; } - public HttpResponse keep() { - final var alias = nextTitle != null ? nextTitle : resultAlias; - assertThat(alias).as("cannot keep result, no alias found").isNotNull(); + public HttpResponse keepAs(final String alias) { ScenarioTest.putAlias( - alias, + alias == null ? "unknown alias" : alias, // FIXME new ScenarioTest.Alias<>(UseCase.this.getClass(), locationUuid)); return this; } + public HttpResponse keep() { + final var alias = nextTitle != null ? nextTitle : resultAlias; + // FIXME assertThat(alias).as("cannot keep result, no title or alias found for locationUuid: " + locationUuid).isNotNull(); + + return keepAs(alias); + } + @SneakyThrows public HttpResponse expectArrayElements(final int expectedElementCount) { final var rootNode = objectMapper.readTree(response.body()); @@ -305,8 +311,7 @@ public abstract class UseCase> { public Optional getFromBodyAsOptional(final String path) { try { return Optional.ofNullable(JsonPath.parse(response.body()).read(ScenarioTest.resolve(path))); - } catch (final Exception e) { - // FIXME: catch more precise exception class + } catch (final PathNotFoundException e) { return null; // means the property did not exist at all, not that it was there with value null } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesCancellationTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesCancellationTransaction.java new file mode 100644 index 00000000..200ae07c --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesCancellationTransaction.java @@ -0,0 +1,17 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.membership; + +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; + +public class CreateCoopSharesCancellationTransaction extends CreateCoopSharesTransaction { + + public CreateCoopSharesCancellationTransaction(final ScenarioTest testSuite) { + super(testSuite); + } + + @Override + protected HttpResponse run() { + given("transactionType", "CANCELLATION"); + given("shareCount", "-%{sharesToCancel}"); + return super.run(); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java new file mode 100644 index 00000000..fc7fb6b9 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java @@ -0,0 +1,27 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.membership; + +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; + +public class CreateCoopSharesRevertTransaction extends CreateCoopSharesTransaction { + + public CreateCoopSharesRevertTransaction(final ScenarioTest testSuite) { + super(testSuite); + + requires("CoopShares-Transaction with incorrect shareCount", alias -> + new CreateCoopSharesSubscriptionTransaction(testSuite) + .given("memberNumber", "3101000") + .given("reference", "sign %{dateOfIncorrectTransaction}") // same as revertedShareTx + .given("shareCount", 100) + .given("comment", "reverting subscription transaction with wrong share count") + .given("transactionDate", "%{dateOfIncorrectTransaction}") + ); + } + + @Override + protected HttpResponse run() { + given("transactionType", "ADJUSTMENT"); + given("shareCount", -100); + given("revertedShareTx", uuid("CoopShares-Transaction with incorrect shareCount")); + return super.run(); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesSubscriptionTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesSubscriptionTransaction.java new file mode 100644 index 00000000..3aba4f29 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesSubscriptionTransaction.java @@ -0,0 +1,12 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.membership; + +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; + +public class CreateCoopSharesSubscriptionTransaction extends CreateCoopSharesTransaction { + + public CreateCoopSharesSubscriptionTransaction(final ScenarioTest testSuite) { + super(testSuite); + + given("transactionType", "SUBSCRIPTION"); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CoopSharesTransactionUseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java similarity index 74% rename from src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CoopSharesTransactionUseCase.java rename to src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java index 589469da..0ed75435 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CoopSharesTransactionUseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java @@ -8,9 +8,9 @@ import org.springframework.http.HttpStatus; import static io.restassured.http.ContentType.JSON; import static org.springframework.http.HttpStatus.OK; -public class CoopSharesTransactionUseCase extends UseCase { +public abstract class CreateCoopSharesTransaction extends UseCase { - public CoopSharesTransactionUseCase(final ScenarioTest testSuite) { + public CreateCoopSharesTransaction(final ScenarioTest testSuite) { super(testSuite); } @@ -23,17 +23,20 @@ public class CoopSharesTransactionUseCase extends UseCase response.getFromBody("$[0].uuid") ); - return httpPost("/api/hs/office/coopsharestransactions", usingJsonBody(""" + return withTitle("Create the CoopShares-%{transactionType} Transaction", () -> + httpPost("/api/hs/office/coopsharestransactions", usingJsonBody(""" { "membership.uuid": ${membershipUuid}, "transactionType": ${transactionType}, "reference": ${reference}, "shareCount": ${shareCount}, "comment": ${comment}, - "valueDate": ${transactionDate} + "valueDate": ${transactionDate}, + "revertedShareTx.uuid": ${revertedShareTx???} } """)) - .expecting(HttpStatus.CREATED).expecting(ContentType.JSON); + .expecting(HttpStatus.CREATED).expecting(ContentType.JSON) + ); } @Override @@ -41,8 +44,7 @@ public class CoopSharesTransactionUseCase extends UseCase httpGet("/api/hs/office/coopsharestransactions/" + response.getLocationUuid()) .expecting(HttpStatus.OK).expecting(ContentType.JSON), -// path("transactionType").contains("%{transactionType}"), -// path("memberNumber").contains("%{memberNumber}"), + path("transactionType").contains("%{transactionType}"), path("shareCount").contains("%{shareCount}"), path("comment").contains("%{comment}"), path("valueDate").contains("%{transactionDate}") -- 2.39.5 From 4736dc042753abf35b7ed6994aa1b953f3457a76 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 06:50:55 +0100 Subject: [PATCH 10/38] adjust naming in CoopShares regarding HTTP verbs and adjust vs. revert --- ...OfficeCoopSharesTransactionController.java | 10 +++---- .../HsOfficeCoopSharesTransactionEntity.java | 12 ++++---- .../hs-office-coopshares-schemas.yaml | 2 +- .../hs-office-coopshares-with-uuid.yaml | 2 +- .../hs-office/hs-office-coopshares.yaml | 4 +-- .../5110-hs-office-coopshares.sql | 6 ++-- .../5118-hs-office-coopshares-test-data.sql | 2 +- .../hs/migration/BaseOfficeDataImport.java | 4 +-- ...esTransactionControllerAcceptanceTest.java | 28 +++++++++---------- ...ceCoopSharesTransactionEntityUnitTest.java | 4 +-- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java index ed84b7b6..c8a9241e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java @@ -38,7 +38,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) - public ResponseEntity> listCoopShares( + public ResponseEntity> getListOfCoopShares( final String currentSubject, final String assumedRoles, final UUID membershipUuid, @@ -57,7 +57,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional - public ResponseEntity postCoopSharesTransaction( + public ResponseEntity postNewCoopSharesTransaction( final String currentSubject, final String assumedRoles, final HsOfficeCoopSharesTransactionInsertResource requestBody) { @@ -80,7 +80,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) - public ResponseEntity getCoopShareTransactionByUuid( + public ResponseEntity geSingletCoopShareTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) { context.define(currentSubject, assumedRoles); @@ -132,8 +132,8 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar final BiConsumer RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { if ( resource.getRevertedShareTxUuid() != null ) { - entity.setAdjustedShareTx(coopSharesTransactionRepo.findByUuid(resource.getRevertedShareTxUuid()) - .orElseThrow(() -> new EntityNotFoundException("ERROR: [400] adjustedShareTxUuid %s not found".formatted(resource.getRevertedShareTxUuid())))); + entity.setRevertedShareTx(coopSharesTransactionRepo.findByUuid(resource.getRevertedShareTxUuid()) + .orElseThrow(() -> new EntityNotFoundException("ERROR: [400] revertedShareTxUuid %s not found".formatted(resource.getRevertedShareTxUuid())))); } }; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java index 8af8b624..3be9373f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java @@ -48,8 +48,8 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE .withProp(HsOfficeCoopSharesTransactionEntity::getShareCount) .withProp(HsOfficeCoopSharesTransactionEntity::getReference) .withProp(HsOfficeCoopSharesTransactionEntity::getComment) - .withProp(at -> ofNullable(at.getAdjustedShareTx()).map(HsOfficeCoopSharesTransactionEntity::toShortString).orElse(null)) - .withProp(at -> ofNullable(at.getAdjustmentShareTx()).map(HsOfficeCoopSharesTransactionEntity::toShortString).orElse(null)) + .withProp(at -> ofNullable(at.getRevertedShareTx()).map(HsOfficeCoopSharesTransactionEntity::toShortString).orElse(null)) + .withProp(at -> ofNullable(at.getReversalShareTx()).map(HsOfficeCoopSharesTransactionEntity::toShortString).orElse(null)) .quotedValues(false); @Id @@ -96,11 +96,11 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE * Optionally, the UUID of the corresponding transaction for an adjustment transaction. */ @OneToOne - @JoinColumn(name = "adjustedsharetxuuid") - private HsOfficeCoopSharesTransactionEntity adjustedShareTx; + @JoinColumn(name = "revertedsharetxuuid") + private HsOfficeCoopSharesTransactionEntity revertedShareTx; - @OneToOne(mappedBy = "adjustedShareTx") - private HsOfficeCoopSharesTransactionEntity adjustmentShareTx; + @OneToOne(mappedBy = "revertedShareTx") + private HsOfficeCoopSharesTransactionEntity reversalShareTx; @Override public HsOfficeCoopSharesTransactionEntity load() { diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml index c9a10377..ce5b25cc 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml @@ -35,7 +35,7 @@ components: HsOfficeReferencedCoopSharesTransaction: description: Similar to `HsOfficeCoopSharesTransaction` but without the self-referencing properties - (`adjustedShareTx` and `adjustmentShareTx`), to avoid recursive JSON. + (`revertedShareTx` and `reversalShareTx`), to avoid recursive JSON. type: object properties: uuid: diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml index a37dbf7e..87d3da86 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-coopShares description: 'Fetch a single share transaction by its uuid, if visible for the current subject.' - operationId: getCoopShareTransactionByUuid + operationId: geSingletCoopShareTransactionByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopshares.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopshares.yaml index f2a03445..69dad5ad 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopshares.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopshares.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) cooperative share transactions which are visible to the current subject or any of it's assumed roles. tags: - hs-office-coopShares - operationId: listCoopShares + operationId: getListOfCoopShares parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -46,7 +46,7 @@ post: summary: Adds a new cooperative share transaction. tags: - hs-office-coopShares - operationId: postCoopSharesTransaction + operationId: postNewCoopSharesTransaction parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql index 213dd1cb..e8845f51 100644 --- a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql +++ b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql @@ -17,7 +17,7 @@ create table if not exists hs_office.coopsharetx valueDate date not null, shareCount integer not null, reference varchar(48) not null, - adjustedShareTxUuid uuid unique REFERENCES hs_office.coopsharetx(uuid) DEFERRABLE INITIALLY DEFERRED, + revertedShareTxUuid uuid unique REFERENCES hs_office.coopsharetx(uuid) DEFERRABLE INITIALLY DEFERRED, comment varchar(512) ); --// @@ -28,8 +28,8 @@ create table if not exists hs_office.coopsharetx alter table hs_office.coopsharetx add constraint reverse_entry_missing - check ( transactionType = 'ADJUSTMENT' and adjustedShareTxUuid is not null - or transactionType <> 'ADJUSTMENT' and adjustedShareTxUuid is null); + check ( transactionType = 'ADJUSTMENT' and revertedShareTxUuid is not null + or transactionType <> 'ADJUSTMENT' and revertedShareTxUuid is null); --// -- ============================================================================ diff --git a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql index 0f148a90..0050e244 100644 --- a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql @@ -27,7 +27,7 @@ begin raise notice 'creating test coopSharesTransaction: %', givenPartnerNumber::text || givenMemberNumberSuffix; subscriptionEntryUuid := uuid_generate_v4(); insert - into hs_office.coopsharetx(uuid, membershipuuid, transactiontype, valuedate, sharecount, reference, comment, adjustedShareTxUuid) + into hs_office.coopsharetx(uuid, membershipuuid, transactiontype, valuedate, sharecount, reference, comment, revertedShareTxUuid) values (uuid_generate_v4(), membership.uuid, 'SUBSCRIPTION', '2010-03-15', 4, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-1', 'initial subscription', null), (uuid_generate_v4(), membership.uuid, 'CANCELLATION', '2021-09-01', -2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-2', 'cancelling some', null), diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java index 70f21e11..ec4c7fec 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -804,14 +804,14 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { if (shareTransaction.getTransactionType() == HsOfficeCoopSharesTransactionType.ADJUSTMENT) { final var negativeValue = -shareTransaction.getShareCount(); - final var adjustedShareTx = coopShares.values().stream().filter(a -> + final var revertedShareTx = coopShares.values().stream().filter(a -> a.getTransactionType() != HsOfficeCoopSharesTransactionType.ADJUSTMENT && a.getMembership() == shareTransaction.getMembership() && a.getShareCount() == negativeValue) .findAny() .orElseThrow(() -> new IllegalStateException( "cannot determine share reverse entry for adjustment " + shareTransaction)); - shareTransaction.setAdjustedShareTx(adjustedShareTx); + shareTransaction.setRevertedShareTx(revertedShareTx); } coopShares.put(rec.getInteger("member_share_id"), shareTransaction); }); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java index a1e8a675..e07ac85b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java @@ -62,7 +62,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased } @Nested - class ListCoopSharesTransactions { + class getListOfCoopSharesTransactions { @Test void globalAdmin_canViewAllCoopSharesTransactions() { @@ -108,7 +108,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased "valueDate": "2022-10-20", "reference": "ref 1000202-3", "comment": "some subscription", - "adjustmentShareTx": { + "reversalShareTx": { "transactionType": "ADJUSTMENT", "shareCount": -2, "valueDate": "2022-10-21", @@ -122,7 +122,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased "valueDate": "2022-10-21", "reference": "ref 1000202-4", "comment": "some adjustment", - "adjustedShareTx": { + "revertedShareTx": { "transactionType": "SUBSCRIPTION", "shareCount": 2, "valueDate": "2022-10-20", @@ -213,16 +213,16 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased .header("current-subject", "superuser-alex@hostsharing.net") .contentType(ContentType.JSON) .body(""" - { - "membership.uuid": "%s", - "transactionType": "ADJUSTMENT", - "shareCount": %s, - "valueDate": "2022-10-30", - "reference": "test ref adjustment", - "comment": "some coop shares adjustment transaction", - "adjustedShareTx.uuid": "%s" - } - """.formatted( + { + "membership.uuid": "%s", + "transactionType": "ADJUSTMENT", + "shareCount": %s, + "valueDate": "2022-10-30", + "reference": "test ref adjustment", + "comment": "some coop shares adjustment transaction", + "revertedShareTx.uuid": "%s" + } + """.formatted( givenMembership.getUuid(), -givenTransaction.getShareCount(), givenTransaction.getUuid())) @@ -240,7 +240,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased "valueDate": "2022-10-30", "reference": "test ref adjustment", "comment": "some coop shares adjustment transaction", - "adjustedShareTx": { + "revertedShareTx": { "transactionType": "SUBSCRIPTION", "shareCount": 13, "valueDate": "2022-10-20", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java index 6d15cb78..8179f40e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java @@ -27,7 +27,7 @@ class HsOfficeCoopSharesTransactionEntityUnitTest { .transactionType(HsOfficeCoopSharesTransactionType.ADJUSTMENT) .shareCount(-4) .comment("some comment") - .adjustedShareTx(givenCoopSharesTransaction) + .revertedShareTx(givenCoopSharesTransaction) .build(); final HsOfficeCoopSharesTransactionEntity givenEmptyCoopSharesTransaction = HsOfficeCoopSharesTransactionEntity.builder().build(); @@ -41,7 +41,7 @@ class HsOfficeCoopSharesTransactionEntityUnitTest { @Test void toStringWithReverseEntryContainsReverseEntry() { - givenCoopSharesTransaction.setAdjustedShareTx(givenCoopShareAdjustmentTransaction); + givenCoopSharesTransaction.setRevertedShareTx(givenCoopShareAdjustmentTransaction); final var result = givenCoopSharesTransaction.toString(); -- 2.39.5 From 718fde26432f047133064f25195cdf037b1fc162 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 07:08:29 +0100 Subject: [PATCH 11/38] adjust naming in CoopShares regarding ADJUSTMENT->REVERSAL --- .../HsOfficeCoopSharesTransactionEntity.java | 4 ++-- .../HsOfficeCoopSharesTransactionType.java | 4 ++-- .../hs-office-coopshares-schemas.yaml | 2 +- .../5110-hs-office-coopshares.sql | 6 ++--- .../5118-hs-office-coopshares-test-data.sql | 2 +- .../hs/migration/BaseOfficeDataImport.java | 6 ++--- ...esTransactionControllerAcceptanceTest.java | 22 +++++++++---------- ...opSharesTransactionControllerRestTest.java | 2 +- ...ceCoopSharesTransactionEntityUnitTest.java | 8 +++---- ...sTransactionRepositoryIntegrationTest.java | 20 ++++++++--------- .../CreateCoopSharesRevertTransaction.java | 2 +- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java index 3be9373f..54787ad7 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntity.java @@ -71,7 +71,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE * The signed value which directly affects the booking balance. * *

This means, that a SUBSCRIPTION is always positive, a CANCELLATION is always negative, - * but an ADJUSTMENT can bei either positive or negative. + * but an REVERSAL can bei either positive or negative. * See {@link HsOfficeCoopSharesTransactionType} for

more information. */ @Column(name = "valuedate") @@ -93,7 +93,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, BaseE private String comment; /** - * Optionally, the UUID of the corresponding transaction for an adjustment transaction. + * Optionally, the UUID of the corresponding transaction for a REVERSAL transaction. */ @OneToOne @JoinColumn(name = "revertedsharetxuuid") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionType.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionType.java index bcd46cb3..0a9b3176 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionType.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionType.java @@ -2,9 +2,9 @@ package net.hostsharing.hsadminng.hs.office.coopshares; public enum HsOfficeCoopSharesTransactionType { /** - * correction of wrong bookings, with either positive or negative value + * reversal of wrong bookings, with either positive or negative value identical to reversed transaction */ - ADJUSTMENT, + REVERSAL, /** * shares signed, e.g. with the declaration of accession, value >0 diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml index ce5b25cc..8d190634 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopshares-schemas.yaml @@ -6,7 +6,7 @@ components: HsOfficeCoopSharesTransactionType: type: string enum: - - ADJUSTMENT # FIXME: rename to REVERSAL + - REVERSAL - SUBSCRIPTION - CANCELLATION diff --git a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql index e8845f51..2aa6fe72 100644 --- a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql +++ b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql @@ -4,7 +4,7 @@ --changeset michael.hoennig:hs-office-coopshares-MAIN-TABLE endDelimiter:--// -- ---------------------------------------------------------------------------- -CREATE TYPE hs_office.CoopSharesTransactionType AS ENUM ('ADJUSTMENT', 'SUBSCRIPTION', 'CANCELLATION'); +CREATE TYPE hs_office.CoopSharesTransactionType AS ENUM ('REVERSAL', 'SUBSCRIPTION', 'CANCELLATION'); CREATE CAST (character varying as hs_office.CoopSharesTransactionType) WITH INOUT AS IMPLICIT; @@ -28,8 +28,8 @@ create table if not exists hs_office.coopsharetx alter table hs_office.coopsharetx add constraint reverse_entry_missing - check ( transactionType = 'ADJUSTMENT' and revertedShareTxUuid is not null - or transactionType <> 'ADJUSTMENT' and revertedShareTxUuid is null); + check ( transactionType = 'REVERSAL' and revertedShareTxUuid is not null + or transactionType <> 'REVERSAL' and revertedShareTxUuid is null); --// -- ============================================================================ diff --git a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql index 0050e244..e7229595 100644 --- a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql @@ -32,7 +32,7 @@ begin (uuid_generate_v4(), membership.uuid, 'SUBSCRIPTION', '2010-03-15', 4, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-1', 'initial subscription', null), (uuid_generate_v4(), membership.uuid, 'CANCELLATION', '2021-09-01', -2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-2', 'cancelling some', null), (subscriptionEntryUuid, membership.uuid, 'SUBSCRIPTION', '2022-10-20', 2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-3', 'some subscription', null), - (uuid_generate_v4(), membership.uuid, 'ADJUSTMENT', '2022-10-21', -2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-4', 'some adjustment', subscriptionEntryUuid); + (uuid_generate_v4(), membership.uuid, 'REVERSAL', '2022-10-21', -2, 'ref '||givenPartnerNumber::text || givenMemberNumberSuffix||'-4', 'some reversal', subscriptionEntryUuid); end; $$; --// diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java index ec4c7fec..626e4613 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -795,17 +795,17 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { ? HsOfficeCoopSharesTransactionType.SUBSCRIPTION : "UNSUBSCRIPTION".equals(rec.getString("action")) ? HsOfficeCoopSharesTransactionType.CANCELLATION - : HsOfficeCoopSharesTransactionType.ADJUSTMENT + : HsOfficeCoopSharesTransactionType.REVERSAL ) .shareCount(rec.getInteger("quantity")) .comment(rec.getString("comment")) .reference(member.getMemberNumber().toString()) .build(); - if (shareTransaction.getTransactionType() == HsOfficeCoopSharesTransactionType.ADJUSTMENT) { + if (shareTransaction.getTransactionType() == HsOfficeCoopSharesTransactionType.REVERSAL) { final var negativeValue = -shareTransaction.getShareCount(); final var revertedShareTx = coopShares.values().stream().filter(a -> - a.getTransactionType() != HsOfficeCoopSharesTransactionType.ADJUSTMENT && + a.getTransactionType() != HsOfficeCoopSharesTransactionType.REVERSAL && a.getMembership() == shareTransaction.getMembership() && a.getShareCount() == negativeValue) .findAny() diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java index e07ac85b..c2e6a11f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java @@ -109,19 +109,19 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased "reference": "ref 1000202-3", "comment": "some subscription", "reversalShareTx": { - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "shareCount": -2, "valueDate": "2022-10-21", "reference": "ref 1000202-4", - "comment": "some adjustment" + "comment": "some reversal" } }, { - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "shareCount": -2, "valueDate": "2022-10-21", "reference": "ref 1000202-4", - "comment": "some adjustment", + "comment": "some reversal", "revertedShareTx": { "transactionType": "SUBSCRIPTION", "shareCount": 2, @@ -191,7 +191,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased } @Test - void globalAdmin_canAddCoopSharesAdjustmentTransaction() { + void globalAdmin_canAddCoopSharesReversalTransaction() { context.define("superuser-alex@hostsharing.net"); final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101); @@ -215,11 +215,11 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased .body(""" { "membership.uuid": "%s", - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "shareCount": %s, "valueDate": "2022-10-30", - "reference": "test ref adjustment", - "comment": "some coop shares adjustment transaction", + "reference": "test reversal ref", + "comment": "some coop shares reversal transaction", "revertedShareTx.uuid": "%s" } """.formatted( @@ -235,11 +235,11 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBased .body("uuid", isUuidValid()) .body("", lenientlyEquals(""" { - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "shareCount": -13, "valueDate": "2022-10-30", - "reference": "test ref adjustment", - "comment": "some coop shares adjustment transaction", + "reference": "test reversal ref", + "comment": "some coop shares reversal transaction", "revertedShareTx": { "transactionType": "SUBSCRIPTION", "shareCount": 13, diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java index 7024c668..821e8871 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerRestTest.java @@ -73,7 +73,7 @@ class HsOfficeCoopSharesTransactionControllerRestTest { SHARES_COUNT_MUST_NOT_BE_NULL( requestBody -> requestBody - .with("transactionType", "ADJUSTMENT") + .with("transactionType", "REVERSAL") .with("shareCount", 0), "[shareCount must not be 0 but is \"0\"]"), diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java index 8179f40e..3ec158f4 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java @@ -20,11 +20,11 @@ class HsOfficeCoopSharesTransactionEntityUnitTest { .build(); - final HsOfficeCoopSharesTransactionEntity givenCoopShareAdjustmentTransaction = HsOfficeCoopSharesTransactionEntity.builder() + final HsOfficeCoopSharesTransactionEntity givenCoopShareReversalTransaction = HsOfficeCoopSharesTransactionEntity.builder() .membership(TEST_MEMBERSHIP) .reference("some-ref") .valueDate(LocalDate.parse("2020-01-15")) - .transactionType(HsOfficeCoopSharesTransactionType.ADJUSTMENT) + .transactionType(HsOfficeCoopSharesTransactionType.REVERSAL) .shareCount(-4) .comment("some comment") .revertedShareTx(givenCoopSharesTransaction) @@ -41,11 +41,11 @@ class HsOfficeCoopSharesTransactionEntityUnitTest { @Test void toStringWithReverseEntryContainsReverseEntry() { - givenCoopSharesTransaction.setRevertedShareTx(givenCoopShareAdjustmentTransaction); + givenCoopSharesTransaction.setRevertedShareTx(givenCoopShareReversalTransaction); final var result = givenCoopSharesTransaction.toString(); - assertThat(result).isEqualTo("CoopShareTransaction(M-1000101: 2020-01-01, SUBSCRIPTION, 4, some-ref, some comment, M-1000101:ADJ:-4)"); + assertThat(result).isEqualTo("CoopShareTransaction(M-1000101: 2020-01-01, SUBSCRIPTION, 4, some-ref, some comment, M-1000101:REV:-4)"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java index ac74bee6..613ccc2b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java @@ -141,18 +141,18 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase result, "CoopShareTransaction(M-1000101: 2010-03-15, SUBSCRIPTION, 4, ref 1000101-1, initial subscription)", "CoopShareTransaction(M-1000101: 2021-09-01, CANCELLATION, -2, ref 1000101-2, cancelling some)", - "CoopShareTransaction(M-1000101: 2022-10-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:ADJ:-2)", - "CoopShareTransaction(M-1000101: 2022-10-21, ADJUSTMENT, -2, ref 1000101-4, some adjustment, M-1000101:SUB:+2)", + "CoopShareTransaction(M-1000101: 2022-10-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:REV:-2)", + "CoopShareTransaction(M-1000101: 2022-10-21, REVERSAL, -2, ref 1000101-4, some reversal, M-1000101:SUB:+2)", "CoopShareTransaction(M-1000202: 2010-03-15, SUBSCRIPTION, 4, ref 1000202-1, initial subscription)", "CoopShareTransaction(M-1000202: 2021-09-01, CANCELLATION, -2, ref 1000202-2, cancelling some)", - "CoopShareTransaction(M-1000202: 2022-10-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:ADJ:-2)", - "CoopShareTransaction(M-1000202: 2022-10-21, ADJUSTMENT, -2, ref 1000202-4, some adjustment, M-1000202:SUB:+2)", + "CoopShareTransaction(M-1000202: 2022-10-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:REV:-2)", + "CoopShareTransaction(M-1000202: 2022-10-21, REVERSAL, -2, ref 1000202-4, some reversal, M-1000202:SUB:+2)", "CoopShareTransaction(M-1000303: 2010-03-15, SUBSCRIPTION, 4, ref 1000303-1, initial subscription)", "CoopShareTransaction(M-1000303: 2021-09-01, CANCELLATION, -2, ref 1000303-2, cancelling some)", - "CoopShareTransaction(M-1000303: 2022-10-20, SUBSCRIPTION, 2, ref 1000303-3, some subscription, M-1000303:ADJ:-2)", - "CoopShareTransaction(M-1000303: 2022-10-21, ADJUSTMENT, -2, ref 1000303-4, some adjustment, M-1000303:SUB:+2)"); + "CoopShareTransaction(M-1000303: 2022-10-20, SUBSCRIPTION, 2, ref 1000303-3, some subscription, M-1000303:REV:-2)", + "CoopShareTransaction(M-1000303: 2022-10-21, REVERSAL, -2, ref 1000303-4, some reversal, M-1000303:SUB:+2)"); } @Test @@ -172,8 +172,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase result, "CoopShareTransaction(M-1000202: 2010-03-15, SUBSCRIPTION, 4, ref 1000202-1, initial subscription)", "CoopShareTransaction(M-1000202: 2021-09-01, CANCELLATION, -2, ref 1000202-2, cancelling some)", - "CoopShareTransaction(M-1000202: 2022-10-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:ADJ:-2)", - "CoopShareTransaction(M-1000202: 2022-10-21, ADJUSTMENT, -2, ref 1000202-4, some adjustment, M-1000202:SUB:+2)"); + "CoopShareTransaction(M-1000202: 2022-10-20, SUBSCRIPTION, 2, ref 1000202-3, some subscription, M-1000202:REV:-2)", + "CoopShareTransaction(M-1000202: 2022-10-21, REVERSAL, -2, ref 1000202-4, some reversal, M-1000202:SUB:+2)"); } @Test @@ -210,8 +210,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase result, "CoopShareTransaction(M-1000101: 2010-03-15, SUBSCRIPTION, 4, ref 1000101-1, initial subscription)", "CoopShareTransaction(M-1000101: 2021-09-01, CANCELLATION, -2, ref 1000101-2, cancelling some)", - "CoopShareTransaction(M-1000101: 2022-10-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:ADJ:-2)", - "CoopShareTransaction(M-1000101: 2022-10-21, ADJUSTMENT, -2, ref 1000101-4, some adjustment, M-1000101:SUB:+2)"); + "CoopShareTransaction(M-1000101: 2022-10-20, SUBSCRIPTION, 2, ref 1000101-3, some subscription, M-1000101:REV:-2)", + "CoopShareTransaction(M-1000101: 2022-10-21, REVERSAL, -2, ref 1000101-4, some reversal, M-1000101:SUB:+2)"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java index fc7fb6b9..06ef4101 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java @@ -19,7 +19,7 @@ public class CreateCoopSharesRevertTransaction extends CreateCoopSharesTransacti @Override protected HttpResponse run() { - given("transactionType", "ADJUSTMENT"); + given("transactionType", "REVERSAL"); given("shareCount", -100); given("revertedShareTx", uuid("CoopShares-Transaction with incorrect shareCount")); return super.run(); -- 2.39.5 From faf654e499774f5c98f1fbba738cb76ea2d40f79 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 08:09:15 +0100 Subject: [PATCH 12/38] adjust naming in CoopAssets regarding adjustment->reversal --- ...OfficeCoopAssetsTransactionController.java | 2 +- .../HsOfficeCoopAssetsTransactionEntity.java | 16 +++++------ .../HsOfficeCoopAssetsTransactionType.java | 2 +- .../HsOfficeMembershipRepository.java | 6 ---- .../hs-office-coopassets-schemas.yaml | 8 +++--- .../5120-hs-office-coopassets.sql | 8 +++--- .../5128-hs-office-coopassets-test-data.sql | 4 +-- .../hs/migration/BaseOfficeDataImport.java | 16 +++++------ ...tsTransactionControllerAcceptanceTest.java | 28 +++++++++---------- ...opAssetsTransactionControllerRestTest.java | 2 +- ...ceCoopAssetsTransactionEntityUnitTest.java | 10 +++---- ...sTransactionRepositoryIntegrationTest.java | 20 ++++++------- .../hs/office/scenarios/UseCase.java | 9 +++++- .../migration/office/asset_transactions.csv | 2 +- 14 files changed, 67 insertions(+), 66 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index b8da7580..8095c96e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -129,7 +129,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse final BiConsumer RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { if ( resource.getReverseEntryUuid() != null ) { - entity.setAdjustedAssetTx(coopAssetsTransactionRepo.findByUuid(resource.getReverseEntryUuid()) + entity.setRevertedAssetTx(coopAssetsTransactionRepo.findByUuid(resource.getReverseEntryUuid()) .orElseThrow(() -> new EntityNotFoundException("ERROR: [400] reverseEntityUuid %s not found".formatted(resource.getReverseEntryUuid())))); } }; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntity.java index 20ef39b4..18e12a11 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntity.java @@ -50,8 +50,8 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, BaseE .withProp(HsOfficeCoopAssetsTransactionEntity::getAssetValue) .withProp(HsOfficeCoopAssetsTransactionEntity::getReference) .withProp(HsOfficeCoopAssetsTransactionEntity::getComment) - .withProp(at -> ofNullable(at.getAdjustedAssetTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null)) - .withProp(at -> ofNullable(at.getAdjustmentAssetTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null)) + .withProp(at -> ofNullable(at.getRevertedAssetTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null)) + .withProp(at -> ofNullable(at.getReversalAssetTx()).map(HsOfficeCoopAssetsTransactionEntity::toShortString).orElse(null)) .quotedValues(false); @Id @@ -77,7 +77,7 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, BaseE * The signed value which directly affects the booking balance. * *

This means, that a DEPOSIT is always positive, a DISBURSAL is always negative, - * but an ADJUSTMENT can bei either positive or negative. + * but an REVERSAL can bei either positive or negative. * See {@link HsOfficeCoopAssetsTransactionType} for

more information. */ @Column(name = "assetvalue") @@ -96,14 +96,14 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, BaseE private String comment; /** - * Optionally, the UUID of the corresponding transaction for an adjustment transaction. + * Optionally, the UUID of the corresponding transaction for an reversal transaction. */ @OneToOne - @JoinColumn(name = "adjustedassettxuuid") - private HsOfficeCoopAssetsTransactionEntity adjustedAssetTx; + @JoinColumn(name = "revertedassettxuuid") + private HsOfficeCoopAssetsTransactionEntity revertedAssetTx; - @OneToOne(mappedBy = "adjustedAssetTx") - private HsOfficeCoopAssetsTransactionEntity adjustmentAssetTx; + @OneToOne(mappedBy = "revertedAssetTx") + private HsOfficeCoopAssetsTransactionEntity reversalAssetTx; @Override public HsOfficeCoopAssetsTransactionEntity load() { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionType.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionType.java index d7397622..ee53bec4 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionType.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionType.java @@ -4,7 +4,7 @@ public enum HsOfficeCoopAssetsTransactionType { /** * correction of wrong bookings, value can be positive or negative */ - ADJUSTMENT, + REVERSAL, /** * payment received from member after signing shares, value >0 diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java index 282bfaf6..d7f36d07 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java @@ -38,12 +38,6 @@ public interface HsOfficeMembershipRepository extends Repository 'ADJUSTMENT' and adjustedAssetTxUuid is null); + check ( transactionType = 'REVERSAL' and revertedAssetTxUuid is not null + or transactionType <> 'REVERSAL' and revertedAssetTxUuid is null); --// -- ============================================================================ diff --git a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql index ed824b12..ac43a731 100644 --- a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql @@ -27,12 +27,12 @@ begin raise notice 'creating test coopAssetsTransaction: %', givenPartnerNumber || givenMemberNumberSuffix; lossEntryUuid := uuid_generate_v4(); insert - into hs_office.coopassettx(uuid, membershipuuid, transactiontype, valuedate, assetvalue, reference, comment, adjustedAssetTxUuid) + into hs_office.coopassettx(uuid, membershipuuid, transactiontype, valuedate, assetvalue, reference, comment, revertedAssetTxUuid) values (uuid_generate_v4(), membership.uuid, 'DEPOSIT', '2010-03-15', 320.00, 'ref '||givenPartnerNumber || givenMemberNumberSuffix||'-1', 'initial deposit', null), (uuid_generate_v4(), membership.uuid, 'DISBURSAL', '2021-09-01', -128.00, 'ref '||givenPartnerNumber || givenMemberNumberSuffix||'-2', 'partial disbursal', null), (lossEntryUuid, membership.uuid, 'DEPOSIT', '2022-10-20', 128.00, 'ref '||givenPartnerNumber || givenMemberNumberSuffix||'-3', 'some loss', null), - (uuid_generate_v4(), membership.uuid, 'ADJUSTMENT', '2022-10-21', -128.00, 'ref '||givenPartnerNumber || givenMemberNumberSuffix||'-3', 'some adjustment', lossEntryUuid); + (uuid_generate_v4(), membership.uuid, 'REVERSAL', '2022-10-21', -128.00, 'ref '||givenPartnerNumber || givenMemberNumberSuffix||'-3', 'some reversal', lossEntryUuid); end; $$; --// diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java index 626e4613..2c8dfe82 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -442,7 +442,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { 34002=CoopAssetsTransaction(M-1002000: 2016-12-31, DISBURSAL, -100.00, 1002000, 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, 1909000, for subscription E), - 35002=CoopAssetsTransaction(M-1909000: 2024-01-20, ADJUSTMENT, -128.00, 1909000, chargeback for subscription E, M-1909000:DEP:+128.00), + 35002=CoopAssetsTransaction(M-1909000: 2024-01-20, REVERSAL, -128.00, 1909000, chargeback for subscription E, M-1909000:DEP:+128.00), 358=CoopAssetsTransaction(M-1000300: 2000-12-06, DEPOSIT, 5120, 1000300, for subscription A), 442=CoopAssetsTransaction(M-1015200: 2003-07-07, DEPOSIT, 64, 1015200), 577=CoopAssetsTransaction(M-1000300: 2011-12-12, DEPOSIT, 1024, 1000300), @@ -810,7 +810,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { a.getShareCount() == negativeValue) .findAny() .orElseThrow(() -> new IllegalStateException( - "cannot determine share reverse entry for adjustment " + shareTransaction)); + "cannot determine share reverse entry for reversal " + shareTransaction)); shareTransaction.setRevertedShareTx(revertedShareTx); } coopShares.put(rec.getInteger("member_share_id"), shareTransaction); @@ -837,7 +837,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { final var assetTypeMapping = new HashMap() { { - put("ADJUSTMENT", HsOfficeCoopAssetsTransactionType.ADJUSTMENT); + put("REVERSAL", HsOfficeCoopAssetsTransactionType.REVERSAL); put("HANDOVER", HsOfficeCoopAssetsTransactionType.TRANSFER); put("ADOPTION", HsOfficeCoopAssetsTransactionType.ADOPTION); put("LOSS", HsOfficeCoopAssetsTransactionType.LOSS); @@ -865,16 +865,16 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { .reference(member.getMemberNumber().toString()) .build(); - if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.ADJUSTMENT) { + if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.REVERSAL) { final var negativeValue = assetTransaction.getAssetValue().negate(); - final var adjustedAssetTx = coopAssets.values().stream().filter(a -> - a.getTransactionType() != HsOfficeCoopAssetsTransactionType.ADJUSTMENT && + final var revertedAssetTx = coopAssets.values().stream().filter(a -> + a.getTransactionType() != HsOfficeCoopAssetsTransactionType.REVERSAL && a.getMembership() == assetTransaction.getMembership() && a.getAssetValue().equals(negativeValue)) .findAny() .orElseThrow(() -> new IllegalStateException( - "cannot determine asset reverse entry for adjustment " + assetTransaction)); - assetTransaction.setAdjustedAssetTx(adjustedAssetTx); + "cannot determine asset reverse entry for reversal " + assetTransaction)); + assetTransaction.setRevertedAssetTx(revertedAssetTx); } coopAssets.put(rec.getInteger("member_asset_id"), assetTransaction); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java index 6ac97292..53067d45 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java @@ -109,21 +109,21 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased "valueDate": "2022-10-20", "reference": "ref 1000202-3", "comment": "some loss", - "adjustmentAssetTx": { - "transactionType": "ADJUSTMENT", + "reversalAssetTx": { + "transactionType": "REVERSAL", "assetValue": -128.00, "valueDate": "2022-10-21", "reference": "ref 1000202-3", - "comment": "some adjustment" + "comment": "some reversal" } }, { - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "assetValue": -128.00, "valueDate": "2022-10-21", "reference": "ref 1000202-3", - "comment": "some adjustment", - "adjustedAssetTx": { + "comment": "some reversal", + "revertedAssetTx": { "transactionType": "DEPOSIT", "assetValue": 128.00, "valueDate": "2022-10-20", @@ -214,7 +214,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased } @Test - void globalAdmin_canAddCoopAssetsAdjustmentTransaction() { + void globalAdmin_canAddCoopAssetsReversalTransaction() { context.define("superuser-alex@hostsharing.net"); final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101); @@ -238,11 +238,11 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased .body(""" { "membership.uuid": "%s", - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "assetValue": %s, "valueDate": "2022-10-30", - "reference": "test ref adjustment", - "comment": "some coop assets adjustment transaction", + "reference": "test ref reversal", + "comment": "some coop assets reversal transaction", "reverseEntry.uuid": "%s" } """.formatted( @@ -258,12 +258,12 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased .body("uuid", isUuidValid()) .body("", lenientlyEquals(""" { - "transactionType": "ADJUSTMENT", + "transactionType": "REVERSAL", "assetValue": -256.00, "valueDate": "2022-10-30", - "reference": "test ref adjustment", - "comment": "some coop assets adjustment transaction", - "adjustedAssetTx": { + "reference": "test ref reversal", + "comment": "some coop assets reversal transaction", + "revertedAssetTx": { "transactionType": "DEPOSIT", "assetValue": 256.00, "valueDate": "2022-10-20", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java index b7f44b35..46779410 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java @@ -77,7 +77,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { ASSETS_VALUE_MUST_NOT_BE_NULL( requestBody -> requestBody - .with("transactionType", "ADJUSTMENT") + .with("transactionType", "REVERSAL") .with("assetValue", 0.00), "[assetValue must not be 0 but is \"0.00\"]"), diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java index 09f704d6..0e6606c2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java @@ -21,14 +21,14 @@ class HsOfficeCoopAssetsTransactionEntityUnitTest { .build(); - final HsOfficeCoopAssetsTransactionEntity givenCoopAssetAdjustmentTransaction = HsOfficeCoopAssetsTransactionEntity.builder() + final HsOfficeCoopAssetsTransactionEntity givenCoopAssetReversalTransaction = HsOfficeCoopAssetsTransactionEntity.builder() .membership(TEST_MEMBERSHIP) .reference("some-ref") .valueDate(LocalDate.parse("2020-01-15")) - .transactionType(HsOfficeCoopAssetsTransactionType.ADJUSTMENT) + .transactionType(HsOfficeCoopAssetsTransactionType.REVERSAL) .assetValue(new BigDecimal("-128.00")) .comment("some comment") - .adjustedAssetTx(givenCoopAssetTransaction) + .revertedAssetTx(givenCoopAssetTransaction) .build(); final HsOfficeCoopAssetsTransactionEntity givenEmptyCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder().build(); @@ -42,11 +42,11 @@ class HsOfficeCoopAssetsTransactionEntityUnitTest { @Test void toStringWithReverseEntryContainsReverseEntry() { - givenCoopAssetTransaction.setAdjustedAssetTx(givenCoopAssetAdjustmentTransaction); + givenCoopAssetTransaction.setRevertedAssetTx(givenCoopAssetReversalTransaction); final var result = givenCoopAssetTransaction.toString(); - assertThat(result).isEqualTo("CoopAssetsTransaction(M-1000101: 2020-01-01, DEPOSIT, 128.00, some-ref, some comment, M-1000101:ADJ:-128.00)"); + assertThat(result).isEqualTo("CoopAssetsTransaction(M-1000101: 2020-01-01, DEPOSIT, 128.00, some-ref, some comment, M-1000101:REV:-128.00)"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java index 8f650fa9..5d9316e2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java @@ -142,18 +142,18 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase result, "CoopAssetsTransaction(M-1000101: 2010-03-15, DEPOSIT, 320.00, ref 1000101-1, initial deposit)", "CoopAssetsTransaction(M-1000101: 2021-09-01, DISBURSAL, -128.00, ref 1000101-2, partial disbursal)", - "CoopAssetsTransaction(M-1000101: 2022-10-20, DEPOSIT, 128.00, ref 1000101-3, some loss, M-1000101:ADJ:-128.00)", - "CoopAssetsTransaction(M-1000101: 2022-10-21, ADJUSTMENT, -128.00, ref 1000101-3, some adjustment, M-1000101:DEP:+128.00)", + "CoopAssetsTransaction(M-1000101: 2022-10-20, DEPOSIT, 128.00, ref 1000101-3, some loss, M-1000101:REV:-128.00)", + "CoopAssetsTransaction(M-1000101: 2022-10-21, REVERSAL, -128.00, ref 1000101-3, some reversal, M-1000101:DEP:+128.00)", "CoopAssetsTransaction(M-1000202: 2010-03-15, DEPOSIT, 320.00, ref 1000202-1, initial deposit)", "CoopAssetsTransaction(M-1000202: 2021-09-01, DISBURSAL, -128.00, ref 1000202-2, partial disbursal)", - "CoopAssetsTransaction(M-1000202: 2022-10-20, DEPOSIT, 128.00, ref 1000202-3, some loss, M-1000202:ADJ:-128.00)", - "CoopAssetsTransaction(M-1000202: 2022-10-21, ADJUSTMENT, -128.00, ref 1000202-3, some adjustment, M-1000202:DEP:+128.00)", + "CoopAssetsTransaction(M-1000202: 2022-10-20, DEPOSIT, 128.00, ref 1000202-3, some loss, M-1000202:REV:-128.00)", + "CoopAssetsTransaction(M-1000202: 2022-10-21, REVERSAL, -128.00, ref 1000202-3, some reversal, M-1000202:DEP:+128.00)", "CoopAssetsTransaction(M-1000303: 2010-03-15, DEPOSIT, 320.00, ref 1000303-1, initial deposit)", "CoopAssetsTransaction(M-1000303: 2021-09-01, DISBURSAL, -128.00, ref 1000303-2, partial disbursal)", - "CoopAssetsTransaction(M-1000303: 2022-10-20, DEPOSIT, 128.00, ref 1000303-3, some loss, M-1000303:ADJ:-128.00)", - "CoopAssetsTransaction(M-1000303: 2022-10-21, ADJUSTMENT, -128.00, ref 1000303-3, some adjustment, M-1000303:DEP:+128.00)"); + "CoopAssetsTransaction(M-1000303: 2022-10-20, DEPOSIT, 128.00, ref 1000303-3, some loss, M-1000303:REV:-128.00)", + "CoopAssetsTransaction(M-1000303: 2022-10-21, REVERSAL, -128.00, ref 1000303-3, some reversal, M-1000303:DEP:+128.00)"); } @Test @@ -173,8 +173,8 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase result, "CoopAssetsTransaction(M-1000202: 2010-03-15, DEPOSIT, 320.00, ref 1000202-1, initial deposit)", "CoopAssetsTransaction(M-1000202: 2021-09-01, DISBURSAL, -128.00, ref 1000202-2, partial disbursal)", - "CoopAssetsTransaction(M-1000202: 2022-10-20, DEPOSIT, 128.00, ref 1000202-3, some loss, M-1000202:ADJ:-128.00)", - "CoopAssetsTransaction(M-1000202: 2022-10-21, ADJUSTMENT, -128.00, ref 1000202-3, some adjustment, M-1000202:DEP:+128.00)"); + "CoopAssetsTransaction(M-1000202: 2022-10-20, DEPOSIT, 128.00, ref 1000202-3, some loss, M-1000202:REV:-128.00)", + "CoopAssetsTransaction(M-1000202: 2022-10-21, REVERSAL, -128.00, ref 1000202-3, some reversal, M-1000202:DEP:+128.00)"); } @Test @@ -211,8 +211,8 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase result, "CoopAssetsTransaction(M-1000101: 2010-03-15, DEPOSIT, 320.00, ref 1000101-1, initial deposit)", "CoopAssetsTransaction(M-1000101: 2021-09-01, DISBURSAL, -128.00, ref 1000101-2, partial disbursal)", - "CoopAssetsTransaction(M-1000101: 2022-10-20, DEPOSIT, 128.00, ref 1000101-3, some loss, M-1000101:ADJ:-128.00)", - "CoopAssetsTransaction(M-1000101: 2022-10-21, ADJUSTMENT, -128.00, ref 1000101-3, some adjustment, M-1000101:DEP:+128.00)"); + "CoopAssetsTransaction(M-1000101: 2022-10-20, DEPOSIT, 128.00, ref 1000101-3, some loss, M-1000101:REV:-128.00)", + "CoopAssetsTransaction(M-1000101: 2022-10-21, REVERSAL, -128.00, ref 1000101-3, some reversal, M-1000101:DEP:+128.00)"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java index 2111349c..62addd5f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java @@ -279,7 +279,7 @@ public abstract class UseCase> { public HttpResponse keepAs(final String alias) { ScenarioTest.putAlias( - alias == null ? "unknown alias" : alias, // FIXME + nonNullAlias(alias), new ScenarioTest.Alias<>(UseCase.this.getClass(), locationUuid)); return this; } @@ -348,6 +348,13 @@ public abstract class UseCase> { testReport.printLine("```"); testReport.printLine(""); } + + private String nonNullAlias(final String alias) { + // This marker tag should not appear in the source-code, as here is nothing to fix. + // But if it appears in generated Markdown files, it should show up when that marker tag is searched. + final var onlyVisibleInGeneratedMarkdownNotInSource = new String(new char[]{'F', 'I', 'X', 'M', 'E'}); + return alias == null ? "unknown alias -- " + onlyVisibleInGeneratedMarkdownNotInSource : alias; + } } protected T self() { diff --git a/src/test/resources/migration/office/asset_transactions.csv b/src/test/resources/migration/office/asset_transactions.csv index a0a83e02..d4f69478 100644 --- a/src/test/resources/migration/office/asset_transactions.csv +++ b/src/test/resources/migration/office/asset_transactions.csv @@ -16,4 +16,4 @@ member_asset_id; bp_id; date; action; amount; comment 34002; 120; 2016-12-31; PAYBACK; -100.00; for cancellation D 34003; 120; 2016-12-31; LOSS; -20.00; for cancellation D 35001; 190; 2024-01-15; PAYMENT; 128.00; for subscription E -35002; 190; 2024-01-20; ADJUSTMENT;-128.00; chargeback for subscription E +35002; 190; 2024-01-20; REVERSAL;-128.00; chargeback for subscription E -- 2.39.5 From 9feef02a170c1e19b08022067a7127adf32d88d1 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 09:29:58 +0100 Subject: [PATCH 13/38] adjust naming in CoopAssets regarding reverseEntry->revertedAssetTx --- .../coopassets/HsOfficeCoopAssetsTransactionController.java | 6 +++--- .../hs-office/hs-office-coopassets-schemas.yaml | 2 +- ...OfficeCoopAssetsTransactionControllerAcceptanceTest.java | 2 +- .../HsOfficeCoopAssetsTransactionEntityUnitTest.java | 2 +- .../HsOfficeCoopSharesTransactionEntityUnitTest.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index 8095c96e..4ab26f49 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -128,9 +128,9 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse } final BiConsumer RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { - if ( resource.getReverseEntryUuid() != null ) { - entity.setRevertedAssetTx(coopAssetsTransactionRepo.findByUuid(resource.getReverseEntryUuid()) - .orElseThrow(() -> new EntityNotFoundException("ERROR: [400] reverseEntityUuid %s not found".formatted(resource.getReverseEntryUuid())))); + if ( resource.getRevertedAssetTxUuid() != null ) { + entity.setRevertedAssetTx(coopAssetsTransactionRepo.findByUuid(resource.getRevertedAssetTxUuid()) + .orElseThrow(() -> new EntityNotFoundException("ERROR: [400] reverseEntityUuid %s not found".formatted(resource.getRevertedAssetTxUuid())))); } }; }; diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopassets-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopassets-schemas.yaml index cb3a9eb5..30725a82 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopassets-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopassets-schemas.yaml @@ -80,7 +80,7 @@ components: maxLength: 48 comment: type: string - reverseEntry.uuid: # FIXME: rename to revertedAssetTx + revertedAssetTx.uuid: type: string format: uuid required: diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java index 53067d45..0caafbab 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java @@ -243,7 +243,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased "valueDate": "2022-10-30", "reference": "test ref reversal", "comment": "some coop assets reversal transaction", - "reverseEntry.uuid": "%s" + "revertedAssetTx.uuid": "%s" } """.formatted( givenMembership.getUuid(), diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java index 0e6606c2..96a0edfb 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java @@ -41,7 +41,7 @@ class HsOfficeCoopAssetsTransactionEntityUnitTest { } @Test - void toStringWithReverseEntryContainsReverseEntry() { + void toStringWithRevertedAssetTxContainsRevertedAssetTx() { givenCoopAssetTransaction.setRevertedAssetTx(givenCoopAssetReversalTransaction); final var result = givenCoopAssetTransaction.toString(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java index 3ec158f4..6394a8d7 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java @@ -40,7 +40,7 @@ class HsOfficeCoopSharesTransactionEntityUnitTest { } @Test - void toStringWithReverseEntryContainsReverseEntry() { + void toStringWithRevertedAssetTxContainsRevertedAssetTx() { givenCoopSharesTransaction.setRevertedShareTx(givenCoopShareReversalTransaction); final var result = givenCoopSharesTransaction.toString(); -- 2.39.5 From a8de7029e9ace90a3d2d1f0c30f762964492df37 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 10:03:33 +0100 Subject: [PATCH 14/38] query partner instead of re-using the @Required uuid --- .../scenarios/membership/CreateMembership.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java index f66a0202..b7af4876 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java @@ -1,8 +1,8 @@ package net.hostsharing.hsadminng.hs.office.scenarios.membership; import io.restassured.http.ContentType; -import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; +import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; import org.springframework.http.HttpStatus; import static io.restassured.http.ContentType.JSON; @@ -16,11 +16,17 @@ public class CreateMembership extends UseCase { @Override protected HttpResponse run() { - // FIXME: httpGet "partner.uuid": ${Partner: Test AG} + + obtain("Partner: %{partnerName}", () -> + httpGet("/api/hs/office/partners?name=&{partnerName}") + .expecting(OK).expecting(JSON), + response -> response.expectArrayElements(1).getFromBody("[0].uuid"), + "In production, data this query could result in multiple outputs. In that case, you have to find out which is the right one." + ); return httpPost("/api/hs/office/memberships", usingJsonBody(""" { - "partner.uuid": ${Partner: P-31010 - Test AG}, + "partner.uuid": ${Partner: %{partnerName}}, "memberNumberSuffix": ${memberNumberSuffix}, "status": "ACTIVE", "validFrom": ${validFrom}, -- 2.39.5 From 4fb0a270da4384f79069ef329fc3e6820cebbcea Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 13:27:59 +0100 Subject: [PATCH 15/38] fixing some FIXME's --- doc/business-glossary-de.md | 76 +++++++++++++++++++ .../partner/HsOfficePartnerController.java | 1 + .../scenarios/HsOfficeScenarioTests.java | 2 +- .../hs/office/scenarios/UseCase.java | 2 +- .../scenarios/partner/CreatePartner.java | 2 + 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 doc/business-glossary-de.md diff --git a/doc/business-glossary-de.md b/doc/business-glossary-de.md new file mode 100644 index 00000000..4ab2d60a --- /dev/null +++ b/doc/business-glossary-de.md @@ -0,0 +1,76 @@ +### hsadminNg fachliches Glossar + + + +Dieses ist eine Sammlung von Fachbegriffen, die in diesem Projekt benutzt werden. +Ebenfalls aufgenommen sind technische Begriffe, die für Benutzer für das Verständnis der Schnittstellen nötig sind. + +Falls etwas fehlt, bitte Bescheid geben. + + +#### Partner + +In diesem System ist ein _Partner_ grundsätzlich jeglicher Geschäftspartner der _Hostsharing eG_. +Dies können grundsätzlich Kunden, siehe [Debitor](#Debitor), wie Lieferanten sein. +Derzeit sind aber nur Debitoren implementiert. + +Des Weiteren gibt es für jeden _Partner_ eine fünfstellige Partnernummer mit dem Prefix 'P-' (z.B. `P-123454`) +sowie Zusatzinformationen (z.B. Registergerichtnummer oder Geburtsdatum), die zur genauen Identifikation benötigt werden. + +Für einen _Partner_ kann es gleichzeitig mehrere [Debitoren](#Debitor) +und zeitlich nacheinander mehrere [Mitgliedschaften](#Mitgliedschaft) geben. + +Partner sind grundsätzlich als ist [Relation](#Relation) der Vertragsperson mit der Person _Hostsharing eG_ implementiert. + + +#### Ex-Partner + +Ex-Partner bilden [Personen](#Person) ab, die vormals [Partner](#Partner) waren. +Diese bleiben dadurch dem System + + +### Debitor + +Ein `Debitor` ist quasi ein Rechnungsempfänger für einen [Partner](#Partner). + +Für einen _Partner_ kann es gleichzeitig mehrere [Debitoren](#Debitor) geben, +z.B. für spezielle Projekte des Kunden oder verbundene Organisationen. + +Des Weiteren gibt es für jeden _Partner_ eine fünfstellige Partnernummer mit dem Prefix 'P-' (z.B. `P-123454`) +sowie Zusatzinformationen (z.B. Registergerichtsnummer oder Geburtsdatum), die zur genauen Identifikation benötigt werden. + + + +Debitoren sind grundsätzlich als ist [Relation](#Relation) der Vertragsperson mit der Person des Vertragspartners implementiert. + + +#### Representative (ehemals _contractual_) + +Ein _Representative_ ist eine natürliche Person, die für eine nicht-natürliche Person vertretungsberechtigt ist. + +Implementiert ist der _Representative_ als eine besondere Form der [Relation](#Relation) des + + + 'VIP_CONTACT', + 'OPERATIONS', + 'SUBSCRIBER'); + + +#### Relation (so eine Art Geschäftsrolle) + +Eine _Relation_ ist eine Beziehung + +Wir haben hier keinen Begriff mit 'Rolle' verwendet, +weil 'Role' (engl.) zu leicht mit der [RBAC-Rolle](#RBAC-Role) verwechselt werden könnte. + +Die _Relation_ ist auch ein technisches Konzept und gehört nicht zur Domänensprache. +Dieses Konzept ist jedoch für das Verständnis der ([API](#API)) notwendig. + +#### Anker + + +#### API (Application-Programming-Interface) + diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java index 1c86698a..1aefafa2 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java @@ -143,6 +143,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { private void optionallyCreateExPartnerRelation(final HsOfficePartnerEntity saved, final HsOfficeRelationRealEntity previousPartnerRel) { if (!saved.getPartnerRel().getUuid().equals(previousPartnerRel.getUuid())) { + // TODO.impl: we also need to use the new partner-person as the anchor relationRepo.save(previousPartnerRel.toBuilder().uuid(null).type(EX_PARTNER).build()); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index 117751ff..056816d6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -321,7 +321,7 @@ class HsOfficeScenarioTests extends ScenarioTest { void shouldCreateMembershipForPartner() { new CreateMembership(this) .given("partnerName", "Test AG") - .given("memberNumberSuffix", "00") + .given("memberNumberSuffix", "00") // FIXME: move into CreateMembership .given("validFrom", "2024-10-15") .given("newStatus", "ACTIVE") .given("membershipFeeBillable", "true") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java index 62addd5f..8850edcc 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java @@ -286,7 +286,7 @@ public abstract class UseCase> { public HttpResponse keep() { final var alias = nextTitle != null ? nextTitle : resultAlias; - // FIXME assertThat(alias).as("cannot keep result, no title or alias found for locationUuid: " + locationUuid).isNotNull(); + assertThat(alias).as("cannot keep result, no title or alias found for locationUuid: " + locationUuid).isNotNull(); return keepAs(alias); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java index a3aa727c..731e1151 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java @@ -16,6 +16,8 @@ public class CreatePartner extends UseCase { public CreatePartner(final ScenarioTest testSuite) { super(testSuite); + + // FIXME: Anmerkung, dass alle Partner Kunden sind } @Override -- 2.39.5 From 385c2c0b75781405ab18f0e56173bd552047251f Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 13:43:46 +0100 Subject: [PATCH 16/38] fixing initial memberhip number suffix --- .../hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java | 1 - .../hs/office/scenarios/membership/CreateMembership.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index 056816d6..4f282055 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -321,7 +321,6 @@ class HsOfficeScenarioTests extends ScenarioTest { void shouldCreateMembershipForPartner() { new CreateMembership(this) .given("partnerName", "Test AG") - .given("memberNumberSuffix", "00") // FIXME: move into CreateMembership .given("validFrom", "2024-10-15") .given("newStatus", "ACTIVE") .given("membershipFeeBillable", "true") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java index b7af4876..890dfedf 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateMembership.java @@ -27,7 +27,7 @@ public class CreateMembership extends UseCase { return httpPost("/api/hs/office/memberships", usingJsonBody(""" { "partner.uuid": ${Partner: %{partnerName}}, - "memberNumberSuffix": ${memberNumberSuffix}, + "memberNumberSuffix": ${%{memberNumberSuffix???}???00}, "status": "ACTIVE", "validFrom": ${validFrom}, "membershipFeeBillable": ${membershipFeeBillable} -- 2.39.5 From 11f6a895f292eb714894c9046da3c50b9b09b7b4 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 14:22:10 +0100 Subject: [PATCH 17/38] add introductory text for partner as client --- .../hsadminng/hs/office/scenarios/UseCase.java | 9 +++++++++ .../hs/office/scenarios/partner/CreatePartner.java | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java index 8850edcc..5867146a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java @@ -51,6 +51,7 @@ public abstract class UseCase> { private final Map givenProperties = new LinkedHashMap<>(); private String nextTitle; // just temporary to override resultAlias for sub-use-cases + private String introduction; public UseCase(final ScenarioTest testSuite) { this(testSuite, getResultAliasFromProducesAnnotationInCallStack()); @@ -72,6 +73,9 @@ public abstract class UseCase> { } public final HttpResponse doRun() { + if (introduction != null) { + testReport.printPara(introduction); + } testReport.printPara("### Given Properties"); testReport.printLine(""" | name | value | @@ -96,6 +100,11 @@ public abstract class UseCase> { protected void verify(final HttpResponse response) { } + public UseCase introduction(final String introduction) { + this.introduction = introduction; + return this; + } + public final UseCase given(final String propName, final Object propValue) { givenProperties.put(propName, propValue); ScenarioTest.putProperty(propName, propValue); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java index 731e1151..3896bbf6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java @@ -17,7 +17,7 @@ public class CreatePartner extends UseCase { public CreatePartner(final ScenarioTest testSuite) { super(testSuite); - // FIXME: Anmerkung, dass alle Partner Kunden sind + introduction("A partner can be a client or a vendor, currently we only use them for clients."); } @Override -- 2.39.5 From ff42bc45ab1ae2de86945d105e5e232affadb87c Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 14:56:44 +0100 Subject: [PATCH 18/38] add RestTest for findMembershipByNonExistingMemberNumberReturnsEmptyList --- .../HsOfficeMembershipControllerRestTest.java | 33 ++++++++++++++++++- .../hs/office/scenarios/PathAssertion.java | 1 - 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java index 455008a2..2306fcca 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java @@ -20,6 +20,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import java.util.UUID; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; @@ -44,8 +45,36 @@ public class HsOfficeMembershipControllerRestTest { @MockBean EntityManagerWrapper em; + @Nested + class GetMemberships { + + @Test + void findMembershipByNonExistingMemberNumberReturnsEmptyList() throws Exception { + + // when + mockMvc.perform(MockMvcRequestBuilders + .get("/api/hs/office/memberships?memberNumber=12345") + .header("current-subject", "superuser-alex@hostsharing.net") + .contentType(MediaType.APPLICATION_JSON) + .content(""" + { + "partner.uuid": null, + "memberNumberSuffix": "01", + "validFrom": "2022-10-13", + "membershipFeeBillable": "true" + } + """) + .accept(MediaType.APPLICATION_JSON)) + + // then + .andExpect(status().is2xxSuccessful()) + .andExpect(jsonPath("$", hasSize(0))); + } + } + @Nested class AddMembership { + @Test void respondBadRequest_ifPartnerUuidIsMissing() throws Exception { @@ -98,7 +127,9 @@ public class HsOfficeMembershipControllerRestTest { .andExpect(status().is4xxClientError()) .andExpect(jsonPath("statusCode", is(400))) .andExpect(jsonPath("statusPhrase", is("Bad Request"))) - .andExpect(jsonPath("message", is("ERROR: [400] Unable to find Partner by partner.uuid: " + givenPartnerUuid))); + .andExpect(jsonPath( + "message", + is("ERROR: [400] Unable to find Partner by partner.uuid: " + givenPartnerUuid))); } @ParameterizedTest diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java index baf8d358..a358280d 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java @@ -18,7 +18,6 @@ public class PathAssertion { public Consumer contains(final String resolvableValue) { return response -> { try { - // FIXME: typed check instead of .map(Object::toString) possible? response.path(path).map(Object::toString).contains(ScenarioTest.resolve(resolvableValue)); } catch (final AssertionError e) { // without this, the error message is often lacking important context -- 2.39.5 From c3f3efaf18fd82d21a6d450e8b565eb63d09c485 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 14:56:54 +0100 Subject: [PATCH 19/38] add RestTest for findMembershipByNonExistingMemberNumberReturnsEmptyList --- .../hs/office/membership/HsOfficeMembershipController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java index 12c373da..62dcd1c2 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java @@ -41,7 +41,6 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { context.define(currentSubject, assumedRoles); final var entities = ( memberNumber != null) - // FIXME: RestTest for the case that findMembershipByMemberNumber returns null ? ofNullable(membershipRepo.findMembershipByMemberNumber(memberNumber)).stream().toList() : membershipRepo.findMembershipsByOptionalPartnerUuid(partnerUuid); -- 2.39.5 From f12ef76f0597a3d9b3d8f864bc39a51b7436f232 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 16:14:33 +0100 Subject: [PATCH 20/38] add aliass scenario-reports-upload + scenario-reports-online and hide template+debug-log --- .aliases | 3 +++ build.gradle | 4 ++-- doc/scenarios/{template.html => .template.html} | 0 .../hostsharing/hsadminng/hs/office/scenarios/TestReport.java | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) rename doc/scenarios/{template.html => .template.html} (100%) diff --git a/.aliases b/.aliases index b57cd717..55a53503 100644 --- a/.aliases +++ b/.aliases @@ -95,3 +95,6 @@ if [ ! -f .environment ]; then cp .tc-environment .environment fi source .environment + +alias scenario-reports-upload='./gradlew convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office' +alias scenario-reports-online='open https://hsngdev.hs-example.de/scenarios/office' diff --git a/build.gradle b/build.gradle index ed7a290d..c07888f5 100644 --- a/build.gradle +++ b/build.gradle @@ -410,7 +410,7 @@ tasks.register('convertMarkdownToHtml') { group = 'Conversion' // Define the template file and input directory - def templateFile = file('doc/scenarios/template.html') + def templateFile = file('doc/scenarios/.template.html') // Task configuration and execution doFirst { @@ -425,7 +425,7 @@ tasks.register('convertMarkdownToHtml') { // Check if the template file exists if (!templateFile.exists()) { - throw new GradleException("Template file 'doc/scenarios/template.html' not found.") + throw new GradleException("Template file 'doc/scenarios/.template.html' not found.") } } diff --git a/doc/scenarios/template.html b/doc/scenarios/.template.html similarity index 100% rename from doc/scenarios/template.html rename to doc/scenarios/.template.html diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java index 07f15e36..5b89e6f1 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestReport { - private final static File markdownLogFile = new File("doc/scenarios/last-debug-log.md"); + private final static File markdownLogFile = new File("doc/scenarios/.last-debug-log.md"); private final Map aliases; private final PrintWriter markdownLog; // records everything for debugging purposes -- 2.39.5 From a1f09642b14df5e29c1f637aa7a42ce28f0d44d1 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 13 Nov 2024 16:14:48 +0100 Subject: [PATCH 21/38] fix duplicate @Order --- .../hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index 4f282055..d671aa8e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -343,7 +343,7 @@ class HsOfficeScenarioTests extends ScenarioTest { } @Test - @Order(4201) + @Order(4202) @Requires("Membership: M-3101000 - Test AG") void shouldRevertCoopSharesSubscription() { new CreateCoopSharesRevertTransaction(this) -- 2.39.5 From 07b5e4686bc954e1d4cb9050f6ac93c939475add Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 06:20:31 +0100 Subject: [PATCH 22/38] improve Scenario Report format --- .../hsadminng/system/SystemProcess.java | 2 +- .../hs/office/scenarios/PathAssertion.java | 3 +- .../hs/office/scenarios/ScenarioTest.java | 19 ++++++---- .../hs/office/scenarios/TemplateResolver.java | 38 +++++++++++++------ .../scenarios/TemplateResolverUnitTest.java | 3 +- .../hs/office/scenarios/TestReport.java | 21 ++++++++-- .../hs/office/scenarios/UseCase.java | 38 ++++++++++--------- .../CreateCoopSharesTransaction.java | 2 +- 8 files changed, 81 insertions(+), 45 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/system/SystemProcess.java b/src/main/java/net/hostsharing/hsadminng/system/SystemProcess.java index 8b302098..c53c814d 100644 --- a/src/main/java/net/hostsharing/hsadminng/system/SystemProcess.java +++ b/src/main/java/net/hostsharing/hsadminng/system/SystemProcess.java @@ -14,6 +14,7 @@ public class SystemProcess { @Getter private String stdOut; + @Getter private String stdErr; @@ -21,7 +22,6 @@ public class SystemProcess { this.processBuilder = new ProcessBuilder(command); } - public String getCommand() { return processBuilder.command().toString(); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java index a358280d..6c189db6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java @@ -4,6 +4,7 @@ import net.hostsharing.hsadminng.hs.office.scenarios.UseCase.HttpResponse; import java.util.function.Consumer; +import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.DROP_COMMENTS; import static org.junit.jupiter.api.Assertions.fail; public class PathAssertion { @@ -18,7 +19,7 @@ public class PathAssertion { public Consumer contains(final String resolvableValue) { return response -> { try { - response.path(path).map(Object::toString).contains(ScenarioTest.resolve(resolvableValue)); + response.path(path).map(Object::toString).contains(ScenarioTest.resolve(resolvableValue, DROP_COMMENTS)); } catch (final AssertionError e) { // without this, the error message is often lacking important context fail(e.getMessage() + " in `path(\"" + path + "\").contains(\"" + resolvableValue + "\")`" ); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/ScenarioTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/ScenarioTest.java index 4600584a..530eba74 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/ScenarioTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/ScenarioTest.java @@ -3,6 +3,7 @@ package net.hostsharing.hsadminng.hs.office.scenarios; import lombok.SneakyThrows; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver; import net.hostsharing.hsadminng.lambda.Reducer; import net.hostsharing.hsadminng.rbac.context.ContextBasedTest; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; @@ -26,6 +27,8 @@ import java.util.stream.Collectors; import static java.util.Arrays.asList; import static java.util.Optional.ofNullable; +import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.DROP_COMMENTS; +import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.DROP_COMMENTS; import static org.assertj.core.api.Assertions.assertThat; public abstract class ScenarioTest extends ContextBasedTest { @@ -38,11 +41,11 @@ public abstract class ScenarioTest extends ContextBasedTest { public String toString() { return ObjectUtils.toString(uuid); } + } - private final static Map> aliases = new HashMap<>(); - private final static Map properties = new HashMap<>(); + private final static Map properties = new HashMap<>(); public final TestReport testReport = new TestReport(aliases); @LocalServerPort @@ -139,9 +142,9 @@ public abstract class ScenarioTest extends ContextBasedTest { } static UUID uuid(final String nameWithPlaceholders) { - final var resoledName = resolve(nameWithPlaceholders); - final UUID alias = ofNullable(knowVariables().get(resoledName)).filter(v -> v instanceof UUID).map(UUID.class::cast).orElse(null); - assertThat(alias).as("alias '" + resoledName + "' not found in aliases nor in properties [" + + final var resolvedName = resolve(nameWithPlaceholders, DROP_COMMENTS); + final UUID alias = ofNullable(knowVariables().get(resolvedName)).filter(v -> v instanceof UUID).map(UUID.class::cast).orElse(null); + assertThat(alias).as("alias '" + resolvedName + "' not found in aliases nor in properties [" + knowVariables().keySet().stream().map(v -> "'" + v + "'").collect(Collectors.joining(", ")) + "]" ).isNotNull(); return alias; @@ -162,13 +165,13 @@ public abstract class ScenarioTest extends ContextBasedTest { return map; } - public static String resolve(final String text) { - final var resolved = new TemplateResolver(text, ScenarioTest.knowVariables()).resolve(); + public static String resolve(final String text, final Resolver resolver) { + final var resolved = new TemplateResolver(text, ScenarioTest.knowVariables()).resolve(resolver); return resolved; } public static Object resolveTyped(final String text) { - final var resolved = resolve(text); + final var resolved = resolve(text, DROP_COMMENTS); try { return UUID.fromString(resolved); } catch (final IllegalArgumentException e) { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java index aaa8855a..b6fac263 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java @@ -10,29 +10,39 @@ import java.util.Objects; import java.util.regex.Pattern; import java.util.stream.Collectors; +import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.DROP_COMMENTS; + public class TemplateResolver { - private final static Pattern pattern = Pattern.compile(",(\\s*})", Pattern.MULTILINE); - private static final String IF_NOT_FOUND_SYMBOL = "???"; + public enum Resolver { + DROP_COMMENTS, // deletes comments ('#{whatever}' -> '') + KEEP_COMMENTS // deletes comments ('#{whatever}' -> '') + } enum PlaceholderPrefix { RAW('%') { @Override - String convert(final Object value) { + String convert(final Object value, final Resolver resolver) { return value != null ? value.toString() : ""; } }, JSON_QUOTED('$'){ @Override - String convert(final Object value) { + String convert(final Object value, final Resolver resolver) { return jsonQuoted(value); } }, URI_ENCODED('&'){ @Override - String convert(final Object value) { + String convert(final Object value, final Resolver resolver) { return value != null ? URLEncoder.encode(value.toString(), StandardCharsets.UTF_8) : ""; } + }, + COMMENT('#'){ + @Override + String convert(final Object value, final Resolver resolver) { + return resolver == DROP_COMMENTS ? "" : value.toString(); + } }; private final char prefixChar; @@ -42,19 +52,24 @@ public class TemplateResolver { } static boolean contains(final char givenChar) { - return Arrays.stream(values()).anyMatch(p -> p.prefixChar == givenChar); + return Arrays.stream(values()).anyMatch(p -> p.prefixChar == givenChar); } static PlaceholderPrefix ofPrefixChar(final char givenChar) { return Arrays.stream(values()).filter(p -> p.prefixChar == givenChar).findFirst().orElseThrow(); } - abstract String convert(final Object value); + abstract String convert(final Object value, final Resolver resolver); // FIXME: why Object and not String? } + private final static Pattern pattern = Pattern.compile(",(\\s*})", Pattern.MULTILINE); + private static final String IF_NOT_FOUND_SYMBOL = "???"; + private final String template; private final Map properties; private final StringBuilder resolved = new StringBuilder(); + + private Resolver resolver; private int position = 0; public TemplateResolver(final String template, final Map properties) { @@ -62,7 +77,8 @@ public class TemplateResolver { this.properties = properties; } - String resolve() { + String resolve(final Resolver resolver) { + this.resolver = resolver; final var resolved = copy(); final var withoutDroppedLines = dropLinesWithNullProperties(resolved); final var result = removeDanglingCommas(withoutDroppedLines); @@ -119,10 +135,10 @@ public class TemplateResolver { placeholder.append(fetchChar()); } } - final var name = new TemplateResolver(placeholder.toString(), properties).resolve(); - final var value = propVal(name); + final var content = new TemplateResolver(placeholder.toString(), properties).resolve(resolver); + final var value = intro != '#' ? propVal(content) : content; resolved.append( - PlaceholderPrefix.ofPrefixChar(intro).convert(value) + PlaceholderPrefix.ofPrefixChar(intro).convert(value, resolver) ); skipChar('}'); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolverUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolverUnitTest.java index 2d63e204..435d44d3 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolverUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolverUnitTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import java.util.Map; +import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.DROP_COMMENTS; import static org.assertj.core.api.Assertions.assertThat; class TemplateResolverUnitTest { @@ -42,7 +43,7 @@ class TemplateResolverUnitTest { Map.entry("simple placeholder", "einfach"), Map.entry("nested placeholder", "verschachtelt"), Map.entry("with-special-chars", "3&3 AG") - )).resolve(); + )).resolve(DROP_COMMENTS); assertThat(resolved).isEqualTo(""" with optional JSON quotes: diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java index 5b89e6f1..007e4512 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java @@ -1,6 +1,7 @@ package net.hostsharing.hsadminng.hs.office.scenarios; import lombok.SneakyThrows; +import net.hostsharing.hsadminng.system.SystemProcess; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.TestInfo; @@ -10,6 +11,8 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; @@ -17,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestReport { private final static File markdownLogFile = new File("doc/scenarios/.last-debug-log.md"); + public static final SimpleDateFormat MM_DD_YYYY_HH_MM_SS = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss"); private final Map aliases; private final PrintWriter markdownLog; // records everything for debugging purposes @@ -61,8 +65,16 @@ public class TestReport { printLine("\n" +output + "\n"); } + void silent(final Runnable code) { + silent++; + code.run(); + silent--; + } + public void close() { if (markdownReport != null) { + printPara("---"); + printPara("generated on " + MM_DD_YYYY_HH_MM_SS.format(new Date()) + " for branch " + currentGitBranch()); markdownReport.close(); System.out.println("SCENARIO REPORT: " + asClickableLink(markdownReportFile)); } @@ -102,9 +114,10 @@ public class TestReport { return result.toString(); } - void silent(final Runnable code) { - silent++; - code.run(); - silent--; + @SneakyThrows + private String currentGitBranch() { + final var gitRevParse = new SystemProcess("git", "rev-parse", "--abbrev-ref", "HEAD"); + gitRevParse.execute(); + return gitRevParse.getStdOut().split("\\R", 2)[0]; } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java index 5867146a..23244d64 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java @@ -34,6 +34,8 @@ import java.util.function.Function; import java.util.function.Supplier; import static java.net.URLEncoder.encode; +import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.DROP_COMMENTS; +import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.KEEP_COMMENTS; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.fail; import static org.junit.platform.commons.util.StringUtils.isBlank; @@ -116,11 +118,11 @@ public abstract class UseCase> { } public final void obtain( - final String alias, + final String title, final Supplier http, final Function extractor, final String... extraInfo) { - withTitle(ScenarioTest.resolve(alias), () -> { + withTitle(title, () -> { final var response = http.get().keep(extractor); Arrays.stream(extraInfo).forEach(testReport::printPara); return response; @@ -128,15 +130,15 @@ public abstract class UseCase> { } public final void obtain(final String alias, final Supplier http, final String... extraInfo) { - withTitle(ScenarioTest.resolve(alias), () -> { + withTitle(alias, () -> { final var response = http.get().keep(); Arrays.stream(extraInfo).forEach(testReport::printPara); return response; }); } - public HttpResponse withTitle(final String title, final Supplier code) { - this.nextTitle = ScenarioTest.resolve(title); + public HttpResponse withTitle(final String resolvableTitle, final Supplier code) { + this.nextTitle = resolvableTitle; final var response = code.get(); this.nextTitle = null; return response; @@ -144,7 +146,7 @@ public abstract class UseCase> { @SneakyThrows public final HttpResponse httpGet(final String uriPathWithPlaceholders) { - final var uriPath = ScenarioTest.resolve(uriPathWithPlaceholders); + final var uriPath = ScenarioTest.resolve(uriPathWithPlaceholders, DROP_COMMENTS); final var request = HttpRequest.newBuilder() .GET() .uri(new URI("http://localhost:" + testSuite.port + uriPath)) @@ -157,7 +159,7 @@ public abstract class UseCase> { @SneakyThrows public final HttpResponse httpPost(final String uriPathWithPlaceholders, final JsonTemplate bodyJsonTemplate) { - final var uriPath = ScenarioTest.resolve(uriPathWithPlaceholders); + final var uriPath = ScenarioTest.resolve(uriPathWithPlaceholders, DROP_COMMENTS); final var requestBody = bodyJsonTemplate.resolvePlaceholders(); final var request = HttpRequest.newBuilder() .POST(BodyPublishers.ofString(requestBody)) @@ -172,7 +174,7 @@ public abstract class UseCase> { @SneakyThrows public final HttpResponse httpPatch(final String uriPathWithPlaceholders, final JsonTemplate bodyJsonTemplate) { - final var uriPath = ScenarioTest.resolve(uriPathWithPlaceholders); + final var uriPath = ScenarioTest.resolve(uriPathWithPlaceholders, DROP_COMMENTS); final var requestBody = bodyJsonTemplate.resolvePlaceholders(); final var request = HttpRequest.newBuilder() .method(HttpMethod.PATCH.toString(), BodyPublishers.ofString(requestBody)) @@ -187,7 +189,7 @@ public abstract class UseCase> { @SneakyThrows public final HttpResponse httpDelete(final String uriPathWithPlaceholders) { - final var uriPath = ScenarioTest.resolve(uriPathWithPlaceholders); + final var uriPath = ScenarioTest.resolve(uriPathWithPlaceholders, DROP_COMMENTS); final var request = HttpRequest.newBuilder() .DELETE() .uri(new URI("http://localhost:" + testSuite.port + uriPath)) @@ -207,7 +209,7 @@ public abstract class UseCase> { final String title, final Supplier http, final Consumer... assertions) { - withTitle(ScenarioTest.resolve(title), () -> { + withTitle(title, () -> { final var response = http.get(); Arrays.stream(assertions).forEach(assertion -> assertion.accept(response)); return response; @@ -219,7 +221,7 @@ public abstract class UseCase> { } public String uriEncoded(final String text) { - return encode(ScenarioTest.resolve(text), StandardCharsets.UTF_8); + return encode(ScenarioTest.resolve(text, DROP_COMMENTS), StandardCharsets.UTF_8); } public static class JsonTemplate { @@ -231,7 +233,7 @@ public abstract class UseCase> { } String resolvePlaceholders() { - return ScenarioTest.resolve(template); + return ScenarioTest.resolve(template, DROP_COMMENTS); } } @@ -276,7 +278,7 @@ public abstract class UseCase> { } public HttpResponse keep(final Function extractor) { - final var alias = nextTitle != null ? nextTitle : resultAlias; + final var alias = nextTitle != null ? ScenarioTest.resolve(nextTitle, DROP_COMMENTS) : resultAlias; assertThat(alias).as("cannot keep result, no alias found").isNotNull(); final var value = extractor.apply(this); @@ -294,7 +296,7 @@ public abstract class UseCase> { } public HttpResponse keep() { - final var alias = nextTitle != null ? nextTitle : resultAlias; + final var alias = nextTitle != null ? ScenarioTest.resolve(nextTitle, DROP_COMMENTS) : resultAlias; assertThat(alias).as("cannot keep result, no title or alias found for locationUuid: " + locationUuid).isNotNull(); return keepAs(alias); @@ -313,13 +315,13 @@ public abstract class UseCase> { @SneakyThrows public String getFromBody(final String path) { - return JsonPath.parse(response.body()).read(ScenarioTest.resolve(path)); + return JsonPath.parse(response.body()).read(ScenarioTest.resolve(path, DROP_COMMENTS)); } @SneakyThrows public Optional getFromBodyAsOptional(final String path) { try { - return Optional.ofNullable(JsonPath.parse(response.body()).read(ScenarioTest.resolve(path))); + return Optional.ofNullable(JsonPath.parse(response.body()).read(ScenarioTest.resolve(path, DROP_COMMENTS))); } catch (final PathNotFoundException e) { return null; // means the property did not exist at all, not that it was there with value null } @@ -335,9 +337,9 @@ public abstract class UseCase> { // the title if (nextTitle != null) { - testReport.printLine("\n### " + nextTitle + "\n"); + testReport.printLine("\n### " + ScenarioTest.resolve(nextTitle, KEEP_COMMENTS) + "\n"); } else if (resultAlias != null) { - testReport.printLine("\n### " + resultAlias + "\n"); + testReport.printLine("\n### Create " + resultAlias + "\n"); } else { fail("please wrap the http...-call in the UseCase using `withTitle(...)`"); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java index 0ed75435..2618b14d 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java @@ -17,7 +17,7 @@ public abstract class CreateCoopSharesTransaction extends UseCase + obtain("#{Find }membershipUuid", () -> httpGet("/api/hs/office/memberships?memberNumber=&{memberNumber}") .expecting(OK).expecting(JSON).expectArrayElements(1), response -> response.getFromBody("$[0].uuid") -- 2.39.5 From 5f454a2ebeb68ddc7957c61398e25acce24f5043 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 14:24:30 +0100 Subject: [PATCH 23/38] workaround for the PostgreSQL money column type problem with thousands separator by using numeric --- .../512-coopassets/5120-hs-office-coopassets.sql | 8 ++++---- ...iceCoopAssetsTransactionRepositoryIntegrationTest.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql index 02b8e401..9604f5e9 100644 --- a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql +++ b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql @@ -22,7 +22,7 @@ create table if not exists hs_office.coopassettx membershipUuid uuid not null references hs_office.membership(uuid), transactionType hs_office.CoopAssetsTransactionType not null, valueDate date not null, - assetValue money not null, + assetValue numeric(12,2) not null, -- TODO.impl: use money type, but we had problems with Hibernate conversion reference varchar(48) not null, revertedAssetTxUuid uuid unique REFERENCES hs_office.coopassettx(uuid) DEFERRABLE INITIALLY DEFERRED, comment varchar(512) @@ -44,12 +44,12 @@ alter table hs_office.coopassettx --changeset michael.hoennig:hs-office-coopassets-ASSET-VALUE-CONSTRAINT endDelimiter:--// -- ---------------------------------------------------------------------------- -create or replace function hs_office.coopassetstx_check_positive_total(forMembershipUuid UUID, newAssetValue money) +create or replace function hs_office.coopassetstx_check_positive_total(forMembershipUuid UUID, newAssetValue numeric(12, 5)) returns boolean language plpgsql as $$ declare - currentAssetValue money; - totalAssetValue money; + currentAssetValue numeric(12,2); + totalAssetValue numeric(12,2); begin select sum(cat.assetValue) from hs_office.coopassettx cat diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java index 5d9316e2..523bea88 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java @@ -69,7 +69,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder() .membership(givenMembership) .transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT) - .assetValue(new BigDecimal("128.00")) + .assetValue(new BigDecimal("6,400.00")) .valueDate(LocalDate.parse("2022-10-18")) .reference("temp ref A") .build(); @@ -98,7 +98,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder() .membership(givenMembership) .transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT) - .assetValue(new BigDecimal("128.00")) + .assetValue(new BigDecimal("6400.00")) .valueDate(LocalDate.parse("2022-10-18")) .reference("temp ref B") .build(); -- 2.39.5 From 9a9e3e2e7375fc70e09ceab1cbe595e5479f5b77 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 14:30:00 +0100 Subject: [PATCH 24/38] add coop assets+shares scenario tests --- .../FormattedBigDecimalDeserializer.java | 28 ++++++++++ .../config/JsonObjectMapperConfiguration.java | 11 ++++ .../person/HsOfficePersonTypeConverter.java | 1 + .../scenarios/HsOfficeScenarioTests.java | 50 +++++++++++++++-- .../hs/office/scenarios/PathAssertion.java | 13 ++++- .../CreateCoopAssetsDepositTransaction.java | 12 +++++ .../CreateCoopAssetsDisbursalTransaction.java | 17 ++++++ .../CreateCoopAssetsRevertTransaction.java | 27 ++++++++++ .../CreateCoopAssetsTransaction.java | 53 +++++++++++++++++++ ...eateCoopSharesCancellationTransaction.java | 2 +- .../CreateCoopSharesRevertTransaction.java | 4 +- ...eateCoopSharesSubscriptionTransaction.java | 2 +- .../CreateCoopSharesTransaction.java | 4 +- 13 files changed, 213 insertions(+), 11 deletions(-) create mode 100644 src/main/java/net/hostsharing/hsadminng/config/FormattedBigDecimalDeserializer.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsDepositTransaction.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsDisbursalTransaction.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsRevertTransaction.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsTransaction.java rename src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/{ => coopshares}/CreateCoopSharesCancellationTransaction.java (97%) rename src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/{ => coopshares}/CreateCoopSharesRevertTransaction.java (89%) rename src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/{ => coopshares}/CreateCoopSharesSubscriptionTransaction.java (96%) rename src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/{ => coopshares}/CreateCoopSharesTransaction.java (95%) diff --git a/src/main/java/net/hostsharing/hsadminng/config/FormattedBigDecimalDeserializer.java b/src/main/java/net/hostsharing/hsadminng/config/FormattedBigDecimalDeserializer.java new file mode 100644 index 00000000..10991b15 --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/config/FormattedBigDecimalDeserializer.java @@ -0,0 +1,28 @@ +package net.hostsharing.hsadminng.config; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import java.io.IOException; +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.ParseException; +import java.util.Locale; + +public class FormattedBigDecimalDeserializer extends JsonDeserializer { + + @Override + public BigDecimal deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + final var numberStr = p.getText(); + try { + final var format = NumberFormat.getInstance(Locale.GERMANY); + if (format instanceof DecimalFormat) { + ((DecimalFormat) format).setParseBigDecimal(true); + } + return (BigDecimal) format.parse(numberStr); + } catch (final ParseException e) { + throw new IOException("Failed to parse BigDecimal from string: " + numberStr, e); + } + } +} diff --git a/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java b/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java index b7011f7f..1afa7ed8 100644 --- a/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java +++ b/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java @@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.config; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.openapitools.jackson.nullable.JsonNullableModule; import org.springframework.context.annotation.Bean; @@ -9,15 +10,25 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import java.math.BigDecimal; + @Configuration public class JsonObjectMapperConfiguration { @Bean @Primary public Jackson2ObjectMapperBuilder customObjectMapper() { + // HOWTO: add JSON converters and specify other JSON mapping configurations return new Jackson2ObjectMapperBuilder() + .modulesToInstall(formattedBigDecimalModule()) .modules(new JsonNullableModule(), new JavaTimeModule()) .featuresToEnable(JsonParser.Feature.ALLOW_COMMENTS, JsonParser.Feature.ALLOW_COMMENTS) .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } + + private SimpleModule formattedBigDecimalModule() { + final var module = new SimpleModule(); + module.addDeserializer(BigDecimal.class, new FormattedBigDecimalDeserializer()); + return module; + } } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverter.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverter.java index 8c268900..71c04ec0 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverter.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonTypeConverter.java @@ -4,6 +4,7 @@ import jakarta.persistence.AttributeConverter; import jakarta.persistence.Converter; import java.util.stream.Stream; +// HOWTO: convert data types for exchange between PostgreSQL and Java/Hibernate/JPA-Entities @Converter(autoApply = true) public class HsOfficePersonTypeConverter implements AttributeConverter { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index d671aa8e..13af695b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -12,10 +12,13 @@ import net.hostsharing.hsadminng.hs.office.scenarios.debitor.FinallyDeleteSepaMa import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DontDeleteDefaultDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.InvalidateSepaMandateForDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.membership.CancelMembership; -import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateCoopSharesCancellationTransaction; -import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateCoopSharesRevertTransaction; -import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateCoopSharesSubscriptionTransaction; import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateMembership; +import net.hostsharing.hsadminng.hs.office.scenarios.membership.coopassets.CreateCoopAssetsDepositTransaction; +import net.hostsharing.hsadminng.hs.office.scenarios.membership.coopassets.CreateCoopAssetsDisbursalTransaction; +import net.hostsharing.hsadminng.hs.office.scenarios.membership.coopassets.CreateCoopAssetsRevertTransaction; +import net.hostsharing.hsadminng.hs.office.scenarios.membership.coopshares.CreateCoopSharesCancellationTransaction; +import net.hostsharing.hsadminng.hs.office.scenarios.membership.coopshares.CreateCoopSharesRevertTransaction; +import net.hostsharing.hsadminng.hs.office.scenarios.membership.coopshares.CreateCoopSharesSubscriptionTransaction; import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddOperationsContactToPartner; import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteDebitor; @@ -348,7 +351,7 @@ class HsOfficeScenarioTests extends ScenarioTest { void shouldRevertCoopSharesSubscription() { new CreateCoopSharesRevertTransaction(this) .given("memberNumber", "3101000") - .given("comment", "reverting some incorrect subscription") + .given("comment", "reverting some incorrect transaction") .given("dateOfIncorrectTransaction", "2024-02-15") .doRun(); } @@ -367,6 +370,45 @@ class HsOfficeScenarioTests extends ScenarioTest { .doRun(); } + @Test + @Order(4301) + @Requires("Membership: M-3101000 - Test AG") + @Produces("Coop-Assets DEPOSIT Transaction") + void shouldSubscribeCoopAssets() { + new CreateCoopAssetsDepositTransaction(this) + .given("memberNumber", "3101000") + .given("reference", "sign 2024-01-15") + .given("assetValue", 100*64) + .given("comment", "disposal for initial shares") + .given("transactionDate", "2024-01-15") + .doRun(); + } + + @Test + @Order(4302) + @Requires("Membership: M-3101000 - Test AG") + void shouldRevertCoopAssetsSubscription() { + new CreateCoopAssetsRevertTransaction(this) + .given("memberNumber", "3101000") + .given("comment", "reverting some incorrect transaction") + .given("dateOfIncorrectTransaction", "2024-02-15") + .doRun(); + } + + @Test + @Order(4302) + @Requires("Coop-Assets DEPOSIT Transaction") + @Produces("Coop-Assets DISBURSAL Transaction") + void shouldDisburseCoopAssets() { + new CreateCoopAssetsDisbursalTransaction(this) + .given("memberNumber", "3101000") + .given("reference", "cancel 2024-01-15") + .given("valueToDisburse", 8*64) + .given("comment", "disbursal according to shares cancellation") + .given("transactionDate", "2024-02-15") + .doRun(); + } + @Test @Order(4900) @Requires("Membership: M-3101000 - Test AG") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java index 6c189db6..6d3dc2a2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/PathAssertion.java @@ -19,7 +19,7 @@ public class PathAssertion { public Consumer contains(final String resolvableValue) { return response -> { try { - response.path(path).map(Object::toString).contains(ScenarioTest.resolve(resolvableValue, DROP_COMMENTS)); + response.path(path).map(this::asString).contains(ScenarioTest.resolve(resolvableValue, DROP_COMMENTS)); } catch (final AssertionError e) { // without this, the error message is often lacking important context fail(e.getMessage() + " in `path(\"" + path + "\").contains(\"" + resolvableValue + "\")`" ); @@ -37,4 +37,15 @@ public class PathAssertion { } }; } + + private String asString(final Object value) { + if (value instanceof Double doubleValue) { + if (doubleValue % 1 == 0) { + return String.valueOf(doubleValue.intValue()); // avoid trailing ".0" + } else { + return doubleValue.toString(); + } + } + return value.toString(); + } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsDepositTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsDepositTransaction.java new file mode 100644 index 00000000..af9b01a1 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsDepositTransaction.java @@ -0,0 +1,12 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.membership.coopassets; + +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; + +public class CreateCoopAssetsDepositTransaction extends CreateCoopAssetsTransaction { + + public CreateCoopAssetsDepositTransaction(final ScenarioTest testSuite) { + super(testSuite); + + given("transactionType", "DEPOSIT"); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsDisbursalTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsDisbursalTransaction.java new file mode 100644 index 00000000..542f75d8 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsDisbursalTransaction.java @@ -0,0 +1,17 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.membership.coopassets; + +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; + +public class CreateCoopAssetsDisbursalTransaction extends CreateCoopAssetsTransaction { + + public CreateCoopAssetsDisbursalTransaction(final ScenarioTest testSuite) { + super(testSuite); + } + + @Override + protected HttpResponse run() { + given("transactionType", "DISBURSAL"); + given("assetValue", "-%{valueToDisburse}"); + return super.run(); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsRevertTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsRevertTransaction.java new file mode 100644 index 00000000..0750847c --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsRevertTransaction.java @@ -0,0 +1,27 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.membership.coopassets; + +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; + +public class CreateCoopAssetsRevertTransaction extends CreateCoopAssetsTransaction { + + public CreateCoopAssetsRevertTransaction(final ScenarioTest testSuite) { + super(testSuite); + + requires("CoopAssets-Transaction with incorrect assetValue", alias -> + new CreateCoopAssetsDepositTransaction(testSuite) + .given("memberNumber", "3101000") + .given("reference", "sign %{dateOfIncorrectTransaction}") // same as revertedAssetTx + .given("assetValue", 10) + .given("comment", "coop-assets deposit transaction with wrong asset value") + .given("transactionDate", "%{dateOfIncorrectTransaction}") + ); + } + + @Override + protected HttpResponse run() { + given("transactionType", "REVERSAL"); + given("assetValue", -100); + given("revertedAssetTx", uuid("CoopAssets-Transaction with incorrect assetValue")); + return super.run(); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsTransaction.java new file mode 100644 index 00000000..56bc2a55 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsTransaction.java @@ -0,0 +1,53 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.membership.coopassets; + +import io.restassured.http.ContentType; +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; +import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; +import org.springframework.http.HttpStatus; + +import static io.restassured.http.ContentType.JSON; +import static org.springframework.http.HttpStatus.OK; + +public abstract class CreateCoopAssetsTransaction extends UseCase { + + public CreateCoopAssetsTransaction(final ScenarioTest testSuite) { + super(testSuite); + } + + @Override + protected HttpResponse run() { + + obtain("#{Find }membershipUuid", () -> + httpGet("/api/hs/office/memberships?memberNumber=&{memberNumber}") + .expecting(OK).expecting(JSON).expectArrayElements(1), + response -> response.getFromBody("$[0].uuid") + ); + + return withTitle("Create the Coop-Assets-%{transactionType} Transaction", () -> + httpPost("/api/hs/office/coopassetstransactions", usingJsonBody(""" + { + "membership.uuid": ${membershipUuid}, + "transactionType": ${transactionType}, + "reference": ${reference}, + "assetValue": ${assetValue}, + "comment": ${comment}, + "valueDate": ${transactionDate}, + "revertedAssetTx.uuid": ${revertedAssetTx???} + } + """)) + .expecting(HttpStatus.CREATED).expecting(ContentType.JSON) + ); + } + + @Override + protected void verify(final HttpResponse response) { + verify("Verify Coop-Assets %{transactionType}-Transaction", + () -> httpGet("/api/hs/office/coopassetstransactions/" + response.getLocationUuid()) + .expecting(HttpStatus.OK).expecting(ContentType.JSON), + path("transactionType").contains("%{transactionType}"), + path("assetValue").contains("%{assetValue}"), + path("comment").contains("%{comment}"), + path("valueDate").contains("%{transactionDate}") + ); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesCancellationTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesCancellationTransaction.java similarity index 97% rename from src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesCancellationTransaction.java rename to src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesCancellationTransaction.java index 200ae07c..16549b36 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesCancellationTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesCancellationTransaction.java @@ -1,4 +1,4 @@ -package net.hostsharing.hsadminng.hs.office.scenarios.membership; +package net.hostsharing.hsadminng.hs.office.scenarios.membership.coopshares; import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java similarity index 89% rename from src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java rename to src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java index 06ef4101..03963834 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesRevertTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java @@ -1,4 +1,4 @@ -package net.hostsharing.hsadminng.hs.office.scenarios.membership; +package net.hostsharing.hsadminng.hs.office.scenarios.membership.coopshares; import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; @@ -12,7 +12,7 @@ public class CreateCoopSharesRevertTransaction extends CreateCoopSharesTransacti .given("memberNumber", "3101000") .given("reference", "sign %{dateOfIncorrectTransaction}") // same as revertedShareTx .given("shareCount", 100) - .given("comment", "reverting subscription transaction with wrong share count") + .given("comment", "coop-shares subscription transaction with wrong share count") .given("transactionDate", "%{dateOfIncorrectTransaction}") ); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesSubscriptionTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesSubscriptionTransaction.java similarity index 96% rename from src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesSubscriptionTransaction.java rename to src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesSubscriptionTransaction.java index 3aba4f29..84db07dd 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesSubscriptionTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesSubscriptionTransaction.java @@ -1,4 +1,4 @@ -package net.hostsharing.hsadminng.hs.office.scenarios.membership; +package net.hostsharing.hsadminng.hs.office.scenarios.membership.coopshares; import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesTransaction.java similarity index 95% rename from src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java rename to src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesTransaction.java index 2618b14d..cd8d9c14 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/CreateCoopSharesTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesTransaction.java @@ -1,4 +1,4 @@ -package net.hostsharing.hsadminng.hs.office.scenarios.membership; +package net.hostsharing.hsadminng.hs.office.scenarios.membership.coopshares; import io.restassured.http.ContentType; import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; @@ -23,7 +23,7 @@ public abstract class CreateCoopSharesTransaction extends UseCase response.getFromBody("$[0].uuid") ); - return withTitle("Create the CoopShares-%{transactionType} Transaction", () -> + return withTitle("Create the Coop-Shares-%{transactionType} Transaction", () -> httpPost("/api/hs/office/coopsharestransactions", usingJsonBody(""" { "membership.uuid": ${membershipUuid}, -- 2.39.5 From 83adb7a5aed3ba9ca2c880db1be790e718144e5f Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 15:11:15 +0100 Subject: [PATCH 25/38] remove FormattedBigDecimalDeserializer, did not work anyway --- .../FormattedBigDecimalDeserializer.java | 28 ------------------- .../config/JsonObjectMapperConfiguration.java | 13 ++++----- 2 files changed, 5 insertions(+), 36 deletions(-) delete mode 100644 src/main/java/net/hostsharing/hsadminng/config/FormattedBigDecimalDeserializer.java diff --git a/src/main/java/net/hostsharing/hsadminng/config/FormattedBigDecimalDeserializer.java b/src/main/java/net/hostsharing/hsadminng/config/FormattedBigDecimalDeserializer.java deleted file mode 100644 index 10991b15..00000000 --- a/src/main/java/net/hostsharing/hsadminng/config/FormattedBigDecimalDeserializer.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.hostsharing.hsadminng.config; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import java.io.IOException; -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.text.ParseException; -import java.util.Locale; - -public class FormattedBigDecimalDeserializer extends JsonDeserializer { - - @Override - public BigDecimal deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - final var numberStr = p.getText(); - try { - final var format = NumberFormat.getInstance(Locale.GERMANY); - if (format instanceof DecimalFormat) { - ((DecimalFormat) format).setParseBigDecimal(true); - } - return (BigDecimal) format.parse(numberStr); - } catch (final ParseException e) { - throw new IOException("Failed to parse BigDecimal from string: " + numberStr, e); - } - } -} diff --git a/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java b/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java index 1afa7ed8..d7d535c3 100644 --- a/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java +++ b/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java @@ -1,6 +1,7 @@ package net.hostsharing.hsadminng.config; import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; @@ -20,15 +21,11 @@ public class JsonObjectMapperConfiguration { public Jackson2ObjectMapperBuilder customObjectMapper() { // HOWTO: add JSON converters and specify other JSON mapping configurations return new Jackson2ObjectMapperBuilder() - .modulesToInstall(formattedBigDecimalModule()) .modules(new JsonNullableModule(), new JavaTimeModule()) - .featuresToEnable(JsonParser.Feature.ALLOW_COMMENTS, JsonParser.Feature.ALLOW_COMMENTS) + .featuresToEnable( + JsonParser.Feature.ALLOW_COMMENTS, + DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS + ) .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } - - private SimpleModule formattedBigDecimalModule() { - final var module = new SimpleModule(); - module.addDeserializer(BigDecimal.class, new FormattedBigDecimalDeserializer()); - return module; - } } -- 2.39.5 From be4898474ca1810b9dfdbaea871b6b92a670a083 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 15:23:03 +0100 Subject: [PATCH 26/38] don't use PostgreSQL money --- .../5-hs-office/512-coopassets/5120-hs-office-coopassets.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql index 9604f5e9..8feac5da 100644 --- a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql +++ b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql @@ -22,7 +22,7 @@ create table if not exists hs_office.coopassettx membershipUuid uuid not null references hs_office.membership(uuid), transactionType hs_office.CoopAssetsTransactionType not null, valueDate date not null, - assetValue numeric(12,2) not null, -- TODO.impl: use money type, but we had problems with Hibernate conversion + assetValue numeric(12,2) not null, -- https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_money reference varchar(48) not null, revertedAssetTxUuid uuid unique REFERENCES hs_office.coopassettx(uuid) DEFERRABLE INITIALLY DEFERRED, comment varchar(512) -- 2.39.5 From 38c51cbf7b106bee5e151efd6de96f1795623144 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 16:09:27 +0100 Subject: [PATCH 27/38] fix a FIXME regarding Object->String --- .../config/JsonObjectMapperConfiguration.java | 2 -- .../hs/office/scenarios/TemplateResolver.java | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java b/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java index d7d535c3..d5ff80d9 100644 --- a/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java +++ b/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java @@ -3,7 +3,6 @@ package net.hostsharing.hsadminng.config; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.openapitools.jackson.nullable.JsonNullableModule; import org.springframework.context.annotation.Bean; @@ -11,7 +10,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import java.math.BigDecimal; @Configuration public class JsonObjectMapperConfiguration { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java index b6fac263..7197e900 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java @@ -22,25 +22,25 @@ public class TemplateResolver { enum PlaceholderPrefix { RAW('%') { @Override - String convert(final Object value, final Resolver resolver) { + String convert(final String value, final Resolver resolver) { return value != null ? value.toString() : ""; } }, JSON_QUOTED('$'){ @Override - String convert(final Object value, final Resolver resolver) { + String convert(final String value, final Resolver resolver) { return jsonQuoted(value); } }, URI_ENCODED('&'){ @Override - String convert(final Object value, final Resolver resolver) { + String convert(final String value, final Resolver resolver) { return value != null ? URLEncoder.encode(value.toString(), StandardCharsets.UTF_8) : ""; } }, COMMENT('#'){ @Override - String convert(final Object value, final Resolver resolver) { + String convert(final String value, final Resolver resolver) { return resolver == DROP_COMMENTS ? "" : value.toString(); } }; @@ -59,7 +59,7 @@ public class TemplateResolver { return Arrays.stream(values()).filter(p -> p.prefixChar == givenChar).findFirst().orElseThrow(); } - abstract String convert(final Object value, final Resolver resolver); // FIXME: why Object and not String? + abstract String convert(final String value, final Resolver resolver); // FIXME: why Object and not String? } private final static Pattern pattern = Pattern.compile(",(\\s*})", Pattern.MULTILINE); @@ -136,7 +136,7 @@ public class TemplateResolver { } } final var content = new TemplateResolver(placeholder.toString(), properties).resolve(resolver); - final var value = intro != '#' ? propVal(content) : content; + final var value = intro != '#' ? propVal(content).toString() : content; resolved.append( PlaceholderPrefix.ofPrefixChar(intro).convert(value, resolver) ); -- 2.39.5 From 880b2aa99ada16525b7d1afe666e7c75aa30fa8a Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 16:22:00 +0100 Subject: [PATCH 28/38] fix new BigDecimal("6,400.00") --- .../HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java index 523bea88..4c2f866d 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java @@ -69,7 +69,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder() .membership(givenMembership) .transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT) - .assetValue(new BigDecimal("6,400.00")) + .assetValue(new BigDecimal("6400.00")) .valueDate(LocalDate.parse("2022-10-18")) .reference("temp ref A") .build(); -- 2.39.5 From e934726c4b68b69e529964856d7ccc9ebd253457 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 16:38:14 +0100 Subject: [PATCH 29/38] revert convert Object->String, causes NPE problems --- .../hs/office/scenarios/TemplateResolver.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java index 7197e900..977c2f13 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java @@ -22,25 +22,25 @@ public class TemplateResolver { enum PlaceholderPrefix { RAW('%') { @Override - String convert(final String value, final Resolver resolver) { + String convert(final Object value, final Resolver resolver) { return value != null ? value.toString() : ""; } }, JSON_QUOTED('$'){ @Override - String convert(final String value, final Resolver resolver) { + String convert(final Object value, final Resolver resolver) { return jsonQuoted(value); } }, URI_ENCODED('&'){ @Override - String convert(final String value, final Resolver resolver) { + String convert(final Object value, final Resolver resolver) { return value != null ? URLEncoder.encode(value.toString(), StandardCharsets.UTF_8) : ""; } }, COMMENT('#'){ @Override - String convert(final String value, final Resolver resolver) { + String convert(final Object value, final Resolver resolver) { return resolver == DROP_COMMENTS ? "" : value.toString(); } }; @@ -59,7 +59,7 @@ public class TemplateResolver { return Arrays.stream(values()).filter(p -> p.prefixChar == givenChar).findFirst().orElseThrow(); } - abstract String convert(final String value, final Resolver resolver); // FIXME: why Object and not String? + abstract String convert(final Object value, final Resolver resolver); } private final static Pattern pattern = Pattern.compile(",(\\s*})", Pattern.MULTILINE); @@ -136,7 +136,7 @@ public class TemplateResolver { } } final var content = new TemplateResolver(placeholder.toString(), properties).resolve(resolver); - final var value = intro != '#' ? propVal(content).toString() : content; + final var value = intro != '#' ? propVal(content) : content; resolved.append( PlaceholderPrefix.ofPrefixChar(intro).convert(value, resolver) ); @@ -150,12 +150,12 @@ public class TemplateResolver { } else if (nameExpression.contains(IF_NOT_FOUND_SYMBOL)) { final var parts = StringUtils.split(nameExpression, IF_NOT_FOUND_SYMBOL); return Arrays.stream(parts).filter(Objects::nonNull).findFirst().orElseGet(() -> { - if ( parts[parts.length-1].isEmpty() ) { - // => whole expression ends with IF_NOT_FOUND_SYMBOL, thus last null element was optional - return null; - } - // => last alternative element in expression was null and not optional - throw new IllegalStateException("Missing required value in property-chain: " + nameExpression); + if ( parts[parts.length-1].isEmpty() ) { + // => whole expression ends with IF_NOT_FOUND_SYMBOL, thus last null element was optional + return null; + } + // => last alternative element in expression was null and not optional + throw new IllegalStateException("Missing required value in property-chain: " + nameExpression); }); } else { final var val = properties.get(nameExpression); -- 2.39.5 From 6f702c82d54956d61e4962dcdf17a70e6f13a7b2 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 14 Nov 2024 17:16:34 +0100 Subject: [PATCH 30/38] revert convert Object->String, causes NPE problems --- .aliases | 4 ++-- build.gradle | 9 +++++---- doc/scenarios/README.txt | 1 + .../hsadminng/hs/office/scenarios/TestReport.java | 11 ++++++++--- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 doc/scenarios/README.txt diff --git a/.aliases b/.aliases index 55a53503..8f8fafc2 100644 --- a/.aliases +++ b/.aliases @@ -96,5 +96,5 @@ if [ ! -f .environment ]; then fi source .environment -alias scenario-reports-upload='./gradlew convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office' -alias scenario-reports-online='open https://hsngdev.hs-example.de/scenarios/office' +alias scenario-reports-upload='./gradlew scenarioTests convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm -f doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp build/doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office' +alias scenario-reports-open='open https://hsngdev.hs-example.de/scenarios/office' diff --git a/build.gradle b/build.gradle index c07888f5..2a33cacf 100644 --- a/build.gradle +++ b/build.gradle @@ -233,7 +233,7 @@ dependencyCheck { failBuildOnCVSS = 5 } project.tasks.check.dependsOn(dependencyCheckAnalyze) -project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.md! +project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.txt! println "OWASP Dependency Security Report: file:///${project.rootDir}/build/reports/dependency-check-report.html" } @@ -268,7 +268,7 @@ jacocoTestReport { ]) })) } - doFirst { // Why not doLast? See README.md! + doFirst { // Why not doLast? See README.txt! println "HTML Jacoco Test Code Coverage Report: file://${reports.html.outputLocation.get()}/index.html" } } @@ -381,7 +381,7 @@ pitest { timestampedReports = false } project.tasks.check.dependsOn(project.tasks.pitest) -project.tasks.pitest.doFirst { // Why not doLast? See README.md! +project.tasks.pitest.doFirst { // Why not doLast? See README.txt! println "PiTest Mutation Report: file:///${project.rootDir}/build/reports/pitest/index.html" } @@ -431,7 +431,7 @@ tasks.register('convertMarkdownToHtml') { doLast { // Gather all Markdown files in the current directory - fileTree(dir: '.', include: 'doc/scenarios/*.md').each { file -> + fileTree(dir: '.', include: 'build/doc/scenarios/*.md').each { file -> // Corrected way to create the output file path def outputFile = new File(file.parent, file.name.replaceAll(/\.md$/, '.html')) @@ -444,3 +444,4 @@ tasks.register('convertMarkdownToHtml') { } } } +convertMarkdownToHtml.dependsOn scenarioTests diff --git a/doc/scenarios/README.txt b/doc/scenarios/README.txt new file mode 100644 index 00000000..1f5c2b4b --- /dev/null +++ b/doc/scenarios/README.txt @@ -0,0 +1 @@ +move generated ScenarioReports to build-dir diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java index 007e4512..2baa3a62 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java @@ -19,7 +19,8 @@ import static org.assertj.core.api.Assertions.assertThat; public class TestReport { - private final static File markdownLogFile = new File("doc/scenarios/.last-debug-log.md"); + public static final File BUILD_DOC_SCENARIOS = new File("build/doc/scenarios"); + private final static File markdownLogFile = new File(BUILD_DOC_SCENARIOS, ".last-debug-log.md"); public static final SimpleDateFormat MM_DD_YYYY_HH_MM_SS = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss"); private final Map aliases; @@ -28,6 +29,11 @@ public class TestReport { private PrintWriter markdownReport; // records only the use-case under test, without its pre-requisites private int silent; // do not print anything to test-report if >0 + static { + assertThat(BUILD_DOC_SCENARIOS.isDirectory() || BUILD_DOC_SCENARIOS.mkdirs()) + .as("mkdir " + BUILD_DOC_SCENARIOS).isTrue(); + } + @SneakyThrows public TestReport(final Map aliases) { this.aliases = aliases; @@ -37,8 +43,7 @@ public class TestReport { public void createTestLogMarkdownFile(final TestInfo testInfo) throws IOException { final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow(); final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow(); - assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue(); - markdownReportFile = new File("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"); + markdownReportFile = new File(BUILD_DOC_SCENARIOS, testMethodOrder + "-" + testMethodName + ".md"); markdownReport = new PrintWriter(new FileWriter(markdownReportFile)); print("## Scenario #" + determineScenarioTitle(testInfo)); } -- 2.39.5 From 3fcff3b9c8f3d317ae26c381fe4a1afadd5dd539 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 09:18:08 +0100 Subject: [PATCH 31/38] catch exception when determining git branch --- .../hsadminng/hs/office/scenarios/TestReport.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java index 2baa3a62..ec6e0fd6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java @@ -121,8 +121,14 @@ public class TestReport { @SneakyThrows private String currentGitBranch() { - final var gitRevParse = new SystemProcess("git", "rev-parse", "--abbrev-ref", "HEAD"); - gitRevParse.execute(); - return gitRevParse.getStdOut().split("\\R", 2)[0]; + try { + final var gitRevParse = new SystemProcess("git", "rev-parse", "--abbrev-ref", "HEAD"); + gitRevParse.execute(); + return gitRevParse.getStdOut().split("\\R", 2)[0]; + } catch (final IOException exc) { + // TODO.test: the git call does not work in Jenkins, we have to find out why + System.err.println(exc); + return "unknown"; + } } } -- 2.39.5 From 17825e73565927372598b52405601745d8c4797c Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 09:38:27 +0100 Subject: [PATCH 32/38] revert accidantally renamed README.md --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 2a33cacf..04edf341 100644 --- a/build.gradle +++ b/build.gradle @@ -233,7 +233,7 @@ dependencyCheck { failBuildOnCVSS = 5 } project.tasks.check.dependsOn(dependencyCheckAnalyze) -project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.txt! +project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.md! println "OWASP Dependency Security Report: file:///${project.rootDir}/build/reports/dependency-check-report.html" } @@ -268,7 +268,7 @@ jacocoTestReport { ]) })) } - doFirst { // Why not doLast? See README.txt! + doFirst { // Why not doLast? See README.md! println "HTML Jacoco Test Code Coverage Report: file://${reports.html.outputLocation.get()}/index.html" } } @@ -381,7 +381,7 @@ pitest { timestampedReports = false } project.tasks.check.dependsOn(project.tasks.pitest) -project.tasks.pitest.doFirst { // Why not doLast? See README.txt! +project.tasks.pitest.doFirst { // Why not doLast? See README.md! println "PiTest Mutation Report: file:///${project.rootDir}/build/reports/pitest/index.html" } -- 2.39.5 From 92e675b642a54de1cc945809998592471c034877 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 09:51:04 +0100 Subject: [PATCH 33/38] improves the Business-Glossary --- doc/business-glossary-de.md | 84 ++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 25 deletions(-) diff --git a/doc/business-glossary-de.md b/doc/business-glossary-de.md index 4ab2d60a..65d316a1 100644 --- a/doc/business-glossary-de.md +++ b/doc/business-glossary-de.md @@ -26,12 +26,6 @@ und zeitlich nacheinander mehrere [Mitgliedschaften](#Mitgliedschaft) geben. Partner sind grundsätzlich als ist [Relation](#Relation) der Vertragsperson mit der Person _Hostsharing eG_ implementiert. -#### Ex-Partner - -Ex-Partner bilden [Personen](#Person) ab, die vormals [Partner](#Partner) waren. -Diese bleiben dadurch dem System - - ### Debitor Ein `Debitor` ist quasi ein Rechnungsempfänger für einen [Partner](#Partner). @@ -42,35 +36,75 @@ z.B. für spezielle Projekte des Kunden oder verbundene Organisationen. Des Weiteren gibt es für jeden _Partner_ eine fünfstellige Partnernummer mit dem Prefix 'P-' (z.B. `P-123454`) sowie Zusatzinformationen (z.B. Registergerichtsnummer oder Geburtsdatum), die zur genauen Identifikation benötigt werden. - - Debitoren sind grundsätzlich als ist [Relation](#Relation) der Vertragsperson mit der Person des Vertragspartners implementiert. -#### Representative (ehemals _contractual_) +#### Relation -Ein _Representative_ ist eine natürliche Person, die für eine nicht-natürliche Person vertretungsberechtigt ist. +Eine _Relation_ ist eine typisierte und mit Kontaktdaten versehene Beziehung einer (_Holder_)-Person zu einer _Anchor_-Person. -Implementiert ist der _Representative_ als eine besondere Form der [Relation](#Relation) des - - - 'VIP_CONTACT', - 'OPERATIONS', - 'SUBSCRIBER'); - - -#### Relation (so eine Art Geschäftsrolle) - -Eine _Relation_ ist eine Beziehung - -Wir haben hier keinen Begriff mit 'Rolle' verwendet, +Eine Relation ist eine Art Geschäftsrolle, wir haben hier aber keinen Begriff mit 'Rolle' verwendet, weil 'Role' (engl.) zu leicht mit der [RBAC-Rolle](#RBAC-Role) verwechselt werden könnte. Die _Relation_ ist auch ein technisches Konzept und gehört nicht zur Domänensprache. Dieses Konzept ist jedoch für das Verständnis der ([API](#API)) notwendig. -#### Anker + +#### Ex-Partner + +Ex-Partner bilden [Personen](#Person) ab, die vormals [Partner](#Partner) waren. +Diese bleiben dadurch informationshalber im System verfügbar. + +Implementiert ist der _Ex-Partner_ als eine besondere Form der [Relation](#Relation) +der Person des Ex-Partner (_Holder_) zum neuen Partner (_Anchor_) dargestellt. +Dieses kann zu einer Kettenbildung führen. -#### API (Application-Programming-Interface) +#### Representative-Contact (ehemals _contractual_) +Ein _Representative_ ist eine natürliche Person, die für eine nicht-natürliche Person vertretungsberechtigt ist. + +Implementiert ist der _Representative_ als eine besondere Form der [Relation](#Relation) +der Person des Repräsentanten (_Holder_) zur repräsentierten Person (_Anchor_) dargestellt. + + +### VIP-Contact + +Ein _VIP-Contact_ ist eine natürliche Person, die für einen Geschäftspartner eine wichtige Funktion übernimmt, +nicht aber deren offizieller Repräsentant ist. + +Implementiert ist der _VIP-Contact_ als eine besondere Form der [Relation](#Relation) +der Person des VIP-Contact (_Holder_) zur repräsentierten Person (_Anchor_) dargestellt. + + +### Operations-Contact + +Ein _Operations-_Contact_ ist_ eine natürliche Person, die für einen Geschäftspartner technischer Ansprechpartner ist + +Implementiert ist der _Operations-Contact_ als eine besondere Form der [Relation](#Relation) +der Person des _Operations-Contact_ (_Holder_) zur repräsentierten Person (_Anchor_) dargestellt. + + +### Subscriber-Contact + +Ein _Subscriber-_Contact_ ist_ eine natürliche Person, die für einen Geschäftspartner eine bestimmte Mailingliste abonniert. + +Implementiert ist der _Subscriber-Contact_ als eine besondere Form der [Relation](#Relation) +der Person des _Subscriber-Contact_ (_Holder_) zur repräsentierten Person (_Anchor_) dargestellt. +Zusätzlich wird diese Relation mit dem Kurznamen der abonnierten Mailingliste markiert. + + +#### Anchor / Relation-Anchor + +siehe [Relation](#Relation) + + +#### Holder / Relation-Holder + +siehe [Relation](#Relation) + + +#### API + +Und API (Application-Programming-Interface) verstehen wir eine über HTTPS angesprochene programmatisch bedienbare Schnittstell +zur Funktionalität des hsAdmin-NG-Systems. -- 2.39.5 From 82f1c57722fefa3e39808c3fccac037a5d8a3f05 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 09:51:54 +0100 Subject: [PATCH 34/38] find the generated ScenarioReports in build/doc/scenarios --- doc/scenarios/README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/scenarios/README.txt b/doc/scenarios/README.txt index 1f5c2b4b..bcba4110 100644 --- a/doc/scenarios/README.txt +++ b/doc/scenarios/README.txt @@ -1 +1 @@ -move generated ScenarioReports to build-dir +find the generated ScenarioReports in build/doc/scenarios -- 2.39.5 From a87acaacec791669429e0def1ec1f0e461c91f9e Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 09:55:01 +0100 Subject: [PATCH 35/38] Streamline controller method naming leaned to HTTP verbs --- .../coopassets/HsOfficeCoopAssetsTransactionController.java | 6 +++--- .../coopshares/HsOfficeCoopSharesTransactionController.java | 2 +- .../hs-office/hs-office-coopassets-with-uuid.yaml | 2 +- .../api-definition/hs-office/hs-office-coopassets.yaml | 4 ++-- .../hs-office/hs-office-coopshares-with-uuid.yaml | 2 +- ...OfficeCoopAssetsTransactionControllerAcceptanceTest.java | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index 4ab26f49..3fec8397 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -36,7 +36,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) - public ResponseEntity> listCoopAssets( + public ResponseEntity> getListOfCoopAssets( final String currentSubject, final String assumedRoles, final UUID membershipUuid, @@ -55,7 +55,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional - public ResponseEntity addCoopAssetsTransaction( + public ResponseEntity postNewCoopAssetTransaction( final String currentSubject, final String assumedRoles, final HsOfficeCoopAssetsTransactionInsertResource requestBody) { @@ -77,7 +77,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) - public ResponseEntity getCoopAssetTransactionByUuid( + public ResponseEntity geSingleCoopAssetTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) { context.define(currentSubject, assumedRoles); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java index c8a9241e..8cd3d9a9 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java @@ -80,7 +80,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) - public ResponseEntity geSingletCoopShareTransactionByUuid( + public ResponseEntity geSingleCoopShareTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) { context.define(currentSubject, assumedRoles); diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopassets-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopassets-with-uuid.yaml index 51d51c2c..7d1fb349 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopassets-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopassets-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-coopAssets description: 'Fetch a single asset transaction by its uuid, if visible for the current subject.' - operationId: getCoopAssetTransactionByUuid + operationId: geSingleCoopAssetTransactionByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopassets.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopassets.yaml index bff3e1d5..55880595 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopassets.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopassets.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) cooperative asset transactions which are visible to the current subject or any of it's assumed roles. tags: - hs-office-coopAssets - operationId: listCoopAssets + operationId: getListOfCoopAssets parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -46,7 +46,7 @@ post: summary: Adds a new cooperative asset transaction. tags: - hs-office-coopAssets - operationId: addCoopAssetsTransaction + operationId: postNewCoopAssetTransaction parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml index 87d3da86..4265f3ca 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-coopShares description: 'Fetch a single share transaction by its uuid, if visible for the current subject.' - operationId: geSingletCoopShareTransactionByUuid + operationId: geSingleCoopShareTransactionByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java index 0caafbab..d5785ffa 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java @@ -55,7 +55,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased EntityManager em; @Nested - class ListCoopAssetsTransactions { + class GetListOfCoopAssetsTransactions { @Test void globalAdmin_canViewAllCoopAssetsTransactions() { @@ -166,10 +166,10 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBased } @Nested - class AddCoopAssetsTransaction { + class PostNewCoopAssetTransaction { @Test - void globalAdmin_canAddCoopAssetsTransaction() { + void globalAdmin_canPostNewCoopAssetTransaction() { context.define("superuser-alex@hostsharing.net"); final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101); -- 2.39.5 From 0342ec0f50cba8dd37e4db43032bf558c9b30afc Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 10:37:06 +0100 Subject: [PATCH 36/38] amendments according to code-review --- .../coopassets/HsOfficeCoopAssetsTransactionController.java | 2 +- .../coopshares/HsOfficeCoopSharesTransactionController.java | 2 +- .../hs-office/hs-office-coopassets-with-uuid.yaml | 2 +- .../hs-office/hs-office-coopshares-with-uuid.yaml | 2 +- .../hsadminng/hs/office/scenarios/TemplateResolver.java | 2 +- src/test/resources/migration/office/asset_transactions.csv | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index 3fec8397..06bec54e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -77,7 +77,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) - public ResponseEntity geSingleCoopAssetTransactionByUuid( + public ResponseEntity getSingleCoopAssetTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) { context.define(currentSubject, assumedRoles); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java index 8cd3d9a9..ebd47800 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java @@ -80,7 +80,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) - public ResponseEntity geSingleCoopShareTransactionByUuid( + public ResponseEntity getSingleCoopShareTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) { context.define(currentSubject, assumedRoles); diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopassets-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopassets-with-uuid.yaml index 7d1fb349..4361e54f 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopassets-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopassets-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-coopAssets description: 'Fetch a single asset transaction by its uuid, if visible for the current subject.' - operationId: geSingleCoopAssetTransactionByUuid + operationId: getSingleCoopAssetTransactionByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml index 4265f3ca..b8d6177e 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-coopshares-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-coopShares description: 'Fetch a single share transaction by its uuid, if visible for the current subject.' - operationId: geSingleCoopShareTransactionByUuid + operationId: getSingleCoopShareTransactionByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java index 977c2f13..14fdcbc8 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java @@ -16,7 +16,7 @@ public class TemplateResolver { public enum Resolver { DROP_COMMENTS, // deletes comments ('#{whatever}' -> '') - KEEP_COMMENTS // deletes comments ('#{whatever}' -> '') + KEEP_COMMENTS // keep comments ('#{whatever}' -> 'whatever') } enum PlaceholderPrefix { diff --git a/src/test/resources/migration/office/asset_transactions.csv b/src/test/resources/migration/office/asset_transactions.csv index d4f69478..a0a83e02 100644 --- a/src/test/resources/migration/office/asset_transactions.csv +++ b/src/test/resources/migration/office/asset_transactions.csv @@ -16,4 +16,4 @@ member_asset_id; bp_id; date; action; amount; comment 34002; 120; 2016-12-31; PAYBACK; -100.00; for cancellation D 34003; 120; 2016-12-31; LOSS; -20.00; for cancellation D 35001; 190; 2024-01-15; PAYMENT; 128.00; for subscription E -35002; 190; 2024-01-20; REVERSAL;-128.00; chargeback for subscription E +35002; 190; 2024-01-20; ADJUSTMENT;-128.00; chargeback for subscription E -- 2.39.5 From eca01a2f9b2bdc06cb3161675dbd25fb036539cd Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 10:47:48 +0100 Subject: [PATCH 37/38] amendments according to code-review --- .../hsadminng/hs/migration/BaseOfficeDataImport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java index 2c8dfe82..0bdf47da 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -837,7 +837,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { final var assetTypeMapping = new HashMap() { { - put("REVERSAL", HsOfficeCoopAssetsTransactionType.REVERSAL); + put("ADJUSTMENT", HsOfficeCoopAssetsTransactionType.REVERSAL); put("HANDOVER", HsOfficeCoopAssetsTransactionType.TRANSFER); put("ADOPTION", HsOfficeCoopAssetsTransactionType.ADOPTION); put("LOSS", HsOfficeCoopAssetsTransactionType.LOSS); -- 2.39.5 From 054bff4355eef0538f52595a059a1cd59ddb84ca Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 11:34:23 +0100 Subject: [PATCH 38/38] amendments according to code-review - COMMA_RIGHT_BEFORE_CLOSING_BRACE --- .../hsadminng/hs/office/scenarios/TemplateResolver.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java index 14fdcbc8..002d0512 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TemplateResolver.java @@ -62,7 +62,7 @@ public class TemplateResolver { abstract String convert(final Object value, final Resolver resolver); } - private final static Pattern pattern = Pattern.compile(",(\\s*})", Pattern.MULTILINE); + private static final Pattern COMMA_RIGHT_BEFORE_CLOSING_BRACE = Pattern.compile(",(\\s*})", Pattern.MULTILINE); private static final String IF_NOT_FOUND_SYMBOL = "???"; private final String template; @@ -86,7 +86,7 @@ public class TemplateResolver { } private static String removeDanglingCommas(final String withoutDroppedLines) { - return pattern.matcher(withoutDroppedLines).replaceAll("$1"); + return COMMA_RIGHT_BEFORE_CLOSING_BRACE.matcher(withoutDroppedLines).replaceAll("$1"); } private String dropLinesWithNullProperties(final String text) { -- 2.39.5