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 0f1b3600..02c72e17 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 @@ -58,7 +58,7 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, HasUu private BigDecimal assetValue; @Column(name = "reference") - private String reference; // TODO: what is this for? + private String reference; @Column(name = "comment") private String comment; 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 6c47bbb8..749b616c 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 @@ -53,7 +53,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUu private int shareCount; @Column(name = "reference") - private String reference; // TODO: what is this for? + private String reference; @Column(name = "comment") private String comment; 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 da1b7920..a375ffa4 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 @@ -44,7 +44,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { Integer memberNumber) { context.define(currentUser, assumedRoles); - final var entities = membershipRepo.findMembershipsByOptionalPartherNumber(partnerUuid); + final var entities = membershipRepo.findMembershipsByOptionalPartnerUuid(partnerUuid); final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class, SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER); 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 52ca596f..703adc57 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 @@ -15,6 +15,7 @@ import org.hibernate.annotations.Type; import jakarta.persistence.*; import java.time.LocalDate; +import java.util.Optional; import java.util.UUID; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.*; @@ -30,8 +31,10 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify; @DisplayName("Membership") public class HsOfficeMembershipEntity implements HasUuid, Stringifyable { + public static final String MEMBER_NUMBER_TAG = "M-"; + private static Stringify stringify = stringify(HsOfficeMembershipEntity.class) - .withProp(HsOfficeMembershipEntity::getMemberNumber) + .withProp(HsOfficeMembershipEntity::getMemberNumberString) .withProp(e -> e.getPartner().toShortString()) .withProp(e -> e.getMainDebitor().toShortString()) .withProp(e -> e.getValidity().asString()) @@ -82,15 +85,33 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable { return upperInclusiveFromPostgresDateRange(getValidity()); } - public Range getValidity() { if (validity == null) { validity = Range.infinite(LocalDate.class); } - ; return validity; } + public String getMemberNumberString() { + return MEMBER_NUMBER_TAG + getMemberNumber(); + } + + public Integer getMemberNumber() { + // TODO: refactor + String combinedMemberNumber; + if (partner.getPartnerNumber() == null ) { + if (memberNumberSuffix == null) { + combinedMemberNumber = null; + } else {combinedMemberNumber = MEMBER_NUMBER_TAG + memberNumberSuffix;} + } else if (memberNumberSuffix == null) { + combinedMemberNumber = partner.getPartnerNumber() + "??"; + } else { + combinedMemberNumber = partner.getPartnerNumber() + memberNumberSuffix; + } + + return Optional.ofNullable(combinedMemberNumber).map(Integer::parseInt).orElse(null); + } + @Override public String toString() { return stringify.apply(this); @@ -98,7 +119,7 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable { @Override public String toShortString() { - return partner.getPartnerNumber() + String.valueOf(memberNumberSuffix); + return "M-" + partner.getPartnerNumber() + String.valueOf(memberNumberSuffix); } @PrePersist diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java index 71f91881..6de92ee8 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java @@ -21,7 +21,7 @@ public interface HsOfficeMembershipRepository extends Repository findMembershipsByOptionalPartherNumber(UUID partnerUuid); + List findMembershipsByOptionalPartnerUuid(UUID partnerUuid); @Query(""" SELECT membership FROM HsOfficeMembershipEntity membership WHERE (:partnerNumber = membership.partner.partnerNumber) diff --git a/src/main/resources/db/changelog/303-hs-office-membership-rbac.sql b/src/main/resources/db/changelog/303-hs-office-membership-rbac.sql index de7b9c30..8197cf09 100644 --- a/src/main/resources/db/changelog/303-hs-office-membership-rbac.sql +++ b/src/main/resources/db/changelog/303-hs-office-membership-rbac.sql @@ -92,8 +92,9 @@ execute procedure hsOfficeMembershipRbacRolesTrigger(); --changeset hs-office-membership-rbac-IDENTITY-VIEW:1 endDelimiter:--// -- ---------------------------------------------------------------------------- call generateRbacIdentityView('hs_office_membership', idNameExpression => $idName$ - target.memberNumberSuffix || - ':' || + '#' || + (select partnerNumber from hs_office_partner p where p.uuid = target.partnerUuid) || + memberNumberSuffix || ':' || (select split_part(idName, ':', 2) from hs_office_partner_iv p where p.uuid = target.partnerUuid) $idName$); --// diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java index c227456d..a7052a2e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java @@ -93,21 +93,21 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest { "transactionType": "DEPOSIT", "assetValue": 320.00, "valueDate": "2010-03-15", - "reference": "ref 10002-1", + "reference": "ref 1000202-1", "comment": "initial deposit" }, { "transactionType": "DISBURSAL", "assetValue": -128.00, "valueDate": "2021-09-01", - "reference": "ref 10002-2", + "reference": "ref 1000202-2", "comment": "partial disbursal" }, { "transactionType": "ADJUSTMENT", "assetValue": 128.00, "valueDate": "2022-10-20", - "reference": "ref 10002-3", + "reference": "ref 1000202-3", "comment": "some adjustment" } ] @@ -137,7 +137,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest { "transactionType": "DISBURSAL", "assetValue": -128.00, "valueDate": "2021-09-01", - "reference": "ref 10002-2", + "reference": "ref 1000202-2", "comment": "partial disbursal" } ] diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java index 6c21cde8..d93aa90f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionEntityUnitTest.java @@ -23,14 +23,14 @@ class HsOfficeCoopAssetsTransactionEntityUnitTest { void toStringContainsAlmostAllPropertiesAccount() { final var result = givenCoopAssetTransaction.toString(); - assertThat(result).isEqualTo("CoopAssetsTransaction(300001, 2020-01-01, DEPOSIT, 128.00, some-ref)"); + assertThat(result).isEqualTo("CoopAssetsTransaction(1000101, 2020-01-01, DEPOSIT, 128.00, some-ref)"); } @Test void toShortStringContainsOnlyMemberNumberSuffixAndSharesCountOnly() { final var result = givenCoopAssetTransaction.toShortString(); - assertThat(result).isEqualTo("300001+128.00"); + assertThat(result).isEqualTo("1000101+128.00"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java index ce50f4a7..dfba6b7a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java @@ -115,7 +115,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase .map(s -> s.replace("hs_office_", "")) .containsExactlyInAnyOrder(Array.fromFormatted( initialGrantNames, - "{ grant perm view on coopassetstransaction#temprefB to role membership#10001:....tenant by system and assume }", + "{ grant perm view on coopassetstransaction#temprefB to role membership#1000101:....tenant by system and assume }", null)); } @@ -142,17 +142,17 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase // then allTheseCoopAssetsTransactionsAreReturned( result, - "CoopAssetsTransaction(10001, 2010-03-15, DEPOSIT, 320.00, ref 10001-1, initial deposit)", - "CoopAssetsTransaction(10001, 2021-09-01, DISBURSAL, -128.00, ref 10001-2, partial disbursal)", - "CoopAssetsTransaction(10001, 2022-10-20, ADJUSTMENT, 128.00, ref 10001-3, some adjustment)", + "CoopAssetsTransaction(1000101, 2010-03-15, DEPOSIT, 320.00, ref 1000101-1, initial deposit)", + "CoopAssetsTransaction(1000101, 2021-09-01, DISBURSAL, -128.00, ref 1000101-2, partial disbursal)", + "CoopAssetsTransaction(1000101, 2022-10-20, ADJUSTMENT, 128.00, ref 1000101-3, some adjustment)", - "CoopAssetsTransaction(10002, 2010-03-15, DEPOSIT, 320.00, ref 10002-1, initial deposit)", - "CoopAssetsTransaction(10002, 2021-09-01, DISBURSAL, -128.00, ref 10002-2, partial disbursal)", - "CoopAssetsTransaction(10002, 2022-10-20, ADJUSTMENT, 128.00, ref 10002-3, some adjustment)", + "CoopAssetsTransaction(1000202, 2010-03-15, DEPOSIT, 320.00, ref 1000202-1, initial deposit)", + "CoopAssetsTransaction(1000202, 2021-09-01, DISBURSAL, -128.00, ref 1000202-2, partial disbursal)", + "CoopAssetsTransaction(1000202, 2022-10-20, ADJUSTMENT, 128.00, ref 1000202-3, some adjustment)", - "CoopAssetsTransaction(10003, 2010-03-15, DEPOSIT, 320.00, ref 10003-1, initial deposit)", - "CoopAssetsTransaction(10003, 2021-09-01, DISBURSAL, -128.00, ref 10003-2, partial disbursal)", - "CoopAssetsTransaction(10003, 2022-10-20, ADJUSTMENT, 128.00, ref 10003-3, some adjustment)"); + "CoopAssetsTransaction(1000303, 2010-03-15, DEPOSIT, 320.00, ref 1000303-1, initial deposit)", + "CoopAssetsTransaction(1000303, 2021-09-01, DISBURSAL, -128.00, ref 1000303-2, partial disbursal)", + "CoopAssetsTransaction(1000303, 2022-10-20, ADJUSTMENT, 128.00, ref 1000303-3, some adjustment)"); } @Test @@ -170,9 +170,9 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase // then allTheseCoopAssetsTransactionsAreReturned( result, - "CoopAssetsTransaction(10002, 2010-03-15, DEPOSIT, 320.00, ref 10002-1, initial deposit)", - "CoopAssetsTransaction(10002, 2021-09-01, DISBURSAL, -128.00, ref 10002-2, partial disbursal)", - "CoopAssetsTransaction(10002, 2022-10-20, ADJUSTMENT, 128.00, ref 10002-3, some adjustment)"); + "CoopAssetsTransaction(1000202, 2010-03-15, DEPOSIT, 320.00, ref 1000202-1, initial deposit)", + "CoopAssetsTransaction(1000202, 2021-09-01, DISBURSAL, -128.00, ref 1000202-2, partial disbursal)", + "CoopAssetsTransaction(1000202, 2022-10-20, ADJUSTMENT, 128.00, ref 1000202-3, some adjustment)"); } @Test @@ -191,7 +191,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase // then allTheseCoopAssetsTransactionsAreReturned( result, - "CoopAssetsTransaction(10002, 2021-09-01, DISBURSAL, -128.00, ref 10002-2, partial disbursal)"); + "CoopAssetsTransaction(1000202, 2021-09-01, DISBURSAL, -128.00, ref 1000202-2, partial disbursal)"); } @Test @@ -208,9 +208,9 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase // then: exactlyTheseCoopAssetsTransactionsAreReturned( result, - "CoopAssetsTransaction(10001, 2010-03-15, DEPOSIT, 320.00, ref 10001-1, initial deposit)", - "CoopAssetsTransaction(10001, 2021-09-01, DISBURSAL, -128.00, ref 10001-2, partial disbursal)", - "CoopAssetsTransaction(10001, 2022-10-20, ADJUSTMENT, 128.00, ref 10001-3, some adjustment)"); + "CoopAssetsTransaction(1000101, 2010-03-15, DEPOSIT, 320.00, ref 1000101-1, initial deposit)", + "CoopAssetsTransaction(1000101, 2021-09-01, DISBURSAL, -128.00, ref 1000101-2, partial disbursal)", + "CoopAssetsTransaction(1000101, 2022-10-20, ADJUSTMENT, 128.00, ref 1000101-3, some adjustment)"); } } @@ -229,8 +229,8 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase // then assertThat(customerLogEntries).map(Arrays::toString).contains( - "[creating coopAssetsTransaction test-data 10001, hs_office_coopassetstransaction, INSERT]", - "[creating coopAssetsTransaction test-data 10002, hs_office_coopassetstransaction, INSERT]"); + "[creating coopAssetsTransaction test-data 1000101, hs_office_coopassetstransaction, INSERT]", + "[creating coopAssetsTransaction test-data 1000202, hs_office_coopassetstransaction, INSERT]"); } @BeforeEach diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java index 1212046e..ebb7ca59 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java @@ -84,21 +84,21 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest { "transactionType": "SUBSCRIPTION", "shareCount": 4, "valueDate": "2010-03-15", - "reference": "ref 10002-1", + "reference": "ref 1000202-1", "comment": "initial subscription" }, { "transactionType": "CANCELLATION", "shareCount": -2, "valueDate": "2021-09-01", - "reference": "ref 10002-2", + "reference": "ref 1000202-2", "comment": "cancelling some" }, { "transactionType": "ADJUSTMENT", "shareCount": 2, "valueDate": "2022-10-20", - "reference": "ref 10002-3", + "reference": "ref 1000202-3", "comment": "some adjustment" } ] @@ -118,7 +118,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest { "transactionType": "CANCELLATION", "shareCount": -2, "valueDate": "2021-09-01", - "reference": "ref 10002-2", + "reference": "ref 1000202-2", "comment": "cancelling some" } ] diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java index 8dcfd133..862c593e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionEntityUnitTest.java @@ -22,14 +22,14 @@ class HsOfficeCoopSharesTransactionEntityUnitTest { void toStringContainsAlmostAllPropertiesAccount() { final var result = givenCoopSharesTransaction.toString(); - assertThat(result).isEqualTo("CoopShareTransaction(300001, 2020-01-01, SUBSCRIPTION, 4, some-ref)"); + assertThat(result).isEqualTo("CoopShareTransaction(1000101, 2020-01-01, SUBSCRIPTION, 4, some-ref)"); } @Test void toShortStringContainsOnlyMemberNumberAndShareCountOnly() { final var result = givenCoopSharesTransaction.toShortString(); - assertThat(result).isEqualTo("300001+4"); + assertThat(result).isEqualTo("1000101+4"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java index d6ec4269..9ef64522 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java @@ -230,8 +230,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase // then assertThat(customerLogEntries).map(Arrays::toString).contains( - "[creating coopSharesTransaction test-data 10001, hs_office_coopsharestransaction, INSERT]", - "[creating coopSharesTransaction test-data 10002, hs_office_coopsharestransaction, INSERT]"); + "[creating coopSharesTransaction test-data 1000101, hs_office_coopsharestransaction, INSERT]", + "[creating coopSharesTransaction test-data 1000202, hs_office_coopsharestransaction, INSERT]"); } @BeforeEach diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java index 0b8d1342..9563d6ad 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java @@ -27,14 +27,14 @@ class HsOfficeMembershipEntityUnitTest { void toStringContainsAllProps() { final var result = givenMembership.toString(); - assertThat(result).isEqualTo("Membership(1000101, LEGAL Test Ltd., 1000100, [2020-01-01,))"); + assertThat(result).isEqualTo("Membership(M-1000101, LEGAL Test Ltd., 1000100, [2020-01-01,))"); } @Test void toShortStringContainsMemberNumberSuffixOnly() { final var result = givenMembership.toShortString(); - assertThat(result).isEqualTo("1000101"); + assertThat(result).isEqualTo("M-1000101"); } @Test diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java index 376d1ecd..e6ec5bb2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java @@ -108,7 +108,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("First").get(0); final var newMembership = toCleanup(HsOfficeMembershipEntity.builder() - .memberNumberSuffix("02") + .memberNumberSuffix("07") .partner(givenPartner) .mainDebitor(givenDebitor) .validity(Range.closedInfinite(LocalDate.parse("2020-01-01"))) @@ -121,11 +121,11 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { final var all = rawRoleRepo.findAll(); assertThat(roleNamesOf(all)).containsExactlyInAnyOrder(Array.from( initialRoleNames, - "hs_office_membership#20002:FirstGmbH-firstcontact.admin", - "hs_office_membership#20002:FirstGmbH-firstcontact.agent", - "hs_office_membership#20002:FirstGmbH-firstcontact.guest", - "hs_office_membership#20002:FirstGmbH-firstcontact.owner", - "hs_office_membership#20002:FirstGmbH-firstcontact.tenant")); + "hs_office_membership#1000107:FirstGmbH-firstcontact.admin", + "hs_office_membership#1000107:FirstGmbH-firstcontact.agent", + "hs_office_membership#1000107:FirstGmbH-firstcontact.guest", + "hs_office_membership#1000107:FirstGmbH-firstcontact.owner", + "hs_office_membership#1000107:FirstGmbH-firstcontact.tenant")); assertThat(grantDisplaysOf(rawGrantRepo.findAll())) .map(s -> s.replace("GmbH-firstcontact", "")) .map(s -> s.replace("hs_office_", "")) @@ -133,33 +133,33 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { initialGrantNames, // owner - "{ grant perm * on membership#20002:First to role membership#20002:First.owner by system and assume }", - "{ grant role membership#20002:First.owner to role global#global.admin by system and assume }", + "{ grant perm * on membership#1000107:First to role membership#1000107:First.owner by system and assume }", + "{ grant role membership#1000107:First.owner to role global#global.admin by system and assume }", // admin - "{ grant perm edit on membership#20002:First to role membership#20002:First.admin by system and assume }", - "{ grant role membership#20002:First.admin to role membership#20002:First.owner by system and assume }", + "{ grant perm edit on membership#1000107:First to role membership#1000107:First.admin by system and assume }", + "{ grant role membership#1000107:First.admin to role membership#1000107:First.owner by system and assume }", // agent - "{ grant role membership#20002:First.agent to role membership#20002:First.admin by system and assume }", - "{ grant role partner#10001:First.tenant to role membership#20002:First.agent by system and assume }", - "{ grant role membership#20002:First.agent to role debitor#1000111:First.admin by system and assume }", - "{ grant role membership#20002:First.agent to role partner#10001:First.admin by system and assume }", - "{ grant role debitor#1000111:First.tenant to role membership#20002:First.agent by system and assume }", + "{ grant role membership#1000107:First.agent to role membership#1000107:First.admin by system and assume }", + "{ grant role partner#10001:First.tenant to role membership#1000107:First.agent by system and assume }", + "{ grant role membership#1000107:First.agent to role debitor#1000111:First.admin by system and assume }", + "{ grant role membership#1000107:First.agent to role partner#10001:First.admin by system and assume }", + "{ grant role debitor#1000111:First.tenant to role membership#1000107:First.agent by system and assume }", // tenant - "{ grant role membership#20002:First.tenant to role membership#20002:First.agent by system and assume }", - "{ grant role partner#10001:First.guest to role membership#20002:First.tenant by system and assume }", - "{ grant role debitor#1000111:First.guest to role membership#20002:First.tenant by system and assume }", - "{ grant role membership#20002:First.tenant to role debitor#1000111:First.agent by system and assume }", + "{ grant role membership#1000107:First.tenant to role membership#1000107:First.agent by system and assume }", + "{ grant role partner#10001:First.guest to role membership#1000107:First.tenant by system and assume }", + "{ grant role debitor#1000111:First.guest to role membership#1000107:First.tenant by system and assume }", + "{ grant role membership#1000107:First.tenant to role debitor#1000111:First.agent by system and assume }", - "{ grant role membership#20002:First.tenant to role partner#10001:First.agent by system and assume }", + "{ grant role membership#1000107:First.tenant to role partner#10001:First.agent by system and assume }", // guest - "{ grant perm view on membership#20002:First to role membership#20002:First.guest by system and assume }", - "{ grant role membership#20002:First.guest to role membership#20002:First.tenant by system and assume }", - "{ grant role membership#20002:First.guest to role partner#10001:First.tenant by system and assume }", - "{ grant role membership#20002:First.guest to role debitor#1000111:First.tenant by system and assume }", + "{ grant perm view on membership#1000107:First to role membership#1000107:First.guest by system and assume }", + "{ grant role membership#1000107:First.guest to role membership#1000107:First.tenant by system and assume }", + "{ grant role membership#1000107:First.guest to role partner#10001:First.tenant by system and assume }", + "{ grant role membership#1000107:First.guest to role debitor#1000111:First.tenant by system and assume }", null)); } @@ -179,14 +179,14 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { context("superuser-alex@hostsharing.net"); // when - final var result = membershipRepo.findMembershipsByOptionalPartherNumber(null); + final var result = membershipRepo.findMembershipsByOptionalPartnerUuid(null); // then exactlyTheseMembershipsAreReturned( result, - "Membership(10001, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)", - "Membership(10002, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)", - "Membership(10003, SOLE_REPRESENTATION Third OHG, 1000313, [2022-10-01,), NONE)"); + "Membership(M-1000101, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)", + "Membership(M-1000202, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)", + "Membership(M-1000303, SOLE_REPRESENTATION Third OHG, 1000313, [2022-10-01,), NONE)"); } @Test @@ -196,10 +196,11 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0); // when - final var result = membershipRepo.findMembershipsByOptionalPartherNumber(givenPartner.getUuid()); + final var result = membershipRepo.findMembershipsByOptionalPartnerUuid(givenPartner.getUuid()); // then - exactlyTheseMembershipsAreReturned(result, "Membership(10001, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)"); + exactlyTheseMembershipsAreReturned(result, + "Membership(M-1000101, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)"); } @Test @@ -208,10 +209,11 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest { context("superuser-alex@hostsharing.net"); // when - final var result = membershipRepo.findMembershipsByOptionalPartherNumber(null); + final var result = membershipRepo.findMembershipsByMemberNumber(1000202); // then - exactlyTheseMembershipsAreReturned(result, "Membership(10002, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)"); + exactlyTheseMembershipsAreReturned(result, + "Membership(M-1000202, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java index 28e20792..473807eb 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/migration/ImportOfficeData.java @@ -182,9 +182,9 @@ public class ImportOfficeData extends ContextBasedTest { """); assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace(""" { - 17=Membership(10017, null null, null, 1001700, [2000-12-06,), NONE), - 20=Membership(10020, null null, null, 1002000, [2000-12-06,2016-01-01), UNKNOWN), - 22=Membership(11022, null null, null, 1102200, [2021-04-01,), NONE) + 17=Membership(1001700, null null, null, 1001700, [2000-12-06,), NONE), + 20=Membership(1002000, null null, null, 1002000, [2000-12-06,2016-01-01), UNKNOWN), + 22=Membership(1102200, null null, null, 1102200, [2021-04-01,), NONE) } """); }