memberNumber as partnerNumber+memberNumberSuffix #13

Merged
hsh-michaelhoennig merged 78 commits from memberNumberSuffix-and-partnerNumber into master 2024-01-24 15:57:16 +01:00
15 changed files with 104 additions and 80 deletions
Showing only changes of commit bcf8ad2148 - Show all commits

View File

@ -58,7 +58,7 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, HasUu
private BigDecimal assetValue; private BigDecimal assetValue;
@Column(name = "reference") @Column(name = "reference")
private String reference; // TODO: what is this for? private String reference;
@Column(name = "comment") @Column(name = "comment")
private String comment; private String comment;

View File

@ -53,7 +53,7 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUu
private int shareCount; private int shareCount;
@Column(name = "reference") @Column(name = "reference")
private String reference; // TODO: what is this for? private String reference;
@Column(name = "comment") @Column(name = "comment")
private String comment; private String comment;

View File

@ -44,7 +44,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
Integer memberNumber) { Integer memberNumber) {
context.define(currentUser, assumedRoles); context.define(currentUser, assumedRoles);
final var entities = membershipRepo.findMembershipsByOptionalPartherNumber(partnerUuid); final var entities = membershipRepo.findMembershipsByOptionalPartnerUuid(partnerUuid);
final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class, final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class,
SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER); SEPA_MANDATE_ENTITY_TO_RESOURCE_POSTMAPPER);

View File

@ -15,6 +15,7 @@ import org.hibernate.annotations.Type;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import static net.hostsharing.hsadminng.mapper.PostgresDateRange.*; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.*;
@ -30,8 +31,10 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
@DisplayName("Membership") @DisplayName("Membership")
public class HsOfficeMembershipEntity implements HasUuid, Stringifyable { public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
public static final String MEMBER_NUMBER_TAG = "M-";
private static Stringify<HsOfficeMembershipEntity> stringify = stringify(HsOfficeMembershipEntity.class) private static Stringify<HsOfficeMembershipEntity> stringify = stringify(HsOfficeMembershipEntity.class)
.withProp(HsOfficeMembershipEntity::getMemberNumber) .withProp(HsOfficeMembershipEntity::getMemberNumberString)
.withProp(e -> e.getPartner().toShortString()) .withProp(e -> e.getPartner().toShortString())
.withProp(e -> e.getMainDebitor().toShortString()) .withProp(e -> e.getMainDebitor().toShortString())
.withProp(e -> e.getValidity().asString()) .withProp(e -> e.getValidity().asString())
@ -82,15 +85,33 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
return upperInclusiveFromPostgresDateRange(getValidity()); return upperInclusiveFromPostgresDateRange(getValidity());
} }
public Range<LocalDate> getValidity() { public Range<LocalDate> getValidity() {
if (validity == null) { if (validity == null) {
validity = Range.infinite(LocalDate.class); validity = Range.infinite(LocalDate.class);
} }
;
return validity; 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 @Override
public String toString() { public String toString() {
return stringify.apply(this); return stringify.apply(this);
@ -98,7 +119,7 @@ public class HsOfficeMembershipEntity implements HasUuid, Stringifyable {
@Override @Override
public String toShortString() { public String toShortString() {
return partner.getPartnerNumber() + String.valueOf(memberNumberSuffix); return "M-" + partner.getPartnerNumber() + String.valueOf(memberNumberSuffix);
} }
@PrePersist @PrePersist

View File

@ -21,7 +21,7 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
OR membership.partner.uuid = :partnerUuid ) OR membership.partner.uuid = :partnerUuid )
ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix
""") """)
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartherNumber(UUID partnerUuid); List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuid(UUID partnerUuid);
@Query(""" @Query("""
SELECT membership FROM HsOfficeMembershipEntity membership SELECT membership FROM HsOfficeMembershipEntity membership
WHERE (:partnerNumber = membership.partner.partnerNumber) WHERE (:partnerNumber = membership.partner.partnerNumber)

View File

@ -92,8 +92,9 @@ execute procedure hsOfficeMembershipRbacRolesTrigger();
--changeset hs-office-membership-rbac-IDENTITY-VIEW:1 endDelimiter:--// --changeset hs-office-membership-rbac-IDENTITY-VIEW:1 endDelimiter:--//
-- ---------------------------------------------------------------------------- -- ----------------------------------------------------------------------------
call generateRbacIdentityView('hs_office_membership', idNameExpression => $idName$ 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) ':' || (select split_part(idName, ':', 2) from hs_office_partner_iv p where p.uuid = target.partnerUuid)
$idName$); $idName$);
--// --//

View File

@ -93,21 +93,21 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
"transactionType": "DEPOSIT", "transactionType": "DEPOSIT",
"assetValue": 320.00, "assetValue": 320.00,
"valueDate": "2010-03-15", "valueDate": "2010-03-15",
"reference": "ref 10002-1", "reference": "ref 1000202-1",
"comment": "initial deposit" "comment": "initial deposit"
}, },
{ {
"transactionType": "DISBURSAL", "transactionType": "DISBURSAL",
"assetValue": -128.00, "assetValue": -128.00,
"valueDate": "2021-09-01", "valueDate": "2021-09-01",
"reference": "ref 10002-2", "reference": "ref 1000202-2",
"comment": "partial disbursal" "comment": "partial disbursal"
}, },
{ {
"transactionType": "ADJUSTMENT", "transactionType": "ADJUSTMENT",
"assetValue": 128.00, "assetValue": 128.00,
"valueDate": "2022-10-20", "valueDate": "2022-10-20",
"reference": "ref 10002-3", "reference": "ref 1000202-3",
"comment": "some adjustment" "comment": "some adjustment"
} }
] ]
@ -137,7 +137,7 @@ class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
"transactionType": "DISBURSAL", "transactionType": "DISBURSAL",
"assetValue": -128.00, "assetValue": -128.00,
"valueDate": "2021-09-01", "valueDate": "2021-09-01",
"reference": "ref 10002-2", "reference": "ref 1000202-2",
"comment": "partial disbursal" "comment": "partial disbursal"
} }
] ]

View File

@ -23,14 +23,14 @@ class HsOfficeCoopAssetsTransactionEntityUnitTest {
void toStringContainsAlmostAllPropertiesAccount() { void toStringContainsAlmostAllPropertiesAccount() {
final var result = givenCoopAssetTransaction.toString(); 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 @Test
void toShortStringContainsOnlyMemberNumberSuffixAndSharesCountOnly() { void toShortStringContainsOnlyMemberNumberSuffixAndSharesCountOnly() {
final var result = givenCoopAssetTransaction.toShortString(); final var result = givenCoopAssetTransaction.toShortString();
assertThat(result).isEqualTo("300001+128.00"); assertThat(result).isEqualTo("1000101+128.00");
} }
@Test @Test

View File

@ -115,7 +115,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
.map(s -> s.replace("hs_office_", "")) .map(s -> s.replace("hs_office_", ""))
.containsExactlyInAnyOrder(Array.fromFormatted( .containsExactlyInAnyOrder(Array.fromFormatted(
initialGrantNames, 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)); null));
} }
@ -142,17 +142,17 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
// then // then
allTheseCoopAssetsTransactionsAreReturned( allTheseCoopAssetsTransactionsAreReturned(
result, result,
"CoopAssetsTransaction(10001, 2010-03-15, DEPOSIT, 320.00, ref 10001-1, initial deposit)", "CoopAssetsTransaction(1000101, 2010-03-15, DEPOSIT, 320.00, ref 1000101-1, initial deposit)",
"CoopAssetsTransaction(10001, 2021-09-01, DISBURSAL, -128.00, ref 10001-2, partial disbursal)", "CoopAssetsTransaction(1000101, 2021-09-01, DISBURSAL, -128.00, ref 1000101-2, partial disbursal)",
"CoopAssetsTransaction(10001, 2022-10-20, ADJUSTMENT, 128.00, ref 10001-3, some adjustment)", "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(1000202, 2010-03-15, DEPOSIT, 320.00, ref 1000202-1, initial deposit)",
"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)",
"CoopAssetsTransaction(10002, 2022-10-20, ADJUSTMENT, 128.00, ref 10002-3, some adjustment)", "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(1000303, 2010-03-15, DEPOSIT, 320.00, ref 1000303-1, initial deposit)",
"CoopAssetsTransaction(10003, 2021-09-01, DISBURSAL, -128.00, ref 10003-2, partial disbursal)", "CoopAssetsTransaction(1000303, 2021-09-01, DISBURSAL, -128.00, ref 1000303-2, partial disbursal)",
"CoopAssetsTransaction(10003, 2022-10-20, ADJUSTMENT, 128.00, ref 10003-3, some adjustment)"); "CoopAssetsTransaction(1000303, 2022-10-20, ADJUSTMENT, 128.00, ref 1000303-3, some adjustment)");
} }
@Test @Test
@ -170,9 +170,9 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
// then // then
allTheseCoopAssetsTransactionsAreReturned( allTheseCoopAssetsTransactionsAreReturned(
result, result,
"CoopAssetsTransaction(10002, 2010-03-15, DEPOSIT, 320.00, ref 10002-1, initial deposit)", "CoopAssetsTransaction(1000202, 2010-03-15, DEPOSIT, 320.00, ref 1000202-1, initial deposit)",
"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)",
"CoopAssetsTransaction(10002, 2022-10-20, ADJUSTMENT, 128.00, ref 10002-3, some adjustment)"); "CoopAssetsTransaction(1000202, 2022-10-20, ADJUSTMENT, 128.00, ref 1000202-3, some adjustment)");
} }
@Test @Test
@ -191,7 +191,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
// then // then
allTheseCoopAssetsTransactionsAreReturned( allTheseCoopAssetsTransactionsAreReturned(
result, 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 @Test
@ -208,9 +208,9 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
// then: // then:
exactlyTheseCoopAssetsTransactionsAreReturned( exactlyTheseCoopAssetsTransactionsAreReturned(
result, result,
"CoopAssetsTransaction(10001, 2010-03-15, DEPOSIT, 320.00, ref 10001-1, initial deposit)", "CoopAssetsTransaction(1000101, 2010-03-15, DEPOSIT, 320.00, ref 1000101-1, initial deposit)",
"CoopAssetsTransaction(10001, 2021-09-01, DISBURSAL, -128.00, ref 10001-2, partial disbursal)", "CoopAssetsTransaction(1000101, 2021-09-01, DISBURSAL, -128.00, ref 1000101-2, partial disbursal)",
"CoopAssetsTransaction(10001, 2022-10-20, ADJUSTMENT, 128.00, ref 10001-3, some adjustment)"); "CoopAssetsTransaction(1000101, 2022-10-20, ADJUSTMENT, 128.00, ref 1000101-3, some adjustment)");
} }
} }
@ -229,8 +229,8 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
// then // then
assertThat(customerLogEntries).map(Arrays::toString).contains( assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating coopAssetsTransaction test-data 10001, hs_office_coopassetstransaction, INSERT]", "[creating coopAssetsTransaction test-data 1000101, hs_office_coopassetstransaction, INSERT]",
"[creating coopAssetsTransaction test-data 10002, hs_office_coopassetstransaction, INSERT]"); "[creating coopAssetsTransaction test-data 1000202, hs_office_coopassetstransaction, INSERT]");
} }
@BeforeEach @BeforeEach

View File

@ -84,21 +84,21 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
"transactionType": "SUBSCRIPTION", "transactionType": "SUBSCRIPTION",
"shareCount": 4, "shareCount": 4,
"valueDate": "2010-03-15", "valueDate": "2010-03-15",
"reference": "ref 10002-1", "reference": "ref 1000202-1",
"comment": "initial subscription" "comment": "initial subscription"
}, },
{ {
"transactionType": "CANCELLATION", "transactionType": "CANCELLATION",
"shareCount": -2, "shareCount": -2,
"valueDate": "2021-09-01", "valueDate": "2021-09-01",
"reference": "ref 10002-2", "reference": "ref 1000202-2",
"comment": "cancelling some" "comment": "cancelling some"
}, },
{ {
"transactionType": "ADJUSTMENT", "transactionType": "ADJUSTMENT",
"shareCount": 2, "shareCount": 2,
"valueDate": "2022-10-20", "valueDate": "2022-10-20",
"reference": "ref 10002-3", "reference": "ref 1000202-3",
"comment": "some adjustment" "comment": "some adjustment"
} }
] ]
@ -118,7 +118,7 @@ class HsOfficeCoopSharesTransactionControllerAcceptanceTest {
"transactionType": "CANCELLATION", "transactionType": "CANCELLATION",
"shareCount": -2, "shareCount": -2,
"valueDate": "2021-09-01", "valueDate": "2021-09-01",
"reference": "ref 10002-2", "reference": "ref 1000202-2",
"comment": "cancelling some" "comment": "cancelling some"
} }
] ]

View File

@ -22,14 +22,14 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
void toStringContainsAlmostAllPropertiesAccount() { void toStringContainsAlmostAllPropertiesAccount() {
final var result = givenCoopSharesTransaction.toString(); 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 @Test
void toShortStringContainsOnlyMemberNumberAndShareCountOnly() { void toShortStringContainsOnlyMemberNumberAndShareCountOnly() {
final var result = givenCoopSharesTransaction.toShortString(); final var result = givenCoopSharesTransaction.toShortString();
assertThat(result).isEqualTo("300001+4"); assertThat(result).isEqualTo("1000101+4");
} }
@Test @Test

View File

@ -230,8 +230,8 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
// then // then
assertThat(customerLogEntries).map(Arrays::toString).contains( assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating coopSharesTransaction test-data 10001, hs_office_coopsharestransaction, INSERT]", "[creating coopSharesTransaction test-data 1000101, hs_office_coopsharestransaction, INSERT]",
"[creating coopSharesTransaction test-data 10002, hs_office_coopsharestransaction, INSERT]"); "[creating coopSharesTransaction test-data 1000202, hs_office_coopsharestransaction, INSERT]");
} }
@BeforeEach @BeforeEach

View File

@ -27,14 +27,14 @@ class HsOfficeMembershipEntityUnitTest {
void toStringContainsAllProps() { void toStringContainsAllProps() {
final var result = givenMembership.toString(); 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 @Test
void toShortStringContainsMemberNumberSuffixOnly() { void toShortStringContainsMemberNumberSuffixOnly() {
final var result = givenMembership.toShortString(); final var result = givenMembership.toShortString();
assertThat(result).isEqualTo("1000101"); assertThat(result).isEqualTo("M-1000101");
} }
@Test @Test

View File

@ -108,7 +108,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0);
final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("First").get(0); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("First").get(0);
final var newMembership = toCleanup(HsOfficeMembershipEntity.builder() final var newMembership = toCleanup(HsOfficeMembershipEntity.builder()
.memberNumberSuffix("02") .memberNumberSuffix("07")
.partner(givenPartner) .partner(givenPartner)
.mainDebitor(givenDebitor) .mainDebitor(givenDebitor)
.validity(Range.closedInfinite(LocalDate.parse("2020-01-01"))) .validity(Range.closedInfinite(LocalDate.parse("2020-01-01")))
@ -121,11 +121,11 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
final var all = rawRoleRepo.findAll(); final var all = rawRoleRepo.findAll();
assertThat(roleNamesOf(all)).containsExactlyInAnyOrder(Array.from( assertThat(roleNamesOf(all)).containsExactlyInAnyOrder(Array.from(
initialRoleNames, initialRoleNames,
"hs_office_membership#20002:FirstGmbH-firstcontact.admin", "hs_office_membership#1000107:FirstGmbH-firstcontact.admin",
"hs_office_membership#20002:FirstGmbH-firstcontact.agent", "hs_office_membership#1000107:FirstGmbH-firstcontact.agent",
"hs_office_membership#20002:FirstGmbH-firstcontact.guest", "hs_office_membership#1000107:FirstGmbH-firstcontact.guest",
"hs_office_membership#20002:FirstGmbH-firstcontact.owner", "hs_office_membership#1000107:FirstGmbH-firstcontact.owner",
"hs_office_membership#20002:FirstGmbH-firstcontact.tenant")); "hs_office_membership#1000107:FirstGmbH-firstcontact.tenant"));
assertThat(grantDisplaysOf(rawGrantRepo.findAll())) assertThat(grantDisplaysOf(rawGrantRepo.findAll()))
.map(s -> s.replace("GmbH-firstcontact", "")) .map(s -> s.replace("GmbH-firstcontact", ""))
.map(s -> s.replace("hs_office_", "")) .map(s -> s.replace("hs_office_", ""))
@ -133,33 +133,33 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
initialGrantNames, initialGrantNames,
// owner // owner
"{ grant perm * on membership#20002:First to role membership#20002:First.owner by system and assume }", "{ grant perm * on membership#1000107:First to role membership#1000107:First.owner by system and assume }",
"{ grant role membership#20002:First.owner to role global#global.admin by system and assume }", "{ grant role membership#1000107:First.owner to role global#global.admin by system and assume }",
// admin // admin
"{ grant perm edit on membership#20002:First to role membership#20002:First.admin by system and assume }", "{ grant perm edit on membership#1000107:First to role membership#1000107:First.admin by system and assume }",
"{ grant role membership#20002:First.admin to role membership#20002:First.owner by system and assume }", "{ grant role membership#1000107:First.admin to role membership#1000107:First.owner by system and assume }",
// agent // agent
"{ grant role membership#20002:First.agent to role membership#20002:First.admin 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#20002:First.agent by system and assume }", "{ grant role partner#10001:First.tenant to role membership#1000107: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#1000107: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 membership#1000107: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 debitor#1000111:First.tenant to role membership#1000107:First.agent by system and assume }",
// tenant // tenant
"{ grant role membership#20002:First.tenant to role membership#20002: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#20002:First.tenant 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#20002: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#20002:First.tenant to role debitor#1000111:First.agent 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 // guest
"{ grant perm view on membership#20002:First to role membership#20002:First.guest by system and assume }", "{ grant perm view on membership#1000107:First to role membership#1000107: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#1000107:First.guest to role membership#1000107: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#1000107: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 role membership#1000107:First.guest to role debitor#1000111:First.tenant by system and assume }",
null)); null));
} }
@ -179,14 +179,14 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
// when // when
final var result = membershipRepo.findMembershipsByOptionalPartherNumber(null); final var result = membershipRepo.findMembershipsByOptionalPartnerUuid(null);
// then // then
exactlyTheseMembershipsAreReturned( exactlyTheseMembershipsAreReturned(
result, result,
"Membership(10001, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)", "Membership(M-1000101, LEGAL First GmbH, 1000111, [2022-10-01,), NONE)",
"Membership(10002, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)", "Membership(M-1000202, LEGAL Second e.K., 1000212, [2022-10-01,), NONE)",
"Membership(10003, SOLE_REPRESENTATION Third OHG, 1000313, [2022-10-01,), NONE)"); "Membership(M-1000303, SOLE_REPRESENTATION Third OHG, 1000313, [2022-10-01,), NONE)");
} }
@Test @Test
@ -196,10 +196,11 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0);
// when // when
final var result = membershipRepo.findMembershipsByOptionalPartherNumber(givenPartner.getUuid()); final var result = membershipRepo.findMembershipsByOptionalPartnerUuid(givenPartner.getUuid());
// then // 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 @Test
@ -208,10 +209,11 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTest {
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
// when // when
final var result = membershipRepo.findMembershipsByOptionalPartherNumber(null); final var result = membershipRepo.findMembershipsByMemberNumber(1000202);
// then // 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)");
} }
} }

View File

@ -182,9 +182,9 @@ public class ImportOfficeData extends ContextBasedTest {
"""); """);
assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace(""" assertThat(toFormattedString(memberships)).isEqualToIgnoringWhitespace("""
{ {
17=Membership(10017, null null, null, 1001700, [2000-12-06,), NONE), 17=Membership(1001700, null null, null, 1001700, [2000-12-06,), NONE),
20=Membership(10020, null null, null, 1002000, [2000-12-06,2016-01-01), UNKNOWN), 20=Membership(1002000, null null, null, 1002000, [2000-12-06,2016-01-01), UNKNOWN),
22=Membership(11022, null null, null, 1102200, [2021-04-01,), NONE) 22=Membership(1102200, null null, null, 1102200, [2021-04-01,), NONE)
} }
"""); """);
} }