From b6fa9606ac18d04732e4612c956964eb026f59c5 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 12:42:01 +0100 Subject: [PATCH 01/10] move all API files into resources/api-definition --- build.gradle | 4 ++-- src/main/resources/{ => api-definition}/api-definition.yaml | 0 src/main/resources/{ => api-definition}/api-mappings.yaml | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/main/resources/{ => api-definition}/api-definition.yaml (100%) rename src/main/resources/{ => api-definition}/api-mappings.yaml (100%) diff --git a/build.gradle b/build.gradle index 04edf341..876ff878 100644 --- a/build.gradle +++ b/build.gradle @@ -118,8 +118,8 @@ openapiProcessor { springRoot { processorName 'spring' processor 'io.openapiprocessor:openapi-processor-spring:2022.5' - apiPath "$projectDir/src/main/resources/api-definition.yaml" - mapping "$projectDir/src/main/resources/api-mappings.yaml" + apiPath "$projectDir/src/main/resources/api-definition/api-definition.yaml" + mapping "$projectDir/src/main/resources/api-definition/api-mappings.yaml" targetDir "$buildDir/generated/sources/openapi-javax" showWarnings true openApiNullable true diff --git a/src/main/resources/api-definition.yaml b/src/main/resources/api-definition/api-definition.yaml similarity index 100% rename from src/main/resources/api-definition.yaml rename to src/main/resources/api-definition/api-definition.yaml diff --git a/src/main/resources/api-mappings.yaml b/src/main/resources/api-definition/api-mappings.yaml similarity index 100% rename from src/main/resources/api-mappings.yaml rename to src/main/resources/api-definition/api-mappings.yaml -- 2.39.5 From d644e9aef206ac483ea969cc6c380063d5298dce Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 13:46:42 +0100 Subject: [PATCH 02/10] add P- tag to partnerNumber in API --- doc/hs-office-data-structure.md | 2 +- .../debitor/HsBookingDebitorEntity.java | 6 ++--- .../hs/booking/item/HsBookingItem.java | 6 ++--- .../hs/booking/project/HsBookingProject.java | 6 ++--- .../hs/hosting/asset/HsHostingAsset.java | 6 ++--- .../HsOfficeBankAccountEntity.java | 6 ++--- .../hs/office/contact/HsOfficeContact.java | 6 ++--- .../HsOfficeCoopAssetsTransactionEntity.java | 6 ++--- .../HsOfficeCoopSharesTransactionEntity.java | 6 ++--- .../office/debitor/HsOfficeDebitorEntity.java | 6 ++--- .../membership/HsOfficeMembershipEntity.java | 6 ++--- .../partner/HsOfficePartnerController.java | 3 ++- .../partner/HsOfficePartnerDetailsEntity.java | 6 ++--- .../office/partner/HsOfficePartnerEntity.java | 6 ++--- .../office/person/HsOfficePersonEntity.java | 6 ++--- .../hs/office/relation/HsOfficeRelation.java | 6 ++--- .../HsOfficeSepaMandateEntity.java | 6 ++--- .../{stringify => repr}/Stringify.java | 2 +- .../{stringify => repr}/Stringifyable.java | 2 +- .../hsadminng/repr/TaggedNumber.java | 15 ++++++++++++ .../hs-office/hs-office-partner-schemas.yaml | 16 ++++++------- ...OfficePartnerControllerAcceptanceTest.java | 24 +++++++++---------- .../HsOfficePartnerControllerRestTest.java | 4 ++-- .../scenarios/HsOfficeScenarioTests.java | 6 ++--- .../rbac/test/StringifyUnitTest.java | 6 ++--- .../hsadminng/repr/TaggedNumberUnitTest.java | 22 +++++++++++++++++ 26 files changed, 115 insertions(+), 77 deletions(-) rename src/main/java/net/hostsharing/hsadminng/{stringify => repr}/Stringify.java (99%) rename src/main/java/net/hostsharing/hsadminng/{stringify => repr}/Stringifyable.java (59%) create mode 100644 src/main/java/net/hostsharing/hsadminng/repr/TaggedNumber.java create mode 100644 src/test/java/net/hostsharing/hsadminng/repr/TaggedNumberUnitTest.java diff --git a/doc/hs-office-data-structure.md b/doc/hs-office-data-structure.md index b84264d0..cce17510 100644 --- a/doc/hs-office-data-structure.md +++ b/doc/hs-office-data-structure.md @@ -64,7 +64,7 @@ classDiagram } class partner-MeierGmbH { - +Numeric partnerNumber: 12345 + +Numeric partnerNumber: P-12345 +Relation partnerRel } partner-MeierGmbH *-- rel-MeierGmbH diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorEntity.java index 69932d5b..a09a33bc 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorEntity.java @@ -5,8 +5,8 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import net.hostsharing.hsadminng.errors.DisplayAs; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -14,7 +14,7 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import java.util.UUID; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; // a partial HsOfficeDebitorEntity to reduce the number of SQL queries to load the entity @Entity diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItem.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItem.java index 07d85007..2d63df74 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItem.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItem.java @@ -15,8 +15,8 @@ import net.hostsharing.hsadminng.hs.booking.project.HsBookingProjectRealEntity; import net.hostsharing.hsadminng.hs.validation.PropertiesProvider; import net.hostsharing.hsadminng.mapper.PatchableMapWrapper; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.Type; import jakarta.persistence.CascadeType; @@ -45,7 +45,7 @@ import static java.util.Optional.ofNullable; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.lowerInclusiveFromPostgresDateRange; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.upperInclusiveFromPostgresDateRange; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @MappedSuperclass @Getter diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProject.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProject.java index 742cf88f..90235732 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProject.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProject.java @@ -4,14 +4,14 @@ import lombok.*; import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.hs.booking.debitor.HsBookingDebitorEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import jakarta.persistence.*; import java.util.UUID; import static java.util.Optional.ofNullable; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @MappedSuperclass @Getter diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAsset.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAsset.java index e89e962f..d327f354 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAsset.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAsset.java @@ -15,8 +15,8 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; import net.hostsharing.hsadminng.hs.validation.PropertiesProvider; import net.hostsharing.hsadminng.mapper.PatchableMapWrapper; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.Type; import jakarta.persistence.CascadeType; @@ -42,7 +42,7 @@ import java.util.Optional; import java.util.UUID; import static java.util.Collections.emptyMap; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @MappedSuperclass @Getter diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java index 5be09962..edc26010 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountEntity.java @@ -5,8 +5,8 @@ import lombok.experimental.FieldNameConstants; import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import jakarta.persistence.*; import java.io.IOException; @@ -16,7 +16,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @Table(schema = "hs_office", name = "bankaccount_rv") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContact.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContact.java index a4267f53..dc5bca3e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContact.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContact.java @@ -12,8 +12,8 @@ import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.mapper.PatchableMapWrapper; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Type; @@ -27,7 +27,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @MappedSuperclass @Getter 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 18e12a11..cc2e504b 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 @@ -10,8 +10,8 @@ import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.GenericGenerator; import jakarta.persistence.*; @@ -31,7 +31,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.ADMIN; import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.AGENT; import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @Table(schema = "hs_office", name = "coopassettx_rv") 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 54787ad7..b5329cea 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 @@ -10,8 +10,8 @@ import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import jakarta.persistence.*; import java.io.IOException; @@ -29,7 +29,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.ADMIN; import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.AGENT; import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @Table(schema = "hs_office", name = "coopsharetx_rv") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java index 2c339605..e7e25ea9 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java @@ -14,8 +14,8 @@ import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.JoinFormula; import org.hibernate.annotations.NotFound; @@ -51,7 +51,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.fetchedBySql; import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @Table(schema = "hs_office", name = "debitor_rv") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java index 893623d7..a0740b8b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java @@ -13,8 +13,8 @@ import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.Type; import jakarta.persistence.Column; @@ -53,7 +53,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.OWNER; import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.TENANT; import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.fetchedBySql; import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @Table(schema = "hs_office", name = "membership_rv") 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 1aefafa2..c39dcd49 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 @@ -27,6 +27,7 @@ import java.util.List; import java.util.UUID; import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.EX_PARTNER; +import static net.hostsharing.hsadminng.repr.TaggedNumber.cropTag; @RestController @@ -150,7 +151,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { private HsOfficePartnerEntity createPartnerEntity(final HsOfficePartnerInsertResource body) { final var entityToSave = new HsOfficePartnerEntity(); - entityToSave.setPartnerNumber(body.getPartnerNumber()); + entityToSave.setPartnerNumber(cropTag(HsOfficePartnerEntity.PARTNER_NUMBER_TAG, body.getPartnerNumber())); entityToSave.setPartnerRel(persistPartnerRel(body.getPartnerRel())); entityToSave.setDetails(mapper.map(body.getDetails(), HsOfficePartnerDetailsEntity.class)); return entityToSave; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntity.java index e6e43996..ca8c391b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntity.java @@ -5,8 +5,8 @@ import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import jakarta.persistence.*; import java.io.IOException; @@ -17,7 +17,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @Table(schema = "hs_office", name = "partner_details_rv") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java index b91f3ab1..f7de08c8 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java @@ -14,8 +14,8 @@ import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation; import net.hostsharing.hsadminng.rbac.generator.RbacView; import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; @@ -33,7 +33,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.directlyFetchedByDependsOnColumn; import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; import static java.util.Optional.ofNullable; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @Table(schema = "hs_office", name = "partner_rv") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java index f28bd4ab..da14e1c4 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java @@ -6,8 +6,8 @@ import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.apache.commons.lang3.StringUtils; import jakarta.persistence.*; @@ -19,7 +19,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; // TODO.refa: split HsOfficePersonEntity into Real+Rbac-Entity @Entity diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelation.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelation.java index 2a4fbd42..c1b4ad8c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelation.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelation.java @@ -6,14 +6,14 @@ import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import jakarta.persistence.*; import jakarta.persistence.Column; import java.util.UUID; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @MappedSuperclass @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java index f781212e..94ac21e2 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateEntity.java @@ -9,8 +9,8 @@ import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.Type; import jakarta.persistence.*; @@ -30,7 +30,7 @@ import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectRefer import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.SQL.*; import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; @Entity @Table(schema = "hs_office", name = "sepamandate_rv") diff --git a/src/main/java/net/hostsharing/hsadminng/stringify/Stringify.java b/src/main/java/net/hostsharing/hsadminng/repr/Stringify.java similarity index 99% rename from src/main/java/net/hostsharing/hsadminng/stringify/Stringify.java rename to src/main/java/net/hostsharing/hsadminng/repr/Stringify.java index 269b0c69..aaa3ea73 100644 --- a/src/main/java/net/hostsharing/hsadminng/stringify/Stringify.java +++ b/src/main/java/net/hostsharing/hsadminng/repr/Stringify.java @@ -1,4 +1,4 @@ -package net.hostsharing.hsadminng.stringify; +package net.hostsharing.hsadminng.repr; import net.hostsharing.hsadminng.errors.DisplayAs; diff --git a/src/main/java/net/hostsharing/hsadminng/stringify/Stringifyable.java b/src/main/java/net/hostsharing/hsadminng/repr/Stringifyable.java similarity index 59% rename from src/main/java/net/hostsharing/hsadminng/stringify/Stringifyable.java rename to src/main/java/net/hostsharing/hsadminng/repr/Stringifyable.java index 70877dc9..397a6c2b 100644 --- a/src/main/java/net/hostsharing/hsadminng/stringify/Stringifyable.java +++ b/src/main/java/net/hostsharing/hsadminng/repr/Stringifyable.java @@ -1,4 +1,4 @@ -package net.hostsharing.hsadminng.stringify; +package net.hostsharing.hsadminng.repr; public interface Stringifyable { diff --git a/src/main/java/net/hostsharing/hsadminng/repr/TaggedNumber.java b/src/main/java/net/hostsharing/hsadminng/repr/TaggedNumber.java new file mode 100644 index 00000000..ab445ec0 --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/repr/TaggedNumber.java @@ -0,0 +1,15 @@ +package net.hostsharing.hsadminng.repr; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class TaggedNumber { + + public static Integer cropTag(final String tag, final String taggedNumber) { + return taggedNumber.startsWith(tag) ? Integer.valueOf(taggedNumber.substring(tag.length())) : invalidTag(tag, taggedNumber); + } + + private static Integer invalidTag(final String tag, final String taggedNumber) { + throw new IllegalArgumentException("Expected " + tag + "... but got: " + taggedNumber); + } +} 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 bd327e10..2fd3d39b 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 @@ -10,10 +10,10 @@ components: type: string format: uuid partnerNumber: - type: integer - format: int8 - minimum: 10000 - maximum: 99999 + type: string + minLength: 7 + maxLength: 7 + pattern: 'P-[0-9]{5}' partnerRel: $ref: 'hs-office-relation-schemas.yaml#/components/schemas/HsOfficeRelation' details: @@ -86,10 +86,10 @@ components: type: object properties: partnerNumber: - type: integer - format: int8 - minimum: 10000 - maximum: 99999 + type: string + minLength: 7 + maxLength: 7 + pattern: 'P-[0-9]{5}' partnerRel: $ref: '#/components/schemas/HsOfficePartnerRelInsert' details: 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 c2ec1271..9f2f3318 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 @@ -71,11 +71,11 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType("application/json") .body("", lenientlyEquals(""" [ - { partnerNumber: 10001 }, - { partnerNumber: 10002 }, - { partnerNumber: 10003 }, - { partnerNumber: 10004 }, - { partnerNumber: 10010 } + { partnerNumber: "P-10001" }, + { partnerNumber: "P-10002" }, + { partnerNumber: "P-10003" }, + { partnerNumber: "P-10004" }, + { partnerNumber: "P-10010" } ] """)); // @formatter:on @@ -100,7 +100,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body(""" { - "partnerNumber": "20002", + "partnerNumber": "P-20002", "partnerRel": { "anchor.uuid": "%s", "holder.uuid": "%s", @@ -123,7 +123,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body("", lenientlyEquals(""" { - "partnerNumber": 20002, + "partnerNumber": "P-20002", "partnerRel": { "anchor": { "tradeName": "Hostsharing eG" }, "holder": { "tradeName": "Third OHG" }, @@ -159,7 +159,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body(""" { - "partnerNumber": "20003", + "partnerNumber": "P-20003", "partnerRel": { "anchor.uuid": "%s", "holder.uuid": "%s", @@ -197,7 +197,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body(""" { - "partnerNumber": "20004", + "partnerNumber": "P-20004", "partnerRel": { "anchor.uuid": "%s", "holder.uuid": "%s", @@ -247,7 +247,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType("application/json") .body("", lenientlyEquals(""" { - "partnerNumber": 10001, + "partnerNumber": "P-10001", "partnerRel": { "anchor": { "tradeName": "Hostsharing eG" }, "holder": { "tradeName": "First GmbH" }, @@ -320,7 +320,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body(""" { - "partnerNumber": "20011", + "partnerNumber": "P-20011", "partnerRel.uuid": "%s", "details": { "registrationOffice": "Temp Registergericht Aurich", @@ -339,7 +339,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType(ContentType.JSON) .body("", lenientlyEquals(""" { - "partnerNumber": 20011, + "partnerNumber": "P-20011", "partnerRel": { "anchor": { "tradeName": "Hostsharing eG" }, "holder": { "tradeName": "Third OHG" }, 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 889e776f..74270f69 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 @@ -99,7 +99,7 @@ class HsOfficePartnerControllerRestTest { .contentType(MediaType.APPLICATION_JSON) .content(""" { - "partnerNumber": "20002", + "partnerNumber": "P-20002", "partnerRel": { "anchor.uuid": "%s", "holder.uuid": "%s", @@ -136,7 +136,7 @@ class HsOfficePartnerControllerRestTest { .contentType(MediaType.APPLICATION_JSON) .content(""" { - "partnerNumber": "20002", + "partnerNumber": "P-20002", "partnerRel": { "anchor.uuid": "%s", "holder.uuid": "%s", 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 13af695b..ab5419ae 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 @@ -58,7 +58,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces(explicitly = "Partner: P-31010 - Test AG", implicitly = {"Person: Test AG", "Contact: Test AG - Hamburg"}) void shouldCreateLegalPersonAsPartner() { new CreatePartner(this) - .given("partnerNumber", 31010) + .given("partnerNumber", "P-31010") .given("personType", "LEGAL_PERSON") .given("tradeName", "Test AG") .given("contactCaption", "Test AG - Hamburg") @@ -80,7 +80,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces(explicitly = "Partner: P-31011 - Michelle Matthieu", implicitly = {"Person: Michelle Matthieu", "Contact: Michelle Matthieu"}) void shouldCreateNaturalPersonAsPartner() { new CreatePartner(this) - .given("partnerNumber", 31011) + .given("partnerNumber", "P-31011") .given("personType", "NATURAL_PERSON") .given("givenName", "Michelle") .given("familyName", "Matthieu") @@ -148,7 +148,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Order(1090) void shouldDeletePartner() { new DeletePartner(this) - .given("partnerNumber", 31020) + .given("partnerNumber", "P-31020") .doRun(); } diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/test/StringifyUnitTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/test/StringifyUnitTest.java index 0267871f..1d22056d 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/test/StringifyUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/test/StringifyUnitTest.java @@ -2,13 +2,13 @@ package net.hostsharing.hsadminng.rbac.test; import lombok.*; import lombok.experimental.FieldNameConstants; -import net.hostsharing.hsadminng.stringify.Stringify; -import net.hostsharing.hsadminng.stringify.Stringifyable; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; import org.junit.jupiter.api.Test; import java.util.UUID; -import static net.hostsharing.hsadminng.stringify.Stringify.stringify; +import static net.hostsharing.hsadminng.repr.Stringify.stringify; import static org.assertj.core.api.Assertions.assertThat; class StringifyUnitTest { diff --git a/src/test/java/net/hostsharing/hsadminng/repr/TaggedNumberUnitTest.java b/src/test/java/net/hostsharing/hsadminng/repr/TaggedNumberUnitTest.java new file mode 100644 index 00000000..ca373f38 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/repr/TaggedNumberUnitTest.java @@ -0,0 +1,22 @@ +package net.hostsharing.hsadminng.repr; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; + +class TaggedNumberUnitTest { + + @Test + void cropsProperTag() { + assertThat(TaggedNumber.cropTag("P-", "P-12345")).isEqualTo(12345); + } + + @Test + void throwsExceptionForImproperTag() { + final var exception = catchThrowable(() -> TaggedNumber.cropTag("P-", "X-12345")); + assertThat(exception).isInstanceOf(IllegalArgumentException.class); + assertThat(exception.getMessage()).isEqualTo("Expected P-... but got: X-12345"); + } + +} -- 2.39.5 From 89f57f75be4683233951ceee0d25b7556d8e2029 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 14:05:04 +0100 Subject: [PATCH 03/10] add P- in dependent tests --- ...sOfficeDebitorControllerAcceptanceTest.java | 12 ++++++------ ...ficeMembershipControllerAcceptanceTest.java | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) 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 f6623fe0..82f6cdf0 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 @@ -113,7 +113,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu "debitorNumber": 1000111, "debitorNumberSuffix": "11", "partner": { - "partnerNumber": 10001, + "partnerNumber": "P-10001", "partnerRel": { "anchor": { "personType": "LEGAL_PERSON", @@ -168,7 +168,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu "debitorNumber": 1000212, "debitorNumberSuffix": "12", "partner": { - "partnerNumber": 10002, + "partnerNumber": "P-10002", "partnerRel": { "anchor": {"tradeName": "Hostsharing eG"}, "holder": {"tradeName": "Second e.K."}, @@ -202,7 +202,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu "debitorNumber": 1000313, "debitorNumberSuffix": "13", "partner": { - "partnerNumber": 10003, + "partnerNumber": "P-10003", "partnerRel": { "anchor": {"tradeName": "Hostsharing eG"}, "holder": {"tradeName": "Third OHG"}, @@ -245,7 +245,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu [ { "debitorNumber": 1000212, - "partner": { "partnerNumber": 10002 }, + "partner": { "partnerNumber": "P-10002" }, "debitorRel": { "contact": { "caption": "second contact" } }, @@ -535,7 +535,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu .body("", lenientlyEquals(""" { "debitorNumber": 1000111, - "partner": { "partnerNumber": 10001 }, + "partner": { "partnerNumber": "P-10001" }, "debitorRel": { "contact": { "caption": "first contact" } }, "refundBankAccount": null } @@ -584,7 +584,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu "debitorNumber": 10004${debitorNumberSuffix}, "debitorNumberSuffix": "${debitorNumberSuffix}", "partner": { - "partnerNumber": 10004, + "partnerNumber": "P-10004", "partnerRel": { "anchor": { "tradeName": "Hostsharing eG" }, "holder": { "tradeName": "Fourth eG" }, 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 f3793da1..33073956 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 @@ -77,7 +77,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .body("", lenientlyEquals(""" [ { - "partner": { "partnerNumber": 10001 }, + "partner": { "partnerNumber": "P-10001" }, "memberNumber": 1000101, "memberNumberSuffix": "01", "validFrom": "2022-10-01", @@ -85,7 +85,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle "status": "ACTIVE" }, { - "partner": { "partnerNumber": 10002 }, + "partner": { "partnerNumber": "P-10002" }, "memberNumber": 1000202, "memberNumberSuffix": "02", "validFrom": "2022-10-01", @@ -93,7 +93,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle "status": "ACTIVE" }, { - "partner": { "partnerNumber": 10003 }, + "partner": { "partnerNumber": "P-10003" }, "memberNumber": 1000303, "memberNumberSuffix": "03", "validFrom": "2022-10-01", @@ -124,7 +124,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .body("", lenientlyEquals(""" [ { - "partner": { "partnerNumber": 10001 }, + "partner": { "partnerNumber": "P-10001" }, "memberNumber": 1000101, "memberNumberSuffix": "01", "validFrom": "2022-10-01", @@ -152,7 +152,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .body("", lenientlyEquals(""" [ { - "partner": { "partnerNumber": 10002 }, + "partner": { "partnerNumber": "P-10002" }, "memberNumber": 1000202, "memberNumberSuffix": "02", "validFrom": "2022-10-01", @@ -195,7 +195,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .statusCode(201) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("partner.partnerNumber", is(10003)) + .body("partner.partnerNumber", is("P-10003")) .body("memberNumber", is(expectedMemberNumber)) .body("memberNumberSuffix", is(givenMemberSuffix)) .body("validFrom", is("2022-10-13")) @@ -230,7 +230,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .contentType("application/json") .body("", lenientlyEquals(""" { - "partner": { "partnerNumber": 10001 }, + "partner": { "partnerNumber": "P-10001" }, "memberNumber": 1000101, "memberNumberSuffix": "01", "validFrom": "2022-10-01", @@ -272,7 +272,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .contentType("application/json") .body("", lenientlyEquals(""" { - "partner": { "partnerNumber": 10003 }, + "partner": { "partnerNumber": "P-10003" }, "memberNumber": 1000303, "memberNumberSuffix": "03", "validFrom": "2022-10-01", @@ -309,7 +309,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .statusCode(200) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("partner.partnerNumber", is(givenMembership.getPartner().getPartnerNumber())) + .body("partner.partnerNumber", is("P-" + givenMembership.getPartner().getPartnerNumber())) .body("memberNumberSuffix", is(givenMembership.getMemberNumberSuffix())) .body("validFrom", is("2022-11-01")) .body("validTo", is("2023-12-31")) -- 2.39.5 From 628f984ae6a8b1b95200e7628bd9565a4ef0fcda Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 14:39:11 +0100 Subject: [PATCH 04/10] add M- in front of memberNumber for API --- .../HsOfficeMembershipController.java | 2 +- .../membership/HsOfficeMembershipEntity.java | 5 +++++ .../hs-office-membership-schemas.yaml | 7 ++++--- ...ficeMembershipControllerAcceptanceTest.java | 18 +++++++++--------- 4 files changed, 19 insertions(+), 13 deletions(-) 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 62dcd1c2..de8cc01a 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 @@ -125,7 +125,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { } final BiConsumer SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> { - // TODO.refa: this should be possible via ModelMapper config + resource.setMemberNumber(entity.getTaggedMemberNumber()); resource.setValidFrom(entity.getValidity().lower()); if (entity.getValidity().hasUpperBound()) { resource.setValidTo(entity.getValidity().upper().minusDays(1)); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java index a0740b8b..1b05a90c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java @@ -130,6 +130,7 @@ public class HsOfficeMembershipEntity implements BaseEntity Date: Fri, 15 Nov 2024 15:10:50 +0100 Subject: [PATCH 05/10] add M- in front of memberNumber for related tests --- .../HsOfficeMembershipController.java | 5 +++-- .../hs-office/hs-office-memberships.yaml | 5 ++++- .../scenarios/HsOfficeScenarioTests.java | 20 +++++++++---------- .../CreateCoopAssetsRevertTransaction.java | 2 +- .../CreateCoopSharesRevertTransaction.java | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) 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 de8cc01a..a8add39a 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 @@ -17,6 +17,7 @@ import java.util.UUID; import java.util.function.BiConsumer; import static java.util.Optional.ofNullable; +import static net.hostsharing.hsadminng.repr.TaggedNumber.cropTag; @RestController @@ -37,11 +38,11 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { final String currentSubject, final String assumedRoles, final UUID partnerUuid, - final Integer memberNumber) { + final String memberNumber) { context.define(currentSubject, assumedRoles); final var entities = ( memberNumber != null) - ? ofNullable(membershipRepo.findMembershipByMemberNumber(memberNumber)).stream().toList() + ? ofNullable(membershipRepo.findMembershipByMemberNumber(cropTag("M-", memberNumber))).stream().toList() : membershipRepo.findMembershipsByOptionalPartnerUuid(partnerUuid); final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class, diff --git a/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml b/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml index 8436134b..74093839 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml @@ -19,7 +19,10 @@ get: in: query required: false schema: - type: integer + type: string + minLength: 9 + maxLength: 9 + pattern: 'M-[0-9]{7}' description: Member number, exclusive to `partnerUuid`. responses: "200": 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 ab5419ae..e5e47cf6 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 @@ -260,7 +260,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Requires("Person: Test AG") void shouldDeleteDebitor() { new DeleteDebitor(this) - .given("partnerNumber", 31020) + .given("partnerNumber", "P-31020") .given("debitorSuffix", "02") .doRun(); } @@ -271,7 +271,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Disabled("see TODO.spec in DontDeleteDefaultDebitor") void shouldNotDeleteDefaultDebitor() { new DontDeleteDefaultDebitor(this) - .given("partnerNumber", 31010) + .given("partnerNumber", "P-31010") .given("debitorSuffix", "00") .doRun(); } @@ -337,7 +337,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces("Coop-Shares SUBSCRIPTION Transaction") void shouldSubscribeCoopShares() { new CreateCoopSharesSubscriptionTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("reference", "sign 2024-01-15") .given("shareCount", 100) .given("comment", "Signing the Membership") @@ -350,7 +350,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Requires("Membership: M-3101000 - Test AG") void shouldRevertCoopSharesSubscription() { new CreateCoopSharesRevertTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("comment", "reverting some incorrect transaction") .given("dateOfIncorrectTransaction", "2024-02-15") .doRun(); @@ -362,7 +362,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces("Coop-Shares CANCELLATION Transaction") void shouldCancelCoopSharesSubscription() { new CreateCoopSharesCancellationTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("reference", "cancel 2024-01-15") .given("sharesToCancel", 8) .given("comment", "Cancelling 8 Shares") @@ -376,7 +376,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces("Coop-Assets DEPOSIT Transaction") void shouldSubscribeCoopAssets() { new CreateCoopAssetsDepositTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("reference", "sign 2024-01-15") .given("assetValue", 100*64) .given("comment", "disposal for initial shares") @@ -386,10 +386,10 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(4302) - @Requires("Membership: M-3101000 - Test AG") + @Requires("Coop-Assets DEPOSIT Transaction") void shouldRevertCoopAssetsSubscription() { new CreateCoopAssetsRevertTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("comment", "reverting some incorrect transaction") .given("dateOfIncorrectTransaction", "2024-02-15") .doRun(); @@ -401,7 +401,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces("Coop-Assets DISBURSAL Transaction") void shouldDisburseCoopAssets() { new CreateCoopAssetsDisbursalTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("reference", "cancel 2024-01-15") .given("valueToDisburse", 8*64) .given("comment", "disbursal according to shares cancellation") @@ -414,7 +414,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Requires("Membership: M-3101000 - Test AG") void shouldCancelMembershipOfPartner() { new CancelMembership(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("validTo", "2025-12-30") .given("newStatus", "CANCELLED") .doRun(); 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 index 0750847c..a83c21a2 100644 --- 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 @@ -9,7 +9,7 @@ public class CreateCoopAssetsRevertTransaction extends CreateCoopAssetsTransacti requires("CoopAssets-Transaction with incorrect assetValue", alias -> new CreateCoopAssetsDepositTransaction(testSuite) - .given("memberNumber", "3101000") + .given("memberNumber", "%{memberNumber}") .given("reference", "sign %{dateOfIncorrectTransaction}") // same as revertedAssetTx .given("assetValue", 10) .given("comment", "coop-assets deposit transaction with wrong asset value") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java index 03963834..8464393a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java @@ -9,7 +9,7 @@ public class CreateCoopSharesRevertTransaction extends CreateCoopSharesTransacti requires("CoopShares-Transaction with incorrect shareCount", alias -> new CreateCoopSharesSubscriptionTransaction(testSuite) - .given("memberNumber", "3101000") + .given("memberNumber", "%{memberNumber}") .given("reference", "sign %{dateOfIncorrectTransaction}") // same as revertedShareTx .given("shareCount", 100) .given("comment", "coop-shares subscription transaction with wrong share count") -- 2.39.5 From 42cafef7689fd1719ba1c1ec4723462632226431 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 16:01:03 +0100 Subject: [PATCH 06/10] add D- in front of memberNumber - WIP --- .../office/debitor/HsOfficeDebitorController.java | 5 +++-- .../office/debitor/HsOfficeDebitorRepository.java | 15 ++++++++++----- .../HsOfficeSepaMandateController.java | 2 +- .../hs-office/hs-office-debitor-schemas.yaml | 8 ++++---- .../hs-office/hs-office-debitors.yaml | 5 ++++- .../office/scenarios/HsOfficeScenarioTests.java | 4 ++-- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java index 32721f0d..86548373 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.UUID; import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR; +import static net.hostsharing.hsadminng.repr.TaggedNumber.cropTag; @RestController @@ -53,11 +54,11 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { final String currentSubject, final String assumedRoles, final String name, - final Integer debitorNumber) { + final String debitorNumber) { context.define(currentSubject, assumedRoles); final var entities = debitorNumber != null - ? debitorRepo.findDebitorByDebitorNumber(debitorNumber) + ? debitorRepo.findDebitorByDebitorNumber(cropTag("D-", debitorNumber)) : debitorRepo.findDebitorByOptionalNameLike(name); final var resources = mapper.mapList(entities, HsOfficeDebitorResource.class); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java index bb6cd0f2..b2b51df6 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java @@ -1,8 +1,10 @@ package net.hostsharing.hsadminng.hs.office.debitor; +import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; +import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -16,13 +18,16 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByDebitorNumber(int partnerNumber, byte debitorNumberSuffix); + WHERE partner.partnerNumber = :partnerNumber + AND debitor.debitorNumberSuffix = :debitorNumberSuffix + """) + List findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix); default List findDebitorByDebitorNumber(int debitorNumber) { - return findDebitorByDebitorNumber( debitorNumber/100, (byte) (debitorNumber%100)); + final var partnerNumber = debitorNumber / 100; + final String suffix = String.format("%02d", debitorNumber % 100); + final var result = findDebitorByDebitorNumber(partnerNumber, suffix); + return result; } @Query(""" diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java index 52ef2aad..976aad83 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java @@ -131,7 +131,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { if (entity.getValidity().hasUpperBound()) { resource.setValidTo(entity.getValidity().upper().minusDays(1)); } - resource.getDebitor().setDebitorNumber(entity.getDebitor().getDebitorNumber()); + resource.getDebitor().setDebitorNumber("D-" + entity.getDebitor().getDebitorNumber()); }; final BiConsumer SEPA_MANDATE_RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { 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 bc3d402e..bca2f0a2 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 @@ -12,10 +12,10 @@ components: debitorRel: $ref: 'hs-office-relation-schemas.yaml#/components/schemas/HsOfficeRelation' debitorNumber: - type: integer - format: int32 - minimum: 1000000 - maximum: 9999999 + type: string + minLength: 9 + maxLength: 9 + pattern: 'D-[0-9]{7}' debitorNumberSuffix: type: string pattern: '^[0-9][0-9]$' diff --git a/src/main/resources/api-definition/hs-office/hs-office-debitors.yaml b/src/main/resources/api-definition/hs-office/hs-office-debitors.yaml index 16554531..2e5c3383 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-debitors.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-debitors.yaml @@ -17,7 +17,10 @@ get: in: query required: false schema: - type: integer + type: string + minLength: 9 + maxLength: 9 + pattern: 'D-[0-9]{7}' description: Debitor number of the requested debitor. responses: "200": 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 e5e47cf6..0a844632 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 @@ -238,7 +238,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(2011) @Requires("Person: Test AG") - @Produces("Debitor: Billing GmbH") + @Produces("Debitor: D-3101000 - Test AG - main debitor") void shouldCreateExternalDebitorForPartner() { new CreateExternalDebitorForPartner(this) .given("partnerPersonTradeName", "Test AG") @@ -283,7 +283,7 @@ class HsOfficeScenarioTests extends ScenarioTest { void shouldCreateSepaMandateForDebitor() { new CreateSepaMandateForDebitor(this) // existing debitor - .given("debitorNumber", "3101000") + .given("debitorNumber", "D-3101000") // new sepa-mandate .given("mandateReference", "Test AG - main debitor") -- 2.39.5 From 378d0e0c1659fb14eefd4e7595148176b93a1408 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 17:45:30 +0100 Subject: [PATCH 07/10] add D- in front of memberNumber - ScenarioTest fixed --- .../scenarios/HsOfficeScenarioTests.java | 44 ++++++++++--------- .../hs/office/scenarios/Produces.java | 1 + .../hs/office/scenarios/ScenarioTest.java | 2 + .../debitor/CreateSelfDebitorForPartner.java | 4 +- .../scenarios/debitor/DeleteDebitor.java | 2 +- 5 files changed, 29 insertions(+), 24 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 0a844632..0f7362df 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 @@ -8,8 +8,9 @@ import net.hostsharing.hsadminng.hs.office.scenarios.contact.ReplaceContactData; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateExternalDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSelfDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSepaMandateForDebitor; -import net.hostsharing.hsadminng.hs.office.scenarios.debitor.FinallyDeleteSepaMandateForDebitor; +import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DontDeleteDefaultDebitor; +import net.hostsharing.hsadminng.hs.office.scenarios.debitor.FinallyDeleteSepaMandateForDebitor; 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.CreateMembership; @@ -20,10 +21,9 @@ import net.hostsharing.hsadminng.hs.office.scenarios.membership.coopshares.Creat 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; -import net.hostsharing.hsadminng.hs.office.scenarios.partner.DeletePartner; import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddRepresentativeToPartner; +import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner; +import net.hostsharing.hsadminng.hs.office.scenarios.partner.DeletePartner; import net.hostsharing.hsadminng.hs.office.scenarios.person.ShouldUpdatePersonData; import net.hostsharing.hsadminng.hs.office.scenarios.subscription.RemoveOperationsContactFromPartner; import net.hostsharing.hsadminng.hs.office.scenarios.subscription.SubscribeToMailinglist; @@ -55,7 +55,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1010) - @Produces(explicitly = "Partner: P-31010 - 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", "P-31010") @@ -77,7 +77,8 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1011) - @Produces(explicitly = "Partner: P-31011 - 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", "P-31011") @@ -191,16 +192,16 @@ class HsOfficeScenarioTests extends ScenarioTest { .given("partnerName", "Test AG") .given("newContactCaption", "Test AG - China") .given("newPostalAddress", """ - "firm": "Test AG", - "name": "Fi Zhong-Kha", - "building": "Thi Chi Koh Building", - "street": "No.2 Commercial Second Street", - "district": "Niushan Wei Wu", - "city": "Dongguan City", - "province": "Guangdong Province", - "country": "China" - """) - .given("newOfficePhoneNumber", "++15 999 654321" ) + "firm": "Test AG", + "name": "Fi Zhong-Kha", + "building": "Thi Chi Koh Building", + "street": "No.2 Commercial Second Street", + "district": "Niushan Wei Wu", + "city": "Dongguan City", + "province": "Guangdong Province", + "country": "China" + """) + .given("newOfficePhoneNumber", "++15 999 654321") .given("newEmailAddress", "norden@test-ag.example.org") .doRun(); } @@ -218,9 +219,9 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(2010) @Requires("Partner: P-31010 - Test AG") - @Produces("Debitor: Test AG - main debitor") + @Produces("Debitor: D-3101000 - Test AG - main debitor") void shouldCreateSelfDebitorForPartner() { - new CreateSelfDebitorForPartner(this, "Debitor: Test AG - main debitor") + new CreateSelfDebitorForPartner(this) .given("partnerPersonTradeName", "Test AG") .given("billingContactCaption", "Test AG - billing department") .given("billingContactEmailAddress", "billing@test-ag.example.org") @@ -238,7 +239,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(2011) @Requires("Person: Test AG") - @Produces("Debitor: D-3101000 - Test AG - main debitor") + @Produces("Debitor: D-3101001 - Test AG - main debitor") void shouldCreateExternalDebitorForPartner() { new CreateExternalDebitorForPartner(this) .given("partnerPersonTradeName", "Test AG") @@ -258,6 +259,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(2020) @Requires("Person: Test AG") + @Produces(explicitly = "Debitor: D-3101000 - Test AG - delete debitor", permanent = false) void shouldDeleteDebitor() { new DeleteDebitor(this) .given("partnerNumber", "P-31020") @@ -378,7 +380,7 @@ class HsOfficeScenarioTests extends ScenarioTest { new CreateCoopAssetsDepositTransaction(this) .given("memberNumber", "M-3101000") .given("reference", "sign 2024-01-15") - .given("assetValue", 100*64) + .given("assetValue", 100 * 64) .given("comment", "disposal for initial shares") .given("transactionDate", "2024-01-15") .doRun(); @@ -403,7 +405,7 @@ class HsOfficeScenarioTests extends ScenarioTest { new CreateCoopAssetsDisbursalTransaction(this) .given("memberNumber", "M-3101000") .given("reference", "cancel 2024-01-15") - .given("valueToDisburse", 8*64) + .given("valueToDisburse", 8 * 64) .given("comment", "disbursal according to shares cancellation") .given("transactionDate", "2024-02-15") .doRun(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/Produces.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/Produces.java index 07bc4e47..5d24fd2c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/Produces.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/Produces.java @@ -12,4 +12,5 @@ public @interface Produces { String value() default ""; // same as explicitly, makes it possible to omit the property name String explicitly() default ""; // same as value String[] implicitly() default {}; + boolean permanent() default true; // false means that the object gets deleted again in the process } 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 530eba74..3e0dab34 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 @@ -113,6 +113,8 @@ public abstract class ScenarioTest extends ContextBasedTest { // and it does not produce anything we already have (would cause errors) SetUtils.intersection(testMethodProduces, knowVariables().keySet()).isEmpty() ) { + assertThat(producesAnnot.permanent()).as("cannot depend on non-permanent producer: " + potentialProducerMethod); + // then we recursively produce the pre-requisites of the producer method callRequiredProducers(potentialProducerMethod); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/CreateSelfDebitorForPartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/CreateSelfDebitorForPartner.java index 1cc7a049..41b40ee6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/CreateSelfDebitorForPartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/CreateSelfDebitorForPartner.java @@ -9,8 +9,8 @@ import static org.springframework.http.HttpStatus.OK; public class CreateSelfDebitorForPartner extends UseCase { - public CreateSelfDebitorForPartner(final ScenarioTest testSuite, final String resultAlias) { - super(testSuite, resultAlias); + public CreateSelfDebitorForPartner(final ScenarioTest testSuite) { + super(testSuite); } @Override diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/DeleteDebitor.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/DeleteDebitor.java index 19a0f159..84e9cd30 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/DeleteDebitor.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/DeleteDebitor.java @@ -9,7 +9,7 @@ public class DeleteDebitor extends UseCase { public DeleteDebitor(final ScenarioTest testSuite) { super(testSuite); - requires("Debitor: Test AG - delete debitor", alias -> new CreateSelfDebitorForPartner(testSuite, alias) + requires("Debitor: Test AG - delete debitor", alias -> new CreateSelfDebitorForPartner(testSuite) .given("partnerPersonTradeName", "Test AG") .given("billingContactCaption", "Test AG - billing department") .given("billingContactEmailAddress", "billing@test-ag.example.org") -- 2.39.5 From f5153cc2a175f39aa6f838e59704f7a53fa99485 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 18 Nov 2024 09:55:31 +0100 Subject: [PATCH 08/10] fix related tests and rename Controller methods --- .../debitor/HsOfficeDebitorController.java | 19 +++++++++++------- .../office/debitor/HsOfficeDebitorEntity.java | 11 +++------- .../debitor/HsOfficeDebitorRepository.java | 2 -- .../HsOfficeMembershipController.java | 15 +++++++------- .../HsOfficeSepaMandateController.java | 2 +- .../hs-office-debitors-with-uuid.yaml | 2 +- .../hs-office/hs-office-debitors.yaml | 4 ++-- .../hs-office-memberships-with-uuid.yaml | 2 +- .../hs-office/hs-office-memberships.yaml | 4 ++-- ...OfficeDebitorControllerAcceptanceTest.java | 20 +++++++++---------- .../HsOfficeDebitorEntityUnitTest.java | 10 +++++----- ...iceMembershipControllerAcceptanceTest.java | 2 +- .../HsOfficeMembershipControllerRestTest.java | 6 +++--- 13 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java index 86548373..011db6a2 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java @@ -22,6 +22,7 @@ import jakarta.persistence.PersistenceContext; import jakarta.validation.ValidationException; import java.util.List; import java.util.UUID; +import java.util.function.BiConsumer; import static net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType.DEBITOR; import static net.hostsharing.hsadminng.repr.TaggedNumber.cropTag; @@ -50,7 +51,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listDebitors( + public ResponseEntity> getListOfDebitors( final String currentSubject, final String assumedRoles, final String name, @@ -61,13 +62,13 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { ? debitorRepo.findDebitorByDebitorNumber(cropTag("D-", debitorNumber)) : debitorRepo.findDebitorByOptionalNameLike(name); - final var resources = mapper.mapList(entities, HsOfficeDebitorResource.class); + final var resources = mapper.mapList(entities, HsOfficeDebitorResource.class, ENTITY_TO_RESOURCE_POSTMAPPER); return ResponseEntity.ok(resources); } @Override @Transactional - public ResponseEntity addDebitor( + public ResponseEntity postNewDebitor( String currentSubject, String assumedRoles, HsOfficeDebitorInsertResource body) { @@ -108,13 +109,13 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { .path("/api/hs/office/debitors/{id}") .buildAndExpand(savedEntity.getUuid()) .toUri(); - final var mapped = mapper.map(savedEntity, HsOfficeDebitorResource.class); + final var mapped = mapper.map(savedEntity, HsOfficeDebitorResource.class, ENTITY_TO_RESOURCE_POSTMAPPER); return ResponseEntity.created(uri).body(mapped); } @Override @Transactional(readOnly = true) - public ResponseEntity getDebitorByUuid( + public ResponseEntity getSingleDebitorByUuid( final String currentSubject, final String assumedRoles, final UUID debitorUuid) { @@ -125,7 +126,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { if (result.isEmpty()) { return ResponseEntity.notFound().build(); } - return ResponseEntity.ok(mapper.map(result.get(), HsOfficeDebitorResource.class)); + return ResponseEntity.ok(mapper.map(result.get(), HsOfficeDebitorResource.class, ENTITY_TO_RESOURCE_POSTMAPPER)); } @Override @@ -160,7 +161,11 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { final var saved = debitorRepo.save(current); Hibernate.initialize(saved); - final var mapped = mapper.map(saved, HsOfficeDebitorResource.class); + final var mapped = mapper.map(saved, HsOfficeDebitorResource.class, ENTITY_TO_RESOURCE_POSTMAPPER); return ResponseEntity.ok(mapped); } + + final BiConsumer ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> { + resource.setDebitorNumber(entity.getTaggedDebitorNumber()); + }; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java index e7e25ea9..623fa2cf 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java @@ -142,19 +142,14 @@ public class HsOfficeDebitorEntity implements BaseEntity, return this; } - private String getDebitorNumberString() { + public String getTaggedDebitorNumber() { return ofNullable(partner) .filter(partner -> debitorNumberSuffix != null) .map(HsOfficePartnerEntity::getPartnerNumber) - .map(Object::toString) - .map(partnerNumber -> partnerNumber + debitorNumberSuffix) + .map(partnerNumber -> DEBITOR_NUMBER_TAG + partnerNumber + debitorNumberSuffix) .orElse(null); } - public Integer getDebitorNumber() { - return ofNullable(getDebitorNumberString()).map(Integer::parseInt).orElse(null); - } - @Override public String toString() { return stringify.apply(this); @@ -162,7 +157,7 @@ public class HsOfficeDebitorEntity implements BaseEntity, @Override public String toShortString() { - return DEBITOR_NUMBER_TAG + getDebitorNumberString(); + return getTaggedDebitorNumber(); } public static RbacView rbac() { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java index b2b51df6..30dabb59 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java @@ -1,10 +1,8 @@ package net.hostsharing.hsadminng.hs.office.debitor; -import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; -import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.Optional; import java.util.UUID; 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 a8add39a..f41bd5c2 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 @@ -20,7 +20,6 @@ import static java.util.Optional.ofNullable; import static net.hostsharing.hsadminng.repr.TaggedNumber.cropTag; @RestController - public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Autowired @@ -34,16 +33,18 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listMemberships( + public ResponseEntity> getListOfMemberships( final String currentSubject, final String assumedRoles, final UUID partnerUuid, final String memberNumber) { context.define(currentSubject, assumedRoles); - final var entities = ( memberNumber != null) - ? ofNullable(membershipRepo.findMembershipByMemberNumber(cropTag("M-", memberNumber))).stream().toList() - : membershipRepo.findMembershipsByOptionalPartnerUuid(partnerUuid); + final var entities = (memberNumber != null) + ? ofNullable(membershipRepo.findMembershipByMemberNumber( + cropTag(HsOfficeMembershipEntity.MEMBER_NUMBER_TAG, memberNumber))).stream() + .toList() + : membershipRepo.findMembershipsByOptionalPartnerUuid(partnerUuid); final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class, SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER); @@ -52,7 +53,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional - public ResponseEntity addMembership( + public ResponseEntity postNewMembership( final String currentSubject, final String assumedRoles, final HsOfficeMembershipInsertResource body) { @@ -75,7 +76,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getMembershipByUuid( + public ResponseEntity getSingleMembershipByUuid( final String currentSubject, final String assumedRoles, final UUID membershipUuid) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java index 976aad83..0a72e425 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java @@ -131,7 +131,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { if (entity.getValidity().hasUpperBound()) { resource.setValidTo(entity.getValidity().upper().minusDays(1)); } - resource.getDebitor().setDebitorNumber("D-" + entity.getDebitor().getDebitorNumber()); + resource.getDebitor().setDebitorNumber(entity.getDebitor().getTaggedDebitorNumber()); }; final BiConsumer SEPA_MANDATE_RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { diff --git a/src/main/resources/api-definition/hs-office/hs-office-debitors-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-debitors-with-uuid.yaml index feb8e473..22548852 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-debitors-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-debitors-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-debitors description: 'Fetch a single debitor by its uuid, if visible for the current subject.' - operationId: getDebitorByUuid + operationId: getSingleDebitorByUuid 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-debitors.yaml b/src/main/resources/api-definition/hs-office/hs-office-debitors.yaml index 2e5c3383..c825817f 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-debitors.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-debitors.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) debitors which are visible to the current subject or any of it's assumed roles. tags: - hs-office-debitors - operationId: listDebitors + operationId: getListOfDebitors parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -40,7 +40,7 @@ post: summary: Adds a new debitor. tags: - hs-office-debitors - operationId: addDebitor + operationId: postNewDebitor 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-memberships-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-memberships-with-uuid.yaml index 1511e09f..820fc0bc 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-memberships-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-memberships-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-memberships description: 'Fetch a single membership by its uuid, if visible for the current subject.' - operationId: getMembershipByUuid + operationId: getSingleMembershipByUuid 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-memberships.yaml b/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml index 74093839..9b2c27b4 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml @@ -4,7 +4,7 @@ get: The list can optionally be filtered by either the `partnerUuid` or the `memberNumber` - not both at the same time. tags: - hs-office-memberships - operationId: listMemberships + operationId: getListOfMemberships parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -42,7 +42,7 @@ post: summary: Adds a new membership. tags: - hs-office-memberships - operationId: addMembership + operationId: postNewMembership parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' 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 82f6cdf0..53f32e80 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 @@ -72,7 +72,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu EntityManager em; @Nested - class ListDebitors { + class GetListOfDebitors { @Test void globalAdmin_withoutAssumedRoles_canViewAllDebitors_ifNoCriteriaGiven() { @@ -110,7 +110,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu "phoneNumbers": { "phone_office": "+49 123 1234567" } } }, - "debitorNumber": 1000111, + "debitorNumber": "D-1000111", "debitorNumberSuffix": "11", "partner": { "partnerNumber": "P-10001", @@ -165,7 +165,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu "emailAddresses": { "main": "contact-admin@secondcontact.example.com" } } }, - "debitorNumber": 1000212, + "debitorNumber": "D-1000212", "debitorNumberSuffix": "12", "partner": { "partnerNumber": "P-10002", @@ -199,7 +199,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu "emailAddresses": { "main": "contact-admin@thirdcontact.example.com" } } }, - "debitorNumber": 1000313, + "debitorNumber": "D-1000313", "debitorNumberSuffix": "13", "partner": { "partnerNumber": "P-10003", @@ -237,14 +237,14 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu .header("current-subject", "superuser-alex@hostsharing.net") .port(port) .when() - .get("http://localhost/api/hs/office/debitors?debitorNumber=1000212") + .get("http://localhost/api/hs/office/debitors?debitorNumber=D-1000212") .then().log().all().assertThat() .statusCode(200) .contentType("application/json") .body("", lenientlyEquals(""" [ { - "debitorNumber": 1000212, + "debitorNumber": "D-1000212", "partner": { "partnerNumber": "P-10002" }, "debitorRel": { "contact": { "caption": "second contact" } @@ -260,7 +260,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu } @Nested - class AddDebitor { + class PostNewDebitor { @Test void globalAdmin_withoutAssumedRole_canAddDebitorWithBankAccount() { @@ -436,7 +436,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu } @Nested - class GetDebitor { + class GetSingleDebitorByUuid { @Test void globalAdmin_withoutAssumedRole_canGetArbitraryDebitor() { @@ -534,7 +534,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu .contentType("application/json") .body("", lenientlyEquals(""" { - "debitorNumber": 1000111, + "debitorNumber": "D-1000111", "partner": { "partnerNumber": "P-10001" }, "debitorRel": { "contact": { "caption": "first contact" } }, "refundBankAccount": null @@ -581,7 +581,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu "mark": null, "contact": { "caption": "fourth contact" } }, - "debitorNumber": 10004${debitorNumberSuffix}, + "debitorNumber": "D-10004${debitorNumberSuffix}", "debitorNumberSuffix": "${debitorNumberSuffix}", "partner": { "partnerNumber": "P-10004", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java index 951ff536..a1c5ea0e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java @@ -65,9 +65,9 @@ class HsOfficeDebitorEntityUnitTest { .build()) .build(); - final var result = given.getDebitorNumber(); + final var result = given.getTaggedDebitorNumber(); - assertThat(result).isEqualTo(1234567); + assertThat(result).isEqualTo("D-1234567"); } @Test @@ -78,7 +78,7 @@ class HsOfficeDebitorEntityUnitTest { .partner(null) .build(); - final var result = given.getDebitorNumber(); + final var result = given.getTaggedDebitorNumber(); assertThat(result).isNull(); } @@ -91,7 +91,7 @@ class HsOfficeDebitorEntityUnitTest { .partner(HsOfficePartnerEntity.builder().build()) .build(); - final var result = given.getDebitorNumber(); + final var result = given.getTaggedDebitorNumber(); assertThat(result).isNull(); } @@ -106,7 +106,7 @@ class HsOfficeDebitorEntityUnitTest { .build()) .build(); - final var result = given.getDebitorNumber(); + final var result = given.getTaggedDebitorNumber(); assertThat(result).isNull(); } 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 68320f21..2a8beba2 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 @@ -144,7 +144,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle .header("current-subject", "superuser-alex@hostsharing.net") .port(port) .when() - .queryParam("memberNumber", 1000202 ) + .queryParam("memberNumber", "M-1000202" ) .get("http://localhost/api/hs/office/memberships") .then().log().all().assertThat() .statusCode(200) 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 2306fcca..cc4b7d0d 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 @@ -46,14 +46,14 @@ public class HsOfficeMembershipControllerRestTest { EntityManagerWrapper em; @Nested - class GetMemberships { + class GetListOfMemberships { @Test void findMembershipByNonExistingMemberNumberReturnsEmptyList() throws Exception { // when mockMvc.perform(MockMvcRequestBuilders - .get("/api/hs/office/memberships?memberNumber=12345") + .get("/api/hs/office/memberships?memberNumber=M-1234501") .header("current-subject", "superuser-alex@hostsharing.net") .contentType(MediaType.APPLICATION_JSON) .content(""" @@ -73,7 +73,7 @@ public class HsOfficeMembershipControllerRestTest { } @Nested - class AddMembership { + class PostNewMembership { @Test void respondBadRequest_ifPartnerUuidIsMissing() throws Exception { -- 2.39.5 From 8183c8751910a21697f45dbeaab006df764e89c2 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 18 Nov 2024 10:51:42 +0100 Subject: [PATCH 09/10] fix prefixes in SepaMandate tests --- ...iceSepaMandateControllerAcceptanceTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 82a011dc..7812a9fb 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 @@ -72,21 +72,21 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .body("", lenientlyEquals(""" [ { - "debitor": { "debitorNumber": 1000111 }, + "debitor": { "debitorNumber": "D-1000111" }, "bankAccount": { "holder": "First GmbH" }, "reference": "ref-10001-11", "validFrom": "2022-10-01", "validTo": "2026-12-31" }, { - "debitor": { "debitorNumber": 1000212 }, + "debitor": { "debitorNumber": "D-1000212" }, "bankAccount": { "holder": "Second e.K." }, "reference": "ref-10002-12", "validFrom": "2022-10-01", "validTo": "2026-12-31" }, { - "debitor": { "debitorNumber": 1000313 }, + "debitor": { "debitorNumber": "D-1000313" }, "bankAccount": { "holder": "Third OHG" }, "reference": "ref-10003-13", "validFrom": "2022-10-01", @@ -113,7 +113,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .body("", lenientlyEquals(""" [ { - "debitor": { "debitorNumber": 1000111 }, + "debitor": { "debitorNumber": "D-1000111" }, "bankAccount": { "iban": "DE02120300000000202051", "holder": "First GmbH" @@ -158,7 +158,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .statusCode(201) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("debitor.partner.partnerNumber", is(10003)) + .body("debitor.partner.partnerNumber", is("P-10003")) .body("bankAccount.iban", is("DE02200505501015871393")) .body("reference", is("temp ref CAT A")) .body("validFrom", is("2022-10-13")) @@ -280,7 +280,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .contentType("application/json") .body("", lenientlyEquals(""" { - "debitor": { "debitorNumber": 1000111 }, + "debitor": { "debitorNumber": "D-1000111" }, "bankAccount": { "holder": "First GmbH", "iban": "DE02120300000000202051" @@ -327,7 +327,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .contentType("application/json") .body("", lenientlyEquals(""" { - "debitor": { "debitorNumber": 1000111 }, + "debitor": { "debitorNumber": "D-1000111" }, "bankAccount": { "holder": "First GmbH", "iban": "DE02120300000000202051" @@ -367,7 +367,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .statusCode(200) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("debitor.debitorNumber", is(1000111)) + .body("debitor.debitorNumber", is("D-1000111")) .body("bankAccount.iban", is("DE02120300000000202051")) .body("reference", is("temp ref CAT Z - patched")) .body("agreement", is("2020-06-01")) @@ -410,7 +410,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl .statusCode(200) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("debitor.debitorNumber", is(1000111)) + .body("debitor.debitorNumber", is("D-1000111")) .body("bankAccount.iban", is("DE02120300000000202051")) .body("reference", is("temp ref CAT Z")) .body("validFrom", is("2022-11-01")) -- 2.39.5 From 1958c0d5b4bcaef034c1d15dfa9712aed78d1c57 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 18 Nov 2024 11:06:33 +0100 Subject: [PATCH 10/10] fix arch test --- .../java/net/hostsharing/hsadminng/arch/ArchitectureTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/hostsharing/hsadminng/arch/ArchitectureTest.java b/src/test/java/net/hostsharing/hsadminng/arch/ArchitectureTest.java index 3c3cae0c..e53a7c75 100644 --- a/src/test/java/net/hostsharing/hsadminng/arch/ArchitectureTest.java +++ b/src/test/java/net/hostsharing/hsadminng/arch/ArchitectureTest.java @@ -77,7 +77,7 @@ public class ArchitectureTest { "..rbac.grant", "..rbac.role", "..rbac.object", - "..stringify" + "..repr" // ATTENTION: Don't simply add packages here, also add arch rules for the new package! ); -- 2.39.5