Compare commits
2 Commits
fb974a3b43
...
90e626eac0
Author | SHA1 | Date | |
---|---|---|---|
|
90e626eac0 | ||
|
1eaef1e18c |
4
.aliases
4
.aliases
@ -79,5 +79,5 @@ alias pg-sql-restore='gunzip --stdout | docker exec -i hsadmin-ng-postgres psql
|
||||
alias fp='grep -r '@Accepts' src | sed -e 's/^.*@/@/g' | sort -u | wc -l'
|
||||
|
||||
alias gw-spotless='./gradlew spotlessApply -x pitest -x test -x :processResources'
|
||||
alias gw-test='. .aliases; ./gradlew test'
|
||||
alias gw-check='. .aliases; gw check -x pitest -x :dependencyCheckAnalyze'
|
||||
alias gw-test='. .aliases; ./gradlew test importOfficeData'
|
||||
alias gw-check='. .aliases; gw test importOfficeData check -x pitest -x :dependencyCheckAnalyze'
|
||||
|
@ -25,7 +25,7 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
||||
public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUuid {
|
||||
|
||||
private static Stringify<HsOfficeCoopSharesTransactionEntity> stringify = stringify(HsOfficeCoopSharesTransactionEntity.class)
|
||||
.withProp(HsOfficeCoopSharesTransactionEntity::getMemberNumber)
|
||||
.withProp(HsOfficeCoopSharesTransactionEntity::getMemberNumberTagged)
|
||||
.withProp(HsOfficeCoopSharesTransactionEntity::getValueDate)
|
||||
.withProp(HsOfficeCoopSharesTransactionEntity::getTransactionType)
|
||||
.withProp(HsOfficeCoopSharesTransactionEntity::getShareCount)
|
||||
@ -76,12 +76,12 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, HasUu
|
||||
return stringify.apply(this);
|
||||
}
|
||||
|
||||
public Integer getMemberNumber() {
|
||||
return ofNullable(membership).map(HsOfficeMembershipEntity::getMemberNumber).orElse(null);
|
||||
private String getMemberNumberTagged() {
|
||||
return ofNullable(membership).map(HsOfficeMembershipEntity::toShortString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toShortString() {
|
||||
return "M-%s%+d".formatted(getMemberNumber(), shareCount);
|
||||
return "%s%+d".formatted(getMemberNumberTagged(), shareCount);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import net.hostsharing.hsadminng.errors.DisplayName;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.migration.HasUuid;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
||||
import net.hostsharing.hsadminng.stringify.Stringify;
|
||||
import net.hostsharing.hsadminng.stringify.Stringifyable;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
@ -39,10 +40,16 @@ public class HsOfficePartnerEntity implements Stringifyable, HasUuid {
|
||||
@Column(name = "partnernumber", columnDefinition = "numeric(5) not null")
|
||||
private Integer partnerNumber;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "partnerroleuuid", nullable = false)
|
||||
private HsOfficeRelationshipEntity partnerRole;
|
||||
|
||||
// TODO: remove, is replaced by partnerRole
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "personuuid", nullable = false)
|
||||
private HsOfficePersonEntity person;
|
||||
|
||||
// TODO: remove, is replaced by partnerRole
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "contactuuid", nullable = false)
|
||||
private HsOfficeContactEntity contact;
|
||||
|
@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.hs.office.relationship;
|
||||
|
||||
public enum HsOfficeRelationshipType {
|
||||
UNKNOWN,
|
||||
PARTNER,
|
||||
EX_PARTNER,
|
||||
REPRESENTATIVE,
|
||||
VIP_CONTACT,
|
||||
|
@ -61,7 +61,7 @@ do language plpgsql $$
|
||||
call createHsOfficeContactTestData('first contact');
|
||||
call createHsOfficeContactTestData('second contact');
|
||||
call createHsOfficeContactTestData('third contact');
|
||||
call createHsOfficeContactTestData('forth contact');
|
||||
call createHsOfficeContactTestData('fourth contact');
|
||||
call createHsOfficeContactTestData('fifth contact');
|
||||
call createHsOfficeContactTestData('sixth contact');
|
||||
call createHsOfficeContactTestData('seventh contact');
|
||||
|
@ -46,7 +46,7 @@ create or replace procedure createTestPersonTestData(
|
||||
begin
|
||||
for t in startCount..endCount
|
||||
loop
|
||||
call createHsOfficePersonTestData('LEGAL', intToVarChar(t, 4));
|
||||
call createHsOfficePersonTestData('LP', intToVarChar(t, 4));
|
||||
commit;
|
||||
end loop;
|
||||
end; $$;
|
||||
@ -59,11 +59,15 @@ end; $$;
|
||||
|
||||
do language plpgsql $$
|
||||
begin
|
||||
call createHsOfficePersonTestData('LP', 'Hostsharing eG');
|
||||
call createHsOfficePersonTestData('LP', 'First GmbH');
|
||||
call createHsOfficePersonTestData('NP', null, 'Firby', 'Susan');
|
||||
call createHsOfficePersonTestData('NP', null, 'Smith', 'Peter');
|
||||
call createHsOfficePersonTestData('NP', null, 'Tucker', 'Jack');
|
||||
call createHsOfficePersonTestData('NP', null, 'Fouler', 'Ellie');
|
||||
call createHsOfficePersonTestData('LP', 'Second e.K.', 'Sandra', 'Miller');
|
||||
call createHsOfficePersonTestData('IF', 'Third OHG');
|
||||
call createHsOfficePersonTestData('IF', 'Fourth e.G.');
|
||||
call createHsOfficePersonTestData('IF', 'Fourth eG');
|
||||
call createHsOfficePersonTestData('UF', 'Erben Bessler', 'Mel', 'Bessler');
|
||||
call createHsOfficePersonTestData('NP', null, 'Bessler', 'Anita');
|
||||
call createHsOfficePersonTestData('NP', null, 'Winkler', 'Paul');
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
CREATE TYPE HsOfficeRelationshipType AS ENUM (
|
||||
'UNKNOWN',
|
||||
'PARTNER',
|
||||
'EX_PARTNER',
|
||||
'REPRESENTATIVE',
|
||||
'VIP_CONTACT',
|
@ -9,9 +9,9 @@
|
||||
Creates a single relationship test record.
|
||||
*/
|
||||
create or replace procedure createHsOfficeRelationshipTestData(
|
||||
anchorPersonTradeName varchar,
|
||||
holderPersonFamilyName varchar,
|
||||
holderPersonName varchar,
|
||||
relationshipType HsOfficeRelationshipType,
|
||||
anchorPersonTradeName varchar,
|
||||
contactLabel varchar)
|
||||
language plpgsql as $$
|
||||
declare
|
||||
@ -22,14 +22,27 @@ declare
|
||||
contact hs_office_contact;
|
||||
|
||||
begin
|
||||
idName := cleanIdentifier( anchorPersonTradeName || '-' || holderPersonFamilyName);
|
||||
idName := cleanIdentifier( anchorPersonTradeName || '-' || holderPersonName);
|
||||
currentTask := 'creating relationship test-data ' || idName;
|
||||
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global.admin');
|
||||
execute format('set local hsadminng.currentTask to %L', currentTask);
|
||||
|
||||
select p.* from hs_office_person p where p.tradeName = anchorPersonTradeName into anchorPerson;
|
||||
select p.* from hs_office_person p where p.familyName = holderPersonFamilyName into holderPerson;
|
||||
if anchorPerson is null then
|
||||
raise exception 'anchorPerson "%" not found', anchorPersonTradeName;
|
||||
end if;
|
||||
|
||||
select p.* from hs_office_person p
|
||||
where p.tradeName = holderPersonName or p.familyName = holderPersonName
|
||||
into holderPerson;
|
||||
if holderPerson is null then
|
||||
raise exception 'holderPerson "%" not found', holderPersonName;
|
||||
end if;
|
||||
|
||||
select c.* from hs_office_contact c where c.label = contactLabel into contact;
|
||||
if contact is null then
|
||||
raise exception 'contact "%" not found', contactLabel;
|
||||
end if;
|
||||
|
||||
raise notice 'creating test relationship: %', idName;
|
||||
raise notice '- using anchor person (%): %', anchorPerson.uuid, anchorPerson;
|
||||
@ -71,11 +84,20 @@ end; $$;
|
||||
|
||||
do language plpgsql $$
|
||||
begin
|
||||
call createHsOfficeRelationshipTestData('First GmbH', 'Smith', 'REPRESENTATIVE', 'first contact');
|
||||
call createHsOfficeRelationshipTestData('First GmbH', 'PARTNER', 'Hostsharing eG', 'first contact');
|
||||
call createHsOfficeRelationshipTestData('Firby', 'REPRESENTATIVE', 'First GmbH', 'first contact');
|
||||
|
||||
call createHsOfficeRelationshipTestData('Second e.K.', 'Smith', 'REPRESENTATIVE', 'second contact');
|
||||
call createHsOfficeRelationshipTestData('Second e.K.', 'PARTNER', 'Hostsharing eG', 'second contact');
|
||||
call createHsOfficeRelationshipTestData('Smith', 'REPRESENTATIVE', 'Second e.K.', 'second contact');
|
||||
|
||||
call createHsOfficeRelationshipTestData('Third OHG', 'PARTNER', 'Hostsharing eG', 'third contact');
|
||||
call createHsOfficeRelationshipTestData('Tucker', 'REPRESENTATIVE', 'Third OHG', 'third contact');
|
||||
|
||||
call createHsOfficeRelationshipTestData('Fourth eG', 'PARTNER', 'Hostsharing eG', 'fourth contact');
|
||||
call createHsOfficeRelationshipTestData('Fouler', 'REPRESENTATIVE', 'Third OHG', 'third contact');
|
||||
|
||||
call createHsOfficeRelationshipTestData('Smith', 'PARTNER', 'Hostsharing eG', 'sixth contact');
|
||||
|
||||
call createHsOfficeRelationshipTestData('Third OHG', 'Smith', 'REPRESENTATIVE', 'third contact');
|
||||
end;
|
||||
$$;
|
||||
--//
|
@ -33,8 +33,9 @@ create table hs_office_partner
|
||||
(
|
||||
uuid uuid unique references RbacObject (uuid) initially deferred,
|
||||
partnerNumber numeric(5),
|
||||
personUuid uuid not null references hs_office_person(uuid),
|
||||
contactUuid uuid not null references hs_office_contact(uuid),
|
||||
partnerRoleUuid uuid not null references hs_office_relationship(uuid),
|
||||
personUuid uuid not null references hs_office_person(uuid), -- TODO: remove, replaced by partnerRoleUuid
|
||||
contactUuid uuid not null references hs_office_contact(uuid), -- TODO: remove, replaced by partnerRoleUuid
|
||||
detailsUuid uuid not null references hs_office_partner_details(uuid) on delete cascade
|
||||
);
|
||||
--//
|
@ -179,9 +179,11 @@ call generateRbacIdentityView('hs_office_partner', $idName$
|
||||
call generateRbacRestrictedView('hs_office_partner',
|
||||
'(select idName from hs_office_person_iv p where p.uuid = target.personUuid)',
|
||||
$updates$
|
||||
partherRoleUuid = new.partnerRoleUuid,
|
||||
personUuid = new.personUuid,
|
||||
contactUuid = new.contactUuid
|
||||
$updates$);
|
||||
-- partnerRoleUuid = new.partnerRoleUuid,
|
||||
--//
|
||||
|
||||
|
@ -9,30 +9,49 @@
|
||||
Creates a single partner test record.
|
||||
*/
|
||||
create or replace procedure createHsOfficePartnerTestData(
|
||||
mandantTradeName varchar,
|
||||
partnerNumber numeric(5),
|
||||
personTradeOrFamilyName varchar,
|
||||
partnerPersonName varchar,
|
||||
contactLabel varchar )
|
||||
language plpgsql as $$
|
||||
declare
|
||||
currentTask varchar;
|
||||
idName varchar;
|
||||
mandantPerson hs_office_person;
|
||||
partnerRole hs_office_relationship;
|
||||
relatedPerson hs_office_person;
|
||||
relatedContact hs_office_contact;
|
||||
relatedDetailsUuid uuid;
|
||||
begin
|
||||
idName := cleanIdentifier( personTradeOrFamilyName|| '-' || contactLabel);
|
||||
idName := cleanIdentifier( partnerPersonName|| '-' || contactLabel);
|
||||
currentTask := 'creating partner test-data ' || idName;
|
||||
call defineContext(currentTask, null, 'superuser-alex@hostsharing.net', 'global#global.admin');
|
||||
execute format('set local hsadminng.currentTask to %L', currentTask);
|
||||
|
||||
select p.* from hs_office_person p
|
||||
where p.tradeName = personTradeOrFamilyName or p.familyName = personTradeOrFamilyName
|
||||
where p.tradeName = mandantTradeName
|
||||
into mandantPerson;
|
||||
if mandantPerson is null then
|
||||
raise exception 'mandant "%" not found', mandantTradeName;
|
||||
end if;
|
||||
|
||||
select p.* from hs_office_person p
|
||||
where p.tradeName = partnerPersonName or p.familyName = partnerPersonName
|
||||
into relatedPerson;
|
||||
select c.* from hs_office_contact c
|
||||
where c.label = contactLabel
|
||||
into relatedContact;
|
||||
|
||||
select r.* from hs_office_relationship r
|
||||
where r.reltype = 'PARTNER'
|
||||
and r.relanchoruuid = mandantPerson.uuid and r.relholderuuid = relatedPerson.uuid
|
||||
into partnerRole;
|
||||
if partnerRole is null then
|
||||
raise exception 'partnerRole "%"-"%" not found', mandantPerson.tradename, partnerPersonName;
|
||||
end if;
|
||||
|
||||
raise notice 'creating test partner: %', idName;
|
||||
raise notice '- using partnerRole (%): %', partnerRole.uuid, partnerRole;
|
||||
raise notice '- using person (%): %', relatedPerson.uuid, relatedPerson;
|
||||
raise notice '- using contact (%): %', relatedContact.uuid, relatedContact;
|
||||
|
||||
@ -49,8 +68,8 @@ begin
|
||||
end if;
|
||||
|
||||
insert
|
||||
into hs_office_partner (uuid, partnerNumber, personuuid, contactuuid, detailsUuid)
|
||||
values (uuid_generate_v4(), partnerNumber, relatedPerson.uuid, relatedContact.uuid, relatedDetailsUuid);
|
||||
into hs_office_partner (uuid, partnerNumber, partnerRoleUuid, personuuid, contactuuid, detailsUuid)
|
||||
values (uuid_generate_v4(), partnerNumber, partnerRole.uuid, relatedPerson.uuid, relatedContact.uuid, relatedDetailsUuid);
|
||||
end; $$;
|
||||
--//
|
||||
|
||||
@ -62,11 +81,11 @@ end; $$;
|
||||
|
||||
do language plpgsql $$
|
||||
begin
|
||||
call createHsOfficePartnerTestData(10001, 'First GmbH', 'first contact');
|
||||
call createHsOfficePartnerTestData(10002, 'Second e.K.', 'second contact');
|
||||
call createHsOfficePartnerTestData(10003, 'Third OHG', 'third contact');
|
||||
call createHsOfficePartnerTestData(10004, 'Fourth e.G.', 'forth contact');
|
||||
call createHsOfficePartnerTestData(10010, 'Smith', 'fifth contact');
|
||||
call createHsOfficePartnerTestData('Hostsharing eG', 10001, 'First GmbH', 'first contact');
|
||||
call createHsOfficePartnerTestData('Hostsharing eG', 10002, 'Second e.K.', 'second contact');
|
||||
call createHsOfficePartnerTestData('Hostsharing eG', 10003, 'Third OHG', 'third contact');
|
||||
call createHsOfficePartnerTestData('Hostsharing eG', 10004, 'Fourth eG', 'fourth contact');
|
||||
call createHsOfficePartnerTestData('Hostsharing eG', 10010, 'Smith', 'fifth contact');
|
||||
end;
|
||||
$$;
|
||||
--//
|
@ -41,7 +41,7 @@ do language plpgsql $$
|
||||
call createHsOfficeBankAccountTestData('Peter Smith', 'DE02500105170137075030', 'INGDDEFF');
|
||||
call createHsOfficeBankAccountTestData('Second e.K.', 'DE02100500000054540402', 'BELADEBE');
|
||||
call createHsOfficeBankAccountTestData('Third OHG', 'DE02300209000106531065', 'CMCIDEDD');
|
||||
call createHsOfficeBankAccountTestData('Fourth e.G.', 'DE02200505501015871393', 'HASPDEHH');
|
||||
call createHsOfficeBankAccountTestData('Fourth eG', 'DE02200505501015871393', 'HASPDEHH');
|
||||
call createHsOfficeBankAccountTestData('Mel Bessler', 'DE02100100100006820101', 'PBNKDEFF');
|
||||
call createHsOfficeBankAccountTestData('Anita Bessler', 'DE02300606010002474689', 'DAAEDEDD');
|
||||
call createHsOfficeBankAccountTestData('Paul Winkler', 'DE02600501010002034304', 'SOLADEST600');
|
||||
|
@ -66,21 +66,21 @@ databaseChangeLog:
|
||||
- include:
|
||||
file: db/changelog/218-hs-office-person-test-data.sql
|
||||
- include:
|
||||
file: db/changelog/220-hs-office-partner.sql
|
||||
file: db/changelog/220-hs-office-relationship.sql
|
||||
- include:
|
||||
file: db/changelog/223-hs-office-partner-rbac.sql
|
||||
file: db/changelog/223-hs-office-relationship-rbac.sql
|
||||
- include:
|
||||
file: db/changelog/224-hs-office-partner-details-rbac.sql
|
||||
file: db/changelog/228-hs-office-relationship-test-data.sql
|
||||
- include:
|
||||
file: db/changelog/226-hs-office-partner-migration.sql
|
||||
file: db/changelog/230-hs-office-partner.sql
|
||||
- include:
|
||||
file: db/changelog/228-hs-office-partner-test-data.sql
|
||||
file: db/changelog/233-hs-office-partner-rbac.sql
|
||||
- include:
|
||||
file: db/changelog/230-hs-office-relationship.sql
|
||||
file: db/changelog/234-hs-office-partner-details-rbac.sql
|
||||
- include:
|
||||
file: db/changelog/233-hs-office-relationship-rbac.sql
|
||||
file: db/changelog/236-hs-office-partner-migration.sql
|
||||
- include:
|
||||
file: db/changelog/238-hs-office-relationship-test-data.sql
|
||||
file: db/changelog/238-hs-office-partner-test-data.sql
|
||||
- include:
|
||||
file: db/changelog/240-hs-office-bankaccount.sql
|
||||
- include:
|
||||
|
@ -75,7 +75,7 @@ class HsOfficeBankAccountControllerAcceptanceTest {
|
||||
"bic": "BYLADEM1001"
|
||||
},
|
||||
{
|
||||
"holder": "Fourth e.G.",
|
||||
"holder": "Fourth eG",
|
||||
"iban": "DE02200505501015871393",
|
||||
"bic": "HASPDEHH"
|
||||
},
|
||||
|
@ -147,7 +147,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTest {
|
||||
result,
|
||||
"Anita Bessler",
|
||||
"First GmbH",
|
||||
"Fourth e.G.",
|
||||
"Fourth eG",
|
||||
"Mel Bessler",
|
||||
"Paul Winkler",
|
||||
"Peter Smith",
|
||||
|
@ -73,7 +73,7 @@ class HsOfficeContactControllerAcceptanceTest {
|
||||
{ "label": "first contact" },
|
||||
{ "label": "second contact" },
|
||||
{ "label": "third contact" },
|
||||
{ "label": "forth contact" },
|
||||
{ "label": "fourth contact" },
|
||||
{ "label": "fifth contact" },
|
||||
{ "label": "sixth contact" },
|
||||
{ "label": "seventh contact" },
|
||||
|
@ -22,7 +22,7 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
|
||||
void toStringContainsAlmostAllPropertiesAccount() {
|
||||
final var result = givenCoopSharesTransaction.toString();
|
||||
|
||||
assertThat(result).isEqualTo("CoopShareTransaction(1000101, 2020-01-01, SUBSCRIPTION, 4, some-ref)");
|
||||
assertThat(result).isEqualTo("CoopShareTransaction(M-1000101, 2020-01-01, SUBSCRIPTION, 4, some-ref)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -36,7 +36,7 @@ class HsOfficeCoopSharesTransactionEntityUnitTest {
|
||||
void toStringEmptyTransactionDoesNotThrowException() {
|
||||
final var result = givenEmptyCoopSharesTransaction.toString();
|
||||
|
||||
assertThat(result).isEqualTo("CoopShareTransaction(0)");
|
||||
assertThat(result).isEqualTo("CoopShareTransaction(M-0)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -419,7 +419,7 @@ class HsOfficeDebitorControllerAcceptanceTest {
|
||||
assertThat(partner.getPartner().getPerson().getTradeName()).isEqualTo(givenDebitor.getPartner()
|
||||
.getPerson()
|
||||
.getTradeName());
|
||||
assertThat(partner.getBillingContact().getLabel()).isEqualTo("forth contact");
|
||||
assertThat(partner.getBillingContact().getLabel()).isEqualTo("fourth contact");
|
||||
assertThat(partner.getVatId()).isEqualTo("VAT222222");
|
||||
assertThat(partner.getVatCountryCode()).isEqualTo("AA");
|
||||
assertThat(partner.isVatBusiness()).isEqualTo(true);
|
||||
@ -500,11 +500,11 @@ class HsOfficeDebitorControllerAcceptanceTest {
|
||||
void contactAdminUser_canNotDeleteRelatedDebitor() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = givenSomeTemporaryDebitor();
|
||||
assertThat(givenDebitor.getBillingContact().getLabel()).isEqualTo("forth contact");
|
||||
assertThat(givenDebitor.getBillingContact().getLabel()).isEqualTo("fourth contact");
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
.header("current-user", "contact-admin@forthcontact.example.com")
|
||||
.header("current-user", "contact-admin@fourthcontact.example.com")
|
||||
.port(port)
|
||||
.when()
|
||||
.delete("http://localhost/api/hs/office/debitors/" + givenDebitor.getUuid())
|
||||
@ -520,7 +520,7 @@ class HsOfficeDebitorControllerAcceptanceTest {
|
||||
void normalUser_canNotDeleteUnrelatedDebitor() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = givenSomeTemporaryDebitor();
|
||||
assertThat(givenDebitor.getBillingContact().getLabel()).isEqualTo("forth contact");
|
||||
assertThat(givenDebitor.getBillingContact().getLabel()).isEqualTo("fourth contact");
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
@ -540,7 +540,7 @@ class HsOfficeDebitorControllerAcceptanceTest {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix(++nextDebitorSuffix)
|
||||
.billable(true)
|
||||
|
@ -128,16 +128,16 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var initialGrantNames = grantDisplaysOf(rawGrantRepo.findAll()).stream()
|
||||
// some search+replace to make the output fit into the screen width
|
||||
.map(s -> s.replace("superuser-alex@hostsharing.net", "superuser-alex"))
|
||||
.map(s -> s.replace("22Fourthe.G.-forthcontact", "FeG"))
|
||||
.map(s -> s.replace("Fourthe.G.-forthcontact", "FeG"))
|
||||
.map(s -> s.replace("forthcontact", "4th"))
|
||||
.map(s -> s.replace("22Fourthe.G.-fourthcontact", "FeG"))
|
||||
.map(s -> s.replace("Fourthe.G.-fourthcontact", "FeG"))
|
||||
.map(s -> s.replace("fourthcontact", "4th"))
|
||||
.map(s -> s.replace("hs_office_", ""))
|
||||
.toList();
|
||||
|
||||
// when
|
||||
attempt(em, () -> {
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix((byte)22)
|
||||
.partner(givenPartner)
|
||||
@ -151,16 +151,16 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// then
|
||||
assertThat(roleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
||||
initialRoleNames,
|
||||
"hs_office_debitor#1000422:Fourthe.G.-forthcontact.owner",
|
||||
"hs_office_debitor#1000422:Fourthe.G.-forthcontact.admin",
|
||||
"hs_office_debitor#1000422:Fourthe.G.-forthcontact.agent",
|
||||
"hs_office_debitor#1000422:Fourthe.G.-forthcontact.tenant",
|
||||
"hs_office_debitor#1000422:Fourthe.G.-forthcontact.guest"));
|
||||
"hs_office_debitor#1000422:Fourthe.G.-fourthcontact.owner",
|
||||
"hs_office_debitor#1000422:Fourthe.G.-fourthcontact.admin",
|
||||
"hs_office_debitor#1000422:Fourthe.G.-fourthcontact.agent",
|
||||
"hs_office_debitor#1000422:Fourthe.G.-fourthcontact.tenant",
|
||||
"hs_office_debitor#1000422:Fourthe.G.-fourthcontact.guest"));
|
||||
assertThat(grantDisplaysOf(rawGrantRepo.findAll()))
|
||||
.map(s -> s.replace("superuser-alex@hostsharing.net", "superuser-alex"))
|
||||
.map(s -> s.replace("22Fourthe.G.-forthcontact", "FeG"))
|
||||
.map(s -> s.replace("Fourthe.G.-forthcontact", "FeG"))
|
||||
.map(s -> s.replace("forthcontact", "4th"))
|
||||
.map(s -> s.replace("22Fourthe.G.-fourthcontact", "FeG"))
|
||||
.map(s -> s.replace("Fourthe.G.-fourthcontact", "FeG"))
|
||||
.map(s -> s.replace("fourthcontact", "4th"))
|
||||
.map(s -> s.replace("hs_office_", ""))
|
||||
.containsExactlyInAnyOrder(Array.fromFormatted(
|
||||
initialGrantNames,
|
||||
@ -290,7 +290,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "fifth contact", "Fourth", "fif");
|
||||
assertThatDebitorIsVisibleForUserWithRole(
|
||||
givenDebitor,
|
||||
"hs_office_partner#10004:Fourthe.G.-forthcontact.admin");
|
||||
"hs_office_partner#10004:Fourthe.G.-fourthcontact.admin");
|
||||
assertThatDebitorActuallyInDatabase(givenDebitor);
|
||||
final var givenNewPartner = partnerRepo.findPartnerByOptionalNameLike("First").get(0);
|
||||
final var givenNewContact = contactRepo.findContactByOptionalLabelLike("sixth contact").get(0);
|
||||
@ -320,7 +320,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
// ... partner role was reassigned:
|
||||
assertThatDebitorIsNotVisibleForUserWithRole(
|
||||
result.returnedValue(),
|
||||
"hs_office_partner#10004:Fourthe.G.-forthcontact.agent");
|
||||
"hs_office_partner#10004:Fourthe.G.-fourthcontact.agent");
|
||||
assertThatDebitorIsVisibleForUserWithRole(
|
||||
result.returnedValue(),
|
||||
"hs_office_partner#10001:FirstGmbH-firstcontact.agent");
|
||||
@ -349,7 +349,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "fifth contact", null, "fig");
|
||||
assertThatDebitorIsVisibleForUserWithRole(
|
||||
givenDebitor,
|
||||
"hs_office_partner#10004:Fourthe.G.-forthcontact.admin");
|
||||
"hs_office_partner#10004:Fourthe.G.-fourthcontact.admin");
|
||||
assertThatDebitorActuallyInDatabase(givenDebitor);
|
||||
final var givenNewBankAccount = bankAccountRepo.findByOptionalHolderLike("first").get(0);
|
||||
|
||||
@ -379,7 +379,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "fifth contact", "Fourth", "fih");
|
||||
assertThatDebitorIsVisibleForUserWithRole(
|
||||
givenDebitor,
|
||||
"hs_office_partner#10004:Fourthe.G.-forthcontact.admin");
|
||||
"hs_office_partner#10004:Fourthe.G.-fourthcontact.admin");
|
||||
assertThatDebitorActuallyInDatabase(givenDebitor);
|
||||
|
||||
// when
|
||||
@ -408,12 +408,12 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var givenDebitor = givenSomeTemporaryDebitor("Fourth", "eighth", "Fourth", "eig");
|
||||
assertThatDebitorIsVisibleForUserWithRole(
|
||||
givenDebitor,
|
||||
"hs_office_partner#10004:Fourthe.G.-forthcontact.admin");
|
||||
"hs_office_partner#10004:Fourthe.G.-fourthcontact.admin");
|
||||
assertThatDebitorActuallyInDatabase(givenDebitor);
|
||||
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", "hs_office_partner#10004:Fourthe.G.-forthcontact.admin");
|
||||
context("superuser-alex@hostsharing.net", "hs_office_partner#10004:Fourthe.G.-fourthcontact.admin");
|
||||
givenDebitor.setVatId("NEW-VAT-ID");
|
||||
return debitorRepo.save(givenDebitor);
|
||||
});
|
||||
|
@ -225,6 +225,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
""");
|
||||
assertThat(toFormattedString(persons)).isEqualToIgnoringWhitespace("""
|
||||
{
|
||||
1=person(personType='LP', tradeName='Hostsharing eG'),
|
||||
1101=person(personType='NP', tradeName='', familyName='Mellies', givenName='Michael'),
|
||||
1200=person(personType='LP', tradeName='JM e.K.', familyName='', givenName=''),
|
||||
1201=person(personType='LP', tradeName='JM GmbH', familyName='Meyer-Billing', givenName='Jenny'),
|
||||
@ -249,14 +250,17 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
""");
|
||||
assertThat(toFormattedString(relationships)).isEqualToIgnoringWhitespace("""
|
||||
{
|
||||
2000000=rel(relAnchor='NP Mellies, Michael', relType='OPERATIONS', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
||||
2000001=rel(relAnchor='LP JM GmbH', relType='EX_PARTNER', relHolder='LP JM e.K.', contact='JM e.K.'),
|
||||
2000002=rel(relAnchor='LP JM GmbH', relType='OPERATIONS', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
||||
2000003=rel(relAnchor='LP JM GmbH', relType='VIP_CONTACT', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
||||
2000004=rel(relAnchor='LP JM GmbH', relType='REPRESENTATIVE', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
||||
2000005=rel(relAnchor='?? Test PS', relType='OPERATIONS', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||
2000006=rel(relAnchor='?? Test PS', relType='REPRESENTATIVE', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||
2000007=rel(relAnchor='NP Mellies, Michael', relType='REPRESENTATIVE', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies ')
|
||||
2000000=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
||||
2000001=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
||||
2000002=rel(relAnchor='LP Hostsharing eG', relType='PARTNER', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||
2000003=rel(relAnchor='NP Mellies, Michael', relType='OPERATIONS', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies '),
|
||||
2000004=rel(relAnchor='LP JM GmbH', relType='EX_PARTNER', relHolder='LP JM e.K.', contact='JM e.K.'),
|
||||
2000005=rel(relAnchor='LP JM GmbH', relType='OPERATIONS', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
||||
2000006=rel(relAnchor='LP JM GmbH', relType='VIP_CONTACT', relHolder='LP JM GmbH', contact='Herr Andrew Meyer-Operation , JM GmbH'),
|
||||
2000007=rel(relAnchor='LP JM GmbH', relType='REPRESENTATIVE', relHolder='LP JM GmbH', contact='Herr Philip Meyer-Contract , JM GmbH'),
|
||||
2000008=rel(relAnchor='?? Test PS', relType='OPERATIONS', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||
2000009=rel(relAnchor='?? Test PS', relType='REPRESENTATIVE', relHolder='?? Test PS', contact='Petra Schmidt , Test PS'),
|
||||
2000010=rel(relAnchor='NP Mellies, Michael', relType='REPRESENTATIVE', relHolder='NP Mellies, Michael', contact='Herr Michael Mellies ')
|
||||
}
|
||||
""");
|
||||
}
|
||||
@ -339,14 +343,14 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
|
||||
assertThat(toFormattedString(coopAssets)).isEqualToIgnoringWhitespace("""
|
||||
{
|
||||
30000=CoopAssetsTransaction(10017, 2000-12-06, DEPOSIT, 1280.00, for subscription A),
|
||||
31000=CoopAssetsTransaction(10020, 2000-12-06, DEPOSIT, 128.00, for subscription B),
|
||||
32000=CoopAssetsTransaction(10017, 2005-01-10, DEPOSIT, 2560.00, for subscription C),
|
||||
33001=CoopAssetsTransaction(10017, 2005-01-10, TRANSFER, -512.00, for transfer to 10),
|
||||
33002=CoopAssetsTransaction(10020, 2005-01-10, ADOPTION, 512.00, for transfer from 7),
|
||||
34001=CoopAssetsTransaction(10020, 2016-12-31, CLEARING, -8.00, for cancellation D),
|
||||
34002=CoopAssetsTransaction(10020, 2016-12-31, DISBURSAL, -100.00, for cancellation D),
|
||||
34003=CoopAssetsTransaction(10020, 2016-12-31, LOSS, -20.00, for cancellation D)
|
||||
30000=CoopAssetsTransaction(1001700, 2000-12-06, DEPOSIT, 1280.00, for subscription A),
|
||||
31000=CoopAssetsTransaction(1002000, 2000-12-06, DEPOSIT, 128.00, for subscription B),
|
||||
32000=CoopAssetsTransaction(1001700, 2005-01-10, DEPOSIT, 2560.00, for subscription C),
|
||||
33001=CoopAssetsTransaction(1001700, 2005-01-10, TRANSFER, -512.00, for transfer to 10),
|
||||
33002=CoopAssetsTransaction(1002000, 2005-01-10, ADOPTION, 512.00, for transfer from 7),
|
||||
34001=CoopAssetsTransaction(1002000, 2016-12-31, CLEARING, -8.00, for cancellation D),
|
||||
34002=CoopAssetsTransaction(1002000, 2016-12-31, DISBURSAL, -100.00, for cancellation D),
|
||||
34003=CoopAssetsTransaction(1002000, 2016-12-31, LOSS, -20.00, for cancellation D)
|
||||
}
|
||||
""");
|
||||
}
|
||||
@ -440,7 +444,6 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
private void deleteTestDataFromHsOfficeTables() {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context(rbacSuperuser);
|
||||
em.createNativeQuery("delete from hs_office_relationship where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_coopassetstransaction where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_coopassetstransaction_legacy_id where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_coopsharestransaction where true").executeUpdate();
|
||||
@ -452,6 +455,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
em.createNativeQuery("delete from hs_office_bankaccount where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_partner where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_partner_details where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_relationship where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_contact where true").executeUpdate();
|
||||
em.createNativeQuery("delete from hs_office_person where true").executeUpdate();
|
||||
}).assertSuccessful();
|
||||
@ -542,15 +546,30 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
|
||||
final var columns = new Columns(header);
|
||||
|
||||
final var mandant = HsOfficePersonEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("Hostsharing eG")
|
||||
.build();
|
||||
persons.put(1, mandant);
|
||||
|
||||
records.stream()
|
||||
.map(this::trimAll)
|
||||
.map(row -> new Record(columns, row))
|
||||
.forEach(rec -> {
|
||||
final var person = HsOfficePersonEntity.builder().build();
|
||||
|
||||
final var partnerRelationship = HsOfficeRelationshipEntity.builder()
|
||||
.relHolder(person)
|
||||
.relType(HsOfficeRelationshipType.PARTNER)
|
||||
.relAnchor(mandant)
|
||||
.contact(null) // is set during contacts import depending on assigned roles
|
||||
.build();
|
||||
relationships.put(relationshipId++, partnerRelationship);
|
||||
|
||||
final var partner = HsOfficePartnerEntity.builder()
|
||||
.partnerNumber(rec.getInteger("member_id"))
|
||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||
.partnerRole(partnerRelationship)
|
||||
.contact(null) // is set during contacts import depending on assigned roles
|
||||
.person(person)
|
||||
.build();
|
||||
@ -709,7 +728,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
final var debitor = debitors.get(rec.getInteger("bp_id"));
|
||||
|
||||
final var partnerPerson = partner.getPerson();
|
||||
if (containsRole(rec)) {
|
||||
if (containsPartnerRole(rec)) {
|
||||
initPerson(partner.getPerson(), rec);
|
||||
}
|
||||
|
||||
@ -723,9 +742,10 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
final var contact = HsOfficeContactEntity.builder().build();
|
||||
initContact(contact, rec);
|
||||
|
||||
if (containsRole(rec, "partner")) {
|
||||
if (containsPartnerRole(rec)) {
|
||||
assertThat(partner.getContact()).isNull();
|
||||
partner.setContact(contact);
|
||||
partner.getPartnerRole().setContact(contact);
|
||||
}
|
||||
if (containsRole(rec, "billing")) {
|
||||
assertThat(debitor.getBillingContact()).isNull();
|
||||
@ -763,7 +783,7 @@ public class ImportOfficeData extends ContextBasedTest {
|
||||
return ("," + roles + ",").contains("," + role + ",");
|
||||
}
|
||||
|
||||
private static boolean containsRole(final Record rec) {
|
||||
private static boolean containsPartnerRole(final Record rec) {
|
||||
return containsRole(rec, "partner");
|
||||
}
|
||||
|
||||
|
@ -78,27 +78,32 @@ class HsOfficePartnerControllerAcceptanceTest {
|
||||
[
|
||||
{
|
||||
"person": { "familyName": "Smith" },
|
||||
"partnerRole": { },
|
||||
"contact": { "label": "fifth contact" },
|
||||
"details": { "birthday": "1987-10-31" }
|
||||
},
|
||||
{
|
||||
"person": { "tradeName": "First GmbH" },
|
||||
"partnerRole": { },
|
||||
"contact": { "label": "first contact" },
|
||||
"details": { "registrationOffice": "Hamburg" }
|
||||
},
|
||||
{
|
||||
"person": { "tradeName": "Third OHG" },
|
||||
"partnerRole": { },
|
||||
"contact": { "label": "third contact" },
|
||||
"details": { "registrationOffice": "Hamburg" }
|
||||
},
|
||||
{
|
||||
"person": { "tradeName": "Second e.K." },
|
||||
"partnerRole": { },
|
||||
"contact": { "label": "second contact" },
|
||||
"details": { "registrationOffice": "Hamburg" }
|
||||
},
|
||||
{
|
||||
"person": { "personType": "INCORPORATED_FIRM" },
|
||||
"contact": { "label": "forth contact" },
|
||||
"partnerRole": { },
|
||||
"contact": { "label": "fourth contact" },
|
||||
"details": { "registrationOffice": "Hamburg" }
|
||||
}
|
||||
]
|
||||
@ -326,7 +331,7 @@ class HsOfficePartnerControllerAcceptanceTest {
|
||||
assertThat(partnerRepo.findByUuid(givenPartner.getUuid())).isPresent().get()
|
||||
.matches(person -> {
|
||||
assertThat(person.getPerson().getTradeName()).isEqualTo("Third OHG");
|
||||
assertThat(person.getContact().getLabel()).isEqualTo("forth contact");
|
||||
assertThat(person.getContact().getLabel()).isEqualTo("fourth contact");
|
||||
assertThat(person.getDetails().getRegistrationOffice()).isEqualTo("Temp Registergericht Aurich");
|
||||
assertThat(person.getDetails().getRegistrationNumber()).isEqualTo("222222");
|
||||
assertThat(person.getDetails().getBirthName()).isEqualTo("Maja Schmidt");
|
||||
@ -411,11 +416,11 @@ class HsOfficePartnerControllerAcceptanceTest {
|
||||
void contactAdminUser_canNotDeleteRelatedPartner() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = givenSomeTemporaryPartnerBessler();
|
||||
assertThat(givenPartner.getContact().getLabel()).isEqualTo("forth contact");
|
||||
assertThat(givenPartner.getContact().getLabel()).isEqualTo("fourth contact");
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
.header("current-user", "contact-admin@forthcontact.example.com")
|
||||
.header("current-user", "contact-admin@fourthcontact.example.com")
|
||||
.port(port)
|
||||
.when()
|
||||
.delete("http://localhost/api/hs/office/partners/" + givenPartner.getUuid())
|
||||
@ -431,7 +436,7 @@ class HsOfficePartnerControllerAcceptanceTest {
|
||||
void normalUser_canNotDeleteUnrelatedPartner() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = givenSomeTemporaryPartnerBessler();
|
||||
assertThat(givenPartner.getContact().getLabel()).isEqualTo("forth contact");
|
||||
assertThat(givenPartner.getContact().getLabel()).isEqualTo("fourth contact");
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
@ -451,7 +456,7 @@ class HsOfficePartnerControllerAcceptanceTest {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
|
||||
final var newPartner = HsOfficePartnerEntity.builder()
|
||||
.person(givenPerson)
|
||||
.contact(givenContact)
|
||||
|
@ -4,6 +4,9 @@ import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.context.ContextBasedTest;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relationship.HsOfficeRelationshipType;
|
||||
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
||||
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
|
||||
import net.hostsharing.test.Array;
|
||||
@ -37,6 +40,9 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
@Autowired
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationshipRepository relationshipRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
|
||||
@ -96,37 +102,68 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var initialRoleNames = roleNamesOf(rawRoleRepo.findAll());
|
||||
final var initialGrantNames = grantDisplaysOf(rawGrantRepo.findAll()).stream()
|
||||
.map(s -> s.replace("ErbenBesslerMelBessler", "EBess"))
|
||||
.map(s -> s.replace("forthcontact", "4th"))
|
||||
.map(s -> s.replace("fourthcontact", "4th"))
|
||||
.map(s -> s.replace("hs_office_", ""))
|
||||
.toList();
|
||||
|
||||
// when
|
||||
attempt(em, () -> {
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
|
||||
final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
|
||||
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||
|
||||
final var newRelationship = HsOfficeRelationshipEntity.builder()
|
||||
.relHolder(givenPartnerPerson)
|
||||
.relType(HsOfficeRelationshipType.PARTNER)
|
||||
.relAnchor(givenMandantPerson)
|
||||
.contact(givenContact)
|
||||
.build();
|
||||
relationshipRepo.save(newRelationship);
|
||||
|
||||
final var newPartner = toCleanup(HsOfficePartnerEntity.builder()
|
||||
.partnerNumber(22222)
|
||||
.person(givenPerson)
|
||||
.partnerRole(newRelationship)
|
||||
.person(givenPartnerPerson)
|
||||
.contact(givenContact)
|
||||
.details(HsOfficePartnerDetailsEntity.builder().build())
|
||||
.build());
|
||||
return partnerRepo.save(newPartner);
|
||||
});
|
||||
}).assertSuccessful();
|
||||
|
||||
// then
|
||||
assertThat(roleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
|
||||
initialRoleNames,
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-forthcontact.admin",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-forthcontact.agent",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-forthcontact.owner",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-forthcontact.tenant",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-forthcontact.guest"));
|
||||
"hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.admin",
|
||||
"hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.owner",
|
||||
"hs_office_relationship#HostsharingeG-with-PARTNER-ErbenBesslerMelBessler.tenant",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-fourthcontact.admin",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-fourthcontact.agent",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-fourthcontact.owner",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-fourthcontact.tenant",
|
||||
"hs_office_partner#22222:ErbenBesslerMelBessler-fourthcontact.guest"));
|
||||
assertThat(grantDisplaysOf(rawGrantRepo.findAll()))
|
||||
.map(s -> s.replace("ErbenBesslerMelBessler", "EBess"))
|
||||
.map(s -> s.replace("forthcontact", "4th"))
|
||||
.map(s -> s.replace("fourthcontact", "4th"))
|
||||
.map(s -> s.replace("hs_office_", ""))
|
||||
.containsExactlyInAnyOrder(Array.fromFormatted(
|
||||
initialGrantNames,
|
||||
// relationship - TODO: check and cleanup
|
||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.owner to role global#global.admin by system and assume }",
|
||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.tenant to role contact#4th.admin by system and assume }",
|
||||
"{ grant role person#HostsharingeG.tenant to role person#EBess.admin by system and assume }",
|
||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.tenant to role person#EBess.admin by system and assume }",
|
||||
"{ grant role person#EBess.tenant to role person#HostsharingeG.admin by system and assume }",
|
||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.owner to role person#HostsharingeG.admin by system and assume }",
|
||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.tenant to role person#HostsharingeG.admin by system and assume }",
|
||||
"{ grant perm edit on relationship#HostsharingeG-with-PARTNER-EBess to role relationship#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.tenant to role relationship#HostsharingeG-with-PARTNER-EBess.admin by system and assume }",
|
||||
"{ grant perm * on relationship#HostsharingeG-with-PARTNER-EBess to role relationship#HostsharingeG-with-PARTNER-EBess.owner by system and assume }",
|
||||
"{ grant role relationship#HostsharingeG-with-PARTNER-EBess.admin to role relationship#HostsharingeG-with-PARTNER-EBess.owner by system and assume }",
|
||||
"{ grant perm view on relationship#HostsharingeG-with-PARTNER-EBess to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||
"{ grant role contact#4th.tenant to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||
"{ grant role person#EBess.tenant to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||
"{ grant role person#HostsharingeG.tenant to role relationship#HostsharingeG-with-PARTNER-EBess.tenant by system and assume }",
|
||||
|
||||
// owner
|
||||
"{ grant perm * on partner#22222:EBess-4th to role partner#22222:EBess-4th.owner by system and assume }",
|
||||
"{ grant perm * on partner_details#22222:EBess-4th-details to role partner#22222:EBess-4th.owner by system and assume }",
|
||||
|
@ -88,7 +88,7 @@ class HsOfficePersonControllerAcceptanceTest {
|
||||
},
|
||||
{
|
||||
"personType": "INCORPORATED_FIRM",
|
||||
"tradeName": "Fourth e.G.",
|
||||
"tradeName": "Fourth eG",
|
||||
"givenName": null,
|
||||
"familyName": null
|
||||
},
|
||||
|
@ -167,7 +167,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
|
||||
.body("relType", is("ACCOUNTING"))
|
||||
.body("relAnchor.tradeName", is("Third OHG"))
|
||||
.body("relHolder.givenName", is("Paul"))
|
||||
.body("contact.label", is("forth contact"))
|
||||
.body("contact.label", is("fourth contact"))
|
||||
.header("Location", startsWith("http://localhost"))
|
||||
.extract().header("Location"); // @formatter:on
|
||||
|
||||
@ -390,7 +390,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
|
||||
.body("relType", is("REPRESENTATIVE"))
|
||||
.body("relAnchor.tradeName", is("Erben Bessler"))
|
||||
.body("relHolder.familyName", is("Winkler"))
|
||||
.body("contact.label", is("forth contact"));
|
||||
.body("contact.label", is("fourth contact"));
|
||||
// @formatter:on
|
||||
|
||||
// finally, the relationship is actually updated
|
||||
@ -399,7 +399,7 @@ class HsOfficeRelationshipControllerAcceptanceTest {
|
||||
.matches(rel -> {
|
||||
assertThat(rel.getRelAnchor().getTradeName()).contains("Bessler");
|
||||
assertThat(rel.getRelHolder().getFamilyName()).contains("Winkler");
|
||||
assertThat(rel.getContact().getLabel()).isEqualTo("forth contact");
|
||||
assertThat(rel.getContact().getLabel()).isEqualTo("fourth contact");
|
||||
assertThat(rel.getRelType()).isEqualTo(HsOfficeRelationshipType.REPRESENTATIVE);
|
||||
return true;
|
||||
});
|
||||
|
@ -70,7 +70,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
final var count = relationshipRepo.count();
|
||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Bessler").get(0);
|
||||
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Anita").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
@ -101,7 +101,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
attempt(em, () -> {
|
||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Bessler").get(0);
|
||||
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Anita").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("forth contact").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalLabelLike("fourth contact").get(0);
|
||||
final var newRelationship = toCleanup(HsOfficeRelationshipEntity.builder()
|
||||
.relAnchor(givenAnchorPerson)
|
||||
.relHolder(givenHolderPerson)
|
||||
@ -128,11 +128,11 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
|
||||
"{ grant role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.admin to role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.owner by system and assume }",
|
||||
|
||||
"{ grant perm view on hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita to role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.tenant by system and assume }",
|
||||
"{ grant role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.tenant to role hs_office_contact#forthcontact.admin by system and assume }",
|
||||
"{ grant role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.tenant to role hs_office_contact#fourthcontact.admin by system and assume }",
|
||||
"{ grant role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.tenant to role hs_office_person#BesslerAnita.admin by system and assume }",
|
||||
|
||||
"{ grant role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.tenant to role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.admin by system and assume }",
|
||||
"{ grant role hs_office_contact#forthcontact.tenant to role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.tenant by system and assume }",
|
||||
"{ grant role hs_office_contact#fourthcontact.tenant to role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.tenant by system and assume }",
|
||||
"{ grant role hs_office_person#BesslerAnita.tenant to role hs_office_relationship#BesslerAnita-with-REPRESENTATIVE-BesslerAnita.tenant by system and assume }",
|
||||
null)
|
||||
);
|
||||
|
@ -320,7 +320,7 @@ class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTest {
|
||||
public void globalAdmin_withoutAssumedRole_canDeleteAnySepaMandate() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net", null);
|
||||
final var givenSepaMandate = givenSomeTemporarySepaMandateBessler("Fourth e.G.");
|
||||
final var givenSepaMandate = givenSomeTemporarySepaMandateBessler("Fourth eG");
|
||||
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
|
Loading…
Reference in New Issue
Block a user