split PersonEntity/Repo into Rbac and Real Entity/Repo and use in Relation for faster lazy loading (#130)
Co-authored-by: Timotheus Pokorra <timotheus.pokorra@hostsharing.net> Co-authored-by: Michael Hoennig <michael@hoennig.de> Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/130 Reviewed-by: Timotheus Pokorra <timotheus.pokorra@hostsharing.net>
This commit is contained in:
@@ -11,7 +11,7 @@ import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipStatus;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerDetailsEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
@@ -81,7 +81,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
);
|
||||
|
||||
static Map<Integer, HsOfficeContactRealEntity> contacts = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePersonEntity> persons = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePersonRealEntity> persons = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePartnerEntity> partners = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeDebitorEntity> debitors = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeMembershipEntity> memberships = new WriteOnceMap<>();
|
||||
@@ -731,7 +731,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
return;
|
||||
}
|
||||
|
||||
final var person = HsOfficePersonEntity.builder().build();
|
||||
final var person = HsOfficePersonRealEntity.builder().build();
|
||||
|
||||
final var partnerRel = addRelation(
|
||||
HsOfficeRelationType.PARTNER,
|
||||
@@ -880,6 +880,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
coopAssets.put(rec.getInteger("member_asset_id"), assetTransaction);
|
||||
});
|
||||
|
||||
|
||||
coopAssets.entrySet().forEach(entry -> {
|
||||
final var legacyId = entry.getKey();
|
||||
final var assetTransaction = entry.getValue();
|
||||
@@ -995,14 +996,14 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
addPerson(partnerPerson, rec);
|
||||
}
|
||||
|
||||
HsOfficePersonEntity contactPerson = partnerPerson;
|
||||
HsOfficePersonRealEntity contactPerson = partnerPerson;
|
||||
if (!StringUtils.equals(rec.getString("firma"), partnerPerson.getTradeName()) ||
|
||||
partnerPerson.getPersonType() != determinePersonType(rec) ||
|
||||
!StringUtils.equals(rec.getString("title"), partnerPerson.getTitle()) ||
|
||||
!StringUtils.equals(rec.getString("salut"), partnerPerson.getSalutation()) ||
|
||||
!StringUtils.equals(rec.getString("first_name"), partnerPerson.getGivenName()) ||
|
||||
!StringUtils.equals(rec.getString("last_name"), partnerPerson.getFamilyName())) {
|
||||
contactPerson = addPerson(HsOfficePersonEntity.builder().build(), rec);
|
||||
contactPerson = addPerson(HsOfficePersonRealEntity.builder().build(), rec);
|
||||
}
|
||||
|
||||
final var contact = HsOfficeContactRealEntity.builder().build();
|
||||
@@ -1085,8 +1086,8 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
|
||||
private static HsOfficeRelationRealEntity addRelation(
|
||||
final HsOfficeRelationType type,
|
||||
final HsOfficePersonEntity anchor,
|
||||
final HsOfficePersonEntity holder,
|
||||
final HsOfficePersonRealEntity anchor,
|
||||
final HsOfficePersonRealEntity holder,
|
||||
final HsOfficeContactRealEntity contact) {
|
||||
final var rel = HsOfficeRelationRealEntity.builder()
|
||||
.anchor(anchor)
|
||||
@@ -1098,7 +1099,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
return rel;
|
||||
}
|
||||
|
||||
private HsOfficePersonEntity addPerson(final HsOfficePersonEntity person, final Record contactRecord) {
|
||||
private HsOfficePersonRealEntity addPerson(final HsOfficePersonRealEntity person, final Record contactRecord) {
|
||||
person.setSalutation(contactRecord.getString("salut"));
|
||||
person.setTitle(contactRecord.getString("title"));
|
||||
person.setGivenName(contactRecord.getString("first_name"));
|
||||
|
||||
+10
-10
@@ -7,7 +7,7 @@ import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
@@ -57,16 +57,16 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeContactRealRepository contactrealRepo;
|
||||
HsOfficeContactRealRepository contactRealRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeBankAccountRepository bankAccountRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRealRepository personRealRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationRealRepository relrealRepo;
|
||||
HsOfficeRelationRealRepository relationRealRepo;
|
||||
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
@@ -270,13 +270,13 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0);
|
||||
final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").get(0);
|
||||
final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").get(0);
|
||||
final var givenBankAccount = bankAccountRepo.findByOptionalHolderLike("Fourth").get(0);
|
||||
final var givenBillingPerson = personRepo.findPersonByOptionalNameLike("Fourth").get(0);
|
||||
final var givenBillingPerson = personRealRepo.findPersonByOptionalNameLike("Fourth").get(0);
|
||||
|
||||
final var givenDebitorRelUUid = jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
return relrealRepo.save(HsOfficeRelationRealEntity.builder()
|
||||
return relationRealRepo.save(HsOfficeRelationRealEntity.builder()
|
||||
.type(DEBITOR)
|
||||
.anchor(givenPartner.getPartnerRel().getHolder())
|
||||
.holder(givenBillingPerson)
|
||||
@@ -327,7 +327,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0);
|
||||
final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").get(0);
|
||||
final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given()
|
||||
@@ -554,7 +554,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = givenSomeTemporaryDebitor();
|
||||
final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").get(0);
|
||||
final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given()
|
||||
@@ -724,7 +724,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0).load();
|
||||
final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
|
||||
final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix(nextDebitorSuffix())
|
||||
.billable(true)
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.debitor;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
|
||||
@@ -13,11 +13,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class HsOfficeDebitorEntityUnitTest {
|
||||
|
||||
private final HsOfficeRelationRealEntity givenDebitorRel = HsOfficeRelationRealEntity.builder()
|
||||
.anchor(HsOfficePersonEntity.builder()
|
||||
.anchor(HsOfficePersonRealEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("some partner trade name")
|
||||
.build())
|
||||
.holder(HsOfficePersonEntity.builder()
|
||||
.holder(HsOfficePersonRealEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("some billing trade name")
|
||||
.build())
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
@@ -53,7 +53,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
HsOfficeContactRealRepository contactrealRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRealRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeBankAccountRepository bankAccountRepo;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.hostsharing.hsadminng.hs.office.debitor;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealTestEntity.TEST_REAL_CONTACT;
|
||||
@@ -15,8 +15,8 @@ public class TestHsOfficeDebitor {
|
||||
public static final HsOfficeDebitorEntity TEST_DEBITOR = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix(DEFAULT_DEBITOR_SUFFIX)
|
||||
.debitorRel(HsOfficeRelationRealEntity.builder()
|
||||
.holder(HsOfficePersonEntity.builder().build())
|
||||
.anchor(HsOfficePersonEntity.builder().build())
|
||||
.holder(HsOfficePersonRealEntity.builder().build())
|
||||
.anchor(HsOfficePersonRealEntity.builder().build())
|
||||
.contact(TEST_REAL_CONTACT)
|
||||
.build())
|
||||
.partner(TEST_PARTNER)
|
||||
|
||||
+15
-15
@@ -5,8 +5,8 @@ import io.restassured.http.ContentType;
|
||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
|
||||
@@ -48,10 +48,10 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
HsOfficeRelationRealRepository relationRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRealRepository personRealRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeContactRealRepository contactrealRepo;
|
||||
HsOfficeContactRealRepository contactRealRepo;
|
||||
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
@@ -93,9 +93,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
void globalAdmin_withoutAssumedRole_canPostNewPartner() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow();
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike("Third").stream().findFirst().orElseThrow();
|
||||
final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").stream().findFirst().orElseThrow();
|
||||
final var givenMandantPerson = personRealRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow();
|
||||
final var givenPerson = personRealRepo.findPersonByOptionalNameLike("Third").stream().findFirst().orElseThrow();
|
||||
final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").stream().findFirst().orElseThrow();
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given()
|
||||
@@ -153,8 +153,8 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
void globalAdmin_canNotPostNewPartner_ifContactDoesNotExist() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike("Third").get(0);
|
||||
final var givenMandantPerson = personRealRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||
final var givenPerson = personRealRepo.findPersonByOptionalNameLike("Third").get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given()
|
||||
@@ -191,8 +191,8 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
void globalAdmin_canNotPostNewPartner_ifPersonDoesNotExist() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var mandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||
final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").get(0);
|
||||
final var mandantPerson = personRealRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||
final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").get(0);
|
||||
|
||||
final var location = RestAssured // @formatter:off
|
||||
.given()
|
||||
@@ -224,7 +224,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
// TODO.impl: we want this error message:
|
||||
// .body("message", is("ERROR: [400] Unable to find Person by uuid: " + GIVEN_NON_EXISTING_UUID));
|
||||
// but ModelMapper creates this error message:
|
||||
.body("message", is("ERROR: [400] Unable to find " + HsOfficePersonEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID));
|
||||
.body("message", is("ERROR: [400] Unable to find " + HsOfficePersonRealEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID));
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
@@ -528,9 +528,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
final String contactName) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow();
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow();
|
||||
final var givenContact = contactrealRepo.findContactByOptionalCaptionLike(contactName).stream().findFirst().orElseThrow();
|
||||
final var givenMandantPerson = personRealRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow();
|
||||
final var givenPerson = personRealRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow();
|
||||
final var givenContact = contactRealRepo.findContactByOptionalCaptionLike(contactName).stream().findFirst().orElseThrow();
|
||||
|
||||
final var partnerRel = new HsOfficeRelationRealEntity();
|
||||
partnerRel.setType(HsOfficeRelationType.PARTNER);
|
||||
|
||||
+6
-6
@@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
@@ -66,10 +66,10 @@ class HsOfficePartnerControllerRestTest {
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@Mock
|
||||
HsOfficePersonEntity mandateMock;
|
||||
HsOfficePersonRealEntity mandateMock;
|
||||
|
||||
@Mock
|
||||
HsOfficePersonEntity personMock;
|
||||
HsOfficePersonRealEntity personMock;
|
||||
|
||||
@Mock
|
||||
HsOfficeContactRbacEntity contactMock;
|
||||
@@ -84,8 +84,8 @@ class HsOfficePartnerControllerRestTest {
|
||||
when(emf.createEntityManager(any(SynchronizationType.class))).thenReturn(em);
|
||||
when(emf.createEntityManager(any(SynchronizationType.class), any(Map.class))).thenReturn(em);
|
||||
|
||||
lenient().when(em.getReference(HsOfficePersonEntity.class, GIVEN_MANDANTE_UUID)).thenReturn(mandateMock);
|
||||
lenient().when(em.getReference(HsOfficePersonEntity.class, GIVEN_PERSON_UUID)).thenReturn(personMock);
|
||||
lenient().when(em.getReference(HsOfficePersonRealEntity.class, GIVEN_MANDANTE_UUID)).thenReturn(mandateMock);
|
||||
lenient().when(em.getReference(HsOfficePersonRealEntity.class, GIVEN_PERSON_UUID)).thenReturn(personMock);
|
||||
lenient().when(em.getReference(HsOfficeContactRbacEntity.class, GIVEN_CONTACT_UUID)).thenReturn(contactMock);
|
||||
lenient().when(em.getReference(any(), eq(GIVEN_INVALID_UUID))).thenThrow(EntityNotFoundException.class);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ class HsOfficePartnerControllerRestTest {
|
||||
.andExpect(status().is4xxClientError())
|
||||
.andExpect(jsonPath("statusCode", is(400)))
|
||||
.andExpect(jsonPath("statusPhrase", is("Bad Request")))
|
||||
.andExpect(jsonPath("message", startsWith("ERROR: [400] Cannot resolve HsOfficePersonEntity with uuid ")));
|
||||
.andExpect(jsonPath("message", startsWith("ERROR: [400] Cannot resolve HsOfficePersonRealEntity with uuid ")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity;
|
||||
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
@@ -45,8 +45,8 @@ class HsOfficePartnerDetailsEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
void initMocks() {
|
||||
lenient().when(em.getReference(eq(HsOfficeContactRbacEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeContactRbacEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficePersonEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficePersonEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficePersonRbacEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficePersonRbacEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -33,7 +33,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
private static final UUID INITIAL_DETAILS_UUID = UUID.randomUUID();
|
||||
private static final UUID PATCHED_PARTNER_ROLE_UUID = UUID.randomUUID();
|
||||
|
||||
private final HsOfficePersonEntity givenInitialPerson = HsOfficePersonEntity.builder()
|
||||
private final HsOfficePersonRealEntity givenInitialPerson = HsOfficePersonRealEntity.builder()
|
||||
.uuid(INITIAL_PERSON_UUID)
|
||||
.build();
|
||||
private final HsOfficeContactRealEntity givenInitialContact = HsOfficeContactRealEntity.builder()
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
@@ -15,12 +15,12 @@ class HsOfficePartnerEntityUnitTest {
|
||||
private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.partnerRel(HsOfficeRelationRealEntity.builder()
|
||||
.anchor(HsOfficePersonEntity.builder()
|
||||
.anchor(HsOfficePersonRealEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("Hostsharing eG")
|
||||
.build())
|
||||
.type(HsOfficeRelationType.PARTNER)
|
||||
.holder(HsOfficePersonEntity.builder()
|
||||
.holder(HsOfficePersonRealEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("some trade name")
|
||||
.build())
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
@@ -45,7 +45,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
HsOfficeRelationRealRepository relationRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRealRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeContactRealRepository contactrealRepo;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
|
||||
@@ -16,12 +16,12 @@ public class TestHsOfficePartner {
|
||||
.partnerNumber(10001)
|
||||
.partnerRel(
|
||||
HsOfficeRelationRealEntity.builder()
|
||||
.holder(HsOfficePersonEntity.builder()
|
||||
.holder(HsOfficePersonRealEntity.builder()
|
||||
.personType(LEGAL_PERSON)
|
||||
.tradeName("Hostsharing eG")
|
||||
.build())
|
||||
.type(HsOfficeRelationType.PARTNER)
|
||||
.holder(HsOfficePersonEntity.builder()
|
||||
.holder(HsOfficePersonRealEntity.builder()
|
||||
.personType(LEGAL_PERSON)
|
||||
.tradeName(tradeName)
|
||||
.build())
|
||||
|
||||
+4
-4
@@ -43,7 +43,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
Context contextMock;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRealRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
@@ -327,10 +327,10 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
}
|
||||
}
|
||||
|
||||
private HsOfficePersonEntity givenSomeTemporaryPersonCreatedBy(final String creatingUser) {
|
||||
private HsOfficePersonRealEntity givenSomeTemporaryPersonCreatedBy(final String creatingUser) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define(creatingUser);
|
||||
final var newPerson = HsOfficePersonEntity.builder()
|
||||
final var newPerson = HsOfficePersonRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("Temp " + Context.getCallerMethodNameFromStackFrame(2))
|
||||
@@ -347,7 +347,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net", null);
|
||||
em.createQuery("""
|
||||
DELETE FROM HsOfficePersonEntity p
|
||||
DELETE FROM HsOfficePersonRealEntity p
|
||||
WHERE p.tradeName LIKE 'Temp %' OR p.givenName LIKE 'Temp %'
|
||||
""").executeUpdate();
|
||||
}).assertSuccessful();
|
||||
|
||||
+10
-10
@@ -13,14 +13,14 @@ import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
|
||||
@TestInstance(PER_CLASS)
|
||||
class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
HsOfficePersonPatchResource,
|
||||
HsOfficePersonEntity
|
||||
HsOfficePersonRbacEntity
|
||||
> {
|
||||
|
||||
private static final UUID INITIAL_PERSON_UUID = UUID.randomUUID();
|
||||
|
||||
@Override
|
||||
protected HsOfficePersonEntity newInitialEntity() {
|
||||
final var entity = new HsOfficePersonEntity();
|
||||
protected HsOfficePersonRbacEntity newInitialEntity() {
|
||||
final var entity = new HsOfficePersonRbacEntity();
|
||||
entity.setUuid(INITIAL_PERSON_UUID);
|
||||
entity.setPersonType(HsOfficePersonType.LEGAL_PERSON);
|
||||
entity.setTradeName("initial trade name");
|
||||
@@ -37,7 +37,7 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HsOfficePersonEntityPatcher createPatcher(final HsOfficePersonEntity entity) {
|
||||
protected HsOfficePersonEntityPatcher createPatcher(final HsOfficePersonRbacEntity entity) {
|
||||
return new HsOfficePersonEntityPatcher(entity);
|
||||
}
|
||||
|
||||
@@ -48,34 +48,34 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
"personType",
|
||||
HsOfficePersonPatchResource::setPersonType,
|
||||
HsOfficePersonTypeResource.INCORPORATED_FIRM,
|
||||
HsOfficePersonEntity::setPersonType,
|
||||
HsOfficePersonRbacEntity::setPersonType,
|
||||
HsOfficePersonType.INCORPORATED_FIRM)
|
||||
.notNullable(),
|
||||
new JsonNullableProperty<>(
|
||||
"tradeName",
|
||||
HsOfficePersonPatchResource::setTradeName,
|
||||
"patched trade name",
|
||||
HsOfficePersonEntity::setTradeName),
|
||||
HsOfficePersonRbacEntity::setTradeName),
|
||||
new JsonNullableProperty<>(
|
||||
"title",
|
||||
HsOfficePersonPatchResource::setTitle,
|
||||
"Dr. Patch.",
|
||||
HsOfficePersonEntity::setTitle),
|
||||
HsOfficePersonRbacEntity::setTitle),
|
||||
new JsonNullableProperty<>(
|
||||
"salutation",
|
||||
HsOfficePersonPatchResource::setSalutation,
|
||||
"Hallo Ini",
|
||||
HsOfficePersonEntity::setSalutation),
|
||||
HsOfficePersonRbacEntity::setSalutation),
|
||||
new JsonNullableProperty<>(
|
||||
"familyName",
|
||||
HsOfficePersonPatchResource::setFamilyName,
|
||||
"patched family name",
|
||||
HsOfficePersonEntity::setFamilyName),
|
||||
HsOfficePersonRbacEntity::setFamilyName),
|
||||
new JsonNullableProperty<>(
|
||||
"patched given name",
|
||||
HsOfficePersonPatchResource::setGivenName,
|
||||
"patched given name",
|
||||
HsOfficePersonEntity::setGivenName)
|
||||
HsOfficePersonRbacEntity::setGivenName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -11,7 +11,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void getDisplayReturnsTradeNameIfAvailable() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("some trade name")
|
||||
.build();
|
||||
@@ -23,7 +23,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void getDisplayReturnsFamilyAndGivenNameIfNoTradeNameAvailable() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.familyName("some family name")
|
||||
.givenName("some given name")
|
||||
@@ -36,7 +36,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toShortStringWithTradeNameReturnsTradeName() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("some trade name")
|
||||
.familyName("some family name")
|
||||
@@ -50,7 +50,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toShortStringWithoutTradeNameReturnsFamilyAndGivenName() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.familyName("some family name")
|
||||
.givenName("some given name")
|
||||
@@ -63,7 +63,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toShortStringWithSalutationAndTitleReturnsSalutationAndTitle() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.salutation("Frau")
|
||||
.title("Dr.")
|
||||
@@ -78,7 +78,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toShortStringWithSalutationAndWithoutTitleReturnsSalutation() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.salutation("Frau")
|
||||
.familyName("some family name")
|
||||
@@ -92,7 +92,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toShortStringWithoutSalutationAndWithTitleReturnsTitle() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.title("Dr. Dr.")
|
||||
.familyName("some family name")
|
||||
@@ -106,7 +106,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toStringWithAllFieldsReturnsAllButUuid() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.tradeName("some trade name")
|
||||
@@ -122,7 +122,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toStringSkipsNullFields() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.familyName("some family name")
|
||||
.givenName("some given name")
|
||||
.build();
|
||||
@@ -133,7 +133,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
}
|
||||
@Test
|
||||
void toStringWithSalutationAndTitleRetursSalutationAndTitle() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.salutation("Herr")
|
||||
.title("Prof. Dr.")
|
||||
.familyName("some family name")
|
||||
@@ -146,7 +146,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
}
|
||||
@Test
|
||||
void toStringWithSalutationAndWithoutTitleSkipsTitle() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.salutation("Herr")
|
||||
.familyName("some family name")
|
||||
.givenName("some given name")
|
||||
@@ -159,7 +159,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toStringWithoutSalutationAndWithTitleSkipsSalutation() {
|
||||
final var givenPersonEntity = HsOfficePersonEntity.builder()
|
||||
final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
|
||||
.title("some title")
|
||||
.familyName("some family name")
|
||||
.givenName("some given name")
|
||||
@@ -172,7 +172,7 @@ class HsOfficePersonEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void definesRbac() {
|
||||
final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePersonEntity.rbac()).toString();
|
||||
final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePersonRbacEntity.rbac()).toString();
|
||||
assertThat(rbacFlowchart).isEqualTo("""
|
||||
%%{init:{'flowchart':{'htmlLabels':false}}}%%
|
||||
flowchart TB
|
||||
|
||||
+34
-34
@@ -21,7 +21,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.person.TestHsOfficePerson.hsOfficePerson;
|
||||
import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacTestEntity.hsOfficePersonRbacEntity;
|
||||
import static net.hostsharing.hsadminng.rbac.grant.RawRbacGrantEntity.distinctGrantDisplaysOf;
|
||||
import static net.hostsharing.hsadminng.rbac.role.RawRbacRoleEntity.distinctRoleNamesOf;
|
||||
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
|
||||
@@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DataJpaTest
|
||||
@Import( { Context.class, JpaAttempt.class })
|
||||
class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
||||
class HsOfficePersonRbacRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRbacRepository personRbacRepo;
|
||||
|
||||
@Autowired
|
||||
RawRbacRoleRepository rawRoleRepo;
|
||||
@@ -56,34 +56,34 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
public void globalAdmin_withoutAssumedRole_canCreateNewPerson() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var count = personRepo.count();
|
||||
final var count = personRbacRepo.count();
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> toCleanup(personRepo.save(
|
||||
hsOfficePerson("a new person"))));
|
||||
final var result = attempt(em, () -> toCleanup(personRbacRepo.save(
|
||||
hsOfficePersonRbacEntity("a new person"))));
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRbacEntity::getUuid).isNotNull();
|
||||
assertThatPersonIsPersisted(result.returnedValue());
|
||||
assertThat(personRepo.count()).isEqualTo(count + 1);
|
||||
assertThat(personRbacRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void arbitraryUser_canCreateNewPerson() {
|
||||
// given
|
||||
context("selfregistered-user-drew@hostsharing.org");
|
||||
final var count = personRepo.count();
|
||||
final var count = personRbacRepo.count();
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> toCleanup(personRepo.save(
|
||||
hsOfficePerson("another new person"))));
|
||||
final var result = attempt(em, () -> toCleanup(personRbacRepo.save(
|
||||
hsOfficePersonRbacEntity("another new person"))));
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRbacEntity::getUuid).isNotNull();
|
||||
assertThatPersonIsPersisted(result.returnedValue());
|
||||
assertThat(personRepo.count()).isEqualTo(count + 1);
|
||||
assertThat(personRbacRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,7 +95,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
|
||||
// when
|
||||
attempt(em, () -> toCleanup(
|
||||
personRepo.save(hsOfficePerson("another new person"))
|
||||
personRbacRepo.save(hsOfficePersonRbacEntity("another new person"))
|
||||
)).assumeSuccessful();
|
||||
|
||||
// then
|
||||
@@ -122,8 +122,8 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
));
|
||||
}
|
||||
|
||||
private void assertThatPersonIsPersisted(final HsOfficePersonEntity saved) {
|
||||
final var found = personRepo.findByUuid(saved.getUuid());
|
||||
private void assertThatPersonIsPersisted(final HsOfficePersonRbacEntity saved) {
|
||||
final var found = personRbacRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
context("superuser-alex@hostsharing.net");
|
||||
|
||||
// when
|
||||
final var result = personRepo.findPersonByOptionalNameLike(null);
|
||||
final var result = personRbacRepo.findPersonByOptionalNameLike(null);
|
||||
|
||||
// then
|
||||
allThesePersonsAreReturned(
|
||||
@@ -155,7 +155,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
|
||||
// when:
|
||||
context("pac-admin-zzz00@zzz.example.com");
|
||||
final var result = personRepo.findPersonByOptionalNameLike(null);
|
||||
final var result = personRbacRepo.findPersonByOptionalNameLike(null);
|
||||
|
||||
// then:
|
||||
exactlyThesePersonsAreReturned(result, givenPerson.getTradeName());
|
||||
@@ -171,7 +171,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
context("superuser-alex@hostsharing.net", null);
|
||||
|
||||
// when
|
||||
final var result = personRepo.findPersonByOptionalNameLike("Second");
|
||||
final var result = personRbacRepo.findPersonByOptionalNameLike("Second");
|
||||
|
||||
// then
|
||||
exactlyThesePersonsAreReturned(result, "Second e.K.");
|
||||
@@ -184,7 +184,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
|
||||
// when:
|
||||
context("selfregistered-user-drew@hostsharing.org");
|
||||
final var result = personRepo.findPersonByOptionalNameLike(givenPerson.getTradeName());
|
||||
final var result = personRbacRepo.findPersonByOptionalNameLike(givenPerson.getTradeName());
|
||||
|
||||
// then:
|
||||
exactlyThesePersonsAreReturned(result, givenPerson.getTradeName());
|
||||
@@ -202,14 +202,14 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", null);
|
||||
personRepo.deleteByUuid(givenPerson.getUuid());
|
||||
personRbacRepo.deleteByUuid(givenPerson.getUuid());
|
||||
});
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", null);
|
||||
return personRepo.findPersonByOptionalNameLike(givenPerson.getTradeName());
|
||||
return personRbacRepo.findPersonByOptionalNameLike(givenPerson.getTradeName());
|
||||
}).assertSuccessful().returnedValue()).hasSize(0);
|
||||
}
|
||||
|
||||
@@ -221,14 +221,14 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("selfregistered-user-drew@hostsharing.org", null);
|
||||
personRepo.deleteByUuid(givenPerson.getUuid());
|
||||
personRbacRepo.deleteByUuid(givenPerson.getUuid());
|
||||
});
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", null);
|
||||
return personRepo.findPersonByOptionalNameLike(givenPerson.getTradeName());
|
||||
return personRbacRepo.findPersonByOptionalNameLike(givenPerson.getTradeName());
|
||||
}).assertSuccessful().returnedValue()).hasSize(0);
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("selfregistered-user-drew@hostsharing.org", null);
|
||||
return personRepo.deleteByUuid(givenPerson.getUuid());
|
||||
return personRbacRepo.deleteByUuid(givenPerson.getUuid());
|
||||
});
|
||||
|
||||
// then
|
||||
@@ -276,29 +276,29 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
|
||||
"[creating person test-data, hs_office.person, INSERT, Third OHG, null]");
|
||||
}
|
||||
|
||||
private HsOfficePersonEntity givenSomeTemporaryPerson(
|
||||
private HsOfficePersonRbacEntity givenSomeTemporaryPerson(
|
||||
final String createdByUser,
|
||||
Supplier<HsOfficePersonEntity> entitySupplier) {
|
||||
Supplier<HsOfficePersonRbacEntity> entitySupplier) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context(createdByUser);
|
||||
return toCleanup(personRepo.save(entitySupplier.get()));
|
||||
return toCleanup(personRbacRepo.save(entitySupplier.get()));
|
||||
}).assumeSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
private HsOfficePersonEntity givenSomeTemporaryPerson(final String createdByUser) {
|
||||
private HsOfficePersonRbacEntity givenSomeTemporaryPerson(final String createdByUser) {
|
||||
return givenSomeTemporaryPerson(createdByUser, () ->
|
||||
hsOfficePerson("some temporary person #" + RandomStringUtils.random(12)));
|
||||
hsOfficePersonRbacEntity("some temporary person #" + RandomStringUtils.random(12)));
|
||||
}
|
||||
|
||||
void exactlyThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personCaptions) {
|
||||
void exactlyThesePersonsAreReturned(final List<HsOfficePersonRbacEntity> actualResult, final String... personCaptions) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsOfficePersonEntity::getTradeName)
|
||||
.extracting(HsOfficePersonRbacEntity::getTradeName)
|
||||
.containsExactlyInAnyOrder(personCaptions);
|
||||
}
|
||||
|
||||
void allThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personCaptions) {
|
||||
void allThesePersonsAreReturned(final List<HsOfficePersonRbacEntity> actualResult, final String... personCaptions) {
|
||||
assertThat(actualResult)
|
||||
.extracting(hsOfficePersonEntity -> hsOfficePersonEntity.toShortString())
|
||||
.extracting(HsOfficePerson::toShortString)
|
||||
.contains(personCaptions);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package net.hostsharing.hsadminng.hs.office.person;
|
||||
|
||||
|
||||
public class HsOfficePersonRbacTestEntity {
|
||||
|
||||
public static final HsOfficePersonRbacEntity somePerson = hsOfficePersonRbacEntity("some person");
|
||||
|
||||
public static HsOfficePersonRbacEntity hsOfficePersonRbacEntity(final String tradeName) {
|
||||
return HsOfficePersonRbacEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.tradeName(tradeName)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
package net.hostsharing.hsadminng.hs.office.person;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.Array;
|
||||
import net.hostsharing.hsadminng.rbac.grant.RawRbacGrantRepository;
|
||||
import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealTestEntity.hsOfficePersonRealEntity;
|
||||
import static net.hostsharing.hsadminng.rbac.grant.RawRbacGrantEntity.distinctGrantDisplaysOf;
|
||||
import static net.hostsharing.hsadminng.rbac.role.RawRbacRoleEntity.distinctRoleNamesOf;
|
||||
import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@DataJpaTest
|
||||
@Import( { Context.class, JpaAttempt.class })
|
||||
class HsOfficePersonRealRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRealRepository personRealRepo;
|
||||
|
||||
@Autowired
|
||||
RawRbacRoleRepository rawRoleRepo;
|
||||
|
||||
@Autowired
|
||||
RawRbacGrantRepository rawGrantRepo;
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
|
||||
@MockBean
|
||||
HttpServletRequest request;
|
||||
@Autowired
|
||||
private HsOfficePersonRealRepository hsOfficePersonRealRepository;
|
||||
|
||||
@Nested
|
||||
class CreatePerson {
|
||||
|
||||
@Test
|
||||
public void arbitraryUser_canCreateNewPerson() {
|
||||
// given
|
||||
context("selfregistered-user-drew@hostsharing.org");
|
||||
final var count = personRealRepo.count();
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> toCleanup(personRealRepo.save(
|
||||
hsOfficePersonRealEntity("another new person"))));
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRealEntity::getUuid).isNotNull();
|
||||
assertThatPersonIsPersisted(result.returnedValue());
|
||||
assertThat(personRealRepo.count()).isEqualTo(count + 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsAndGrantsRoles() {
|
||||
// given
|
||||
context("selfregistered-user-drew@hostsharing.org");
|
||||
final var initialRoleNames = distinctRoleNamesOf(rawRoleRepo.findAll());
|
||||
final var initialGrantNames = distinctGrantDisplaysOf(rawGrantRepo.findAll());
|
||||
|
||||
// when
|
||||
attempt(em, () -> toCleanup(
|
||||
personRealRepo.save(hsOfficePersonRealEntity("another new person"))
|
||||
)).assumeSuccessful();
|
||||
|
||||
// then
|
||||
assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(
|
||||
Array.from(
|
||||
initialRoleNames,
|
||||
"hs_office.person#anothernewperson:OWNER",
|
||||
"hs_office.person#anothernewperson:ADMIN",
|
||||
"hs_office.person#anothernewperson:REFERRER"
|
||||
));
|
||||
assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(
|
||||
Array.fromFormatted(
|
||||
initialGrantNames,
|
||||
"{ grant perm:hs_office.person#anothernewperson:INSERT>hs_office.relation to role:hs_office.person#anothernewperson:ADMIN by system and assume }",
|
||||
|
||||
"{ grant role:hs_office.person#anothernewperson:OWNER to user:selfregistered-user-drew@hostsharing.org by hs_office.person#anothernewperson:OWNER and assume }",
|
||||
"{ grant role:hs_office.person#anothernewperson:OWNER to role:rbac.global#global:ADMIN by system and assume }",
|
||||
"{ grant perm:hs_office.person#anothernewperson:UPDATE to role:hs_office.person#anothernewperson:ADMIN by system and assume }",
|
||||
"{ grant perm:hs_office.person#anothernewperson:DELETE to role:hs_office.person#anothernewperson:OWNER by system and assume }",
|
||||
"{ grant role:hs_office.person#anothernewperson:ADMIN to role:hs_office.person#anothernewperson:OWNER by system and assume }",
|
||||
|
||||
"{ grant perm:hs_office.person#anothernewperson:SELECT to role:hs_office.person#anothernewperson:REFERRER by system and assume }",
|
||||
"{ grant role:hs_office.person#anothernewperson:REFERRER to role:hs_office.person#anothernewperson:ADMIN by system and assume }"
|
||||
));
|
||||
}
|
||||
|
||||
private void assertThatPersonIsPersisted(final HsOfficePersonRealEntity saved) {
|
||||
final var found = personRealRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class FindAllPersons {
|
||||
|
||||
@Test
|
||||
public void arbitraryUser_canViewAllPersons() {
|
||||
// given
|
||||
context("selfregistered-user-drew@hostsharing.org");
|
||||
|
||||
// when
|
||||
final var result = personRealRepo.findPersonByOptionalNameLike(null);
|
||||
|
||||
// then
|
||||
allThesePersonsAreReturned(
|
||||
result,
|
||||
"NP Smith, Peter",
|
||||
"LP Second e.K.",
|
||||
"IF Third OHG",
|
||||
"UF Erben Bessler");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class FindByCaptionLike {
|
||||
|
||||
@Test
|
||||
public void arbitraryUser_canViewAllPersons() {
|
||||
// given
|
||||
context("selfregistered-user-drew@hostsharing.org");
|
||||
|
||||
// when
|
||||
final var result = personRealRepo.findPersonByOptionalNameLike("Second");
|
||||
|
||||
// then
|
||||
exactlyThesePersonsAreReturned(result, "Second e.K.");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void auditJournalLogIsAvailable() {
|
||||
// given
|
||||
final var query = em.createNativeQuery("""
|
||||
select currentTask, targetTable, targetOp, targetdelta->>'tradename', targetdelta->>'lastname'
|
||||
from base.tx_journal_v
|
||||
where targettable = 'hs_office.person';
|
||||
""");
|
||||
|
||||
// when
|
||||
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
|
||||
|
||||
// then
|
||||
assertThat(customerLogEntries).map(Arrays::toString).contains(
|
||||
"[creating person test-data, hs_office.person, INSERT, Hostsharing eG, null]",
|
||||
"[creating person test-data, hs_office.person, INSERT, First GmbH, null]",
|
||||
"[creating person test-data, hs_office.person, INSERT, Second e.K., null]",
|
||||
"[creating person test-data, hs_office.person, INSERT, Third OHG, null]");
|
||||
}
|
||||
|
||||
void exactlyThesePersonsAreReturned(final List<HsOfficePersonRealEntity> actualResult, final String... personCaptions) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsOfficePersonRealEntity::getTradeName)
|
||||
.containsExactlyInAnyOrder(personCaptions);
|
||||
}
|
||||
|
||||
void allThesePersonsAreReturned(final List<HsOfficePersonRealEntity> actualResult, final String... personCaptions) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsOfficePerson::toShortString)
|
||||
.contains(personCaptions);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package net.hostsharing.hsadminng.hs.office.person;
|
||||
|
||||
|
||||
public class HsOfficePersonRealTestEntity {
|
||||
|
||||
public static final HsOfficePersonRealEntity somePerson = hsOfficePersonRealEntity("some person");
|
||||
|
||||
public static HsOfficePersonRealEntity hsOfficePersonRealEntity(final String tradeName) {
|
||||
return HsOfficePersonRealEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.tradeName(tradeName)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package net.hostsharing.hsadminng.hs.office.person;
|
||||
|
||||
|
||||
public class TestHsOfficePerson {
|
||||
|
||||
public static final HsOfficePersonEntity somePerson = hsOfficePerson("some person");
|
||||
|
||||
static public HsOfficePersonEntity hsOfficePerson(final String tradeName) {
|
||||
return HsOfficePersonEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.tradeName(tradeName)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
@@ -30,7 +30,7 @@ class HsOfficeRealRelationRepositoryIntegrationTest extends ContextBasedTestWith
|
||||
HsOfficeRelationRealRepository relationRealRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRbacRepository personRepo;
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
+2
-2
@@ -3,11 +3,11 @@ package net.hostsharing.hsadminng.hs.office.relation;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationTypeResource;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
import net.hostsharing.hsadminng.test.DisableSecurityConfig;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
@@ -45,7 +45,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
HsOfficeRelationRealRepository relationrealRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRealRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeContactRealRepository contactrealRepo;
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
@@ -38,10 +38,10 @@ class HsOfficeRelationPatcherUnitTest extends PatchUnitTestBase<
|
||||
HsOfficeContactRealEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
}
|
||||
|
||||
final HsOfficePersonEntity givenInitialAnchorPerson = HsOfficePersonEntity.builder()
|
||||
final HsOfficePersonRealEntity givenInitialAnchorPerson = HsOfficePersonRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.build();
|
||||
final HsOfficePersonEntity givenInitialHolderPerson = HsOfficePersonEntity.builder()
|
||||
final HsOfficePersonRealEntity givenInitialHolderPerson = HsOfficePersonRealEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.build();
|
||||
final HsOfficeContactRealEntity givenInitialContact = HsOfficeContactRealEntity.builder()
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.grant.RawRbacGrantRepository;
|
||||
import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository;
|
||||
@@ -37,7 +37,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
HsOfficeRelationRbacRepository relationRbacRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRealRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeContactRealRepository contactrealRepo;
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -9,11 +9,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class HsOfficeRelationUnitTest {
|
||||
|
||||
private HsOfficePersonEntity anchor = HsOfficePersonEntity.builder()
|
||||
private HsOfficePersonRealEntity anchor = HsOfficePersonRealEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("some trade name")
|
||||
.build();
|
||||
private HsOfficePersonEntity holder = HsOfficePersonEntity.builder()
|
||||
private HsOfficePersonRealEntity holder = HsOfficePersonRealEntity.builder()
|
||||
.personType(HsOfficePersonType.NATURAL_PERSON)
|
||||
.familyName("Meier")
|
||||
.givenName("Mellie")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.hostsharing.hsadminng.hs.scenarios;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacRepository;
|
||||
import net.hostsharing.hsadminng.lambda.Reducer;
|
||||
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
@@ -68,7 +68,7 @@ public abstract class ScenarioTest extends ContextBasedTest {
|
||||
Integer port;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
HsOfficePersonRbacRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
@@ -117,7 +117,7 @@ public abstract class ScenarioTest extends ContextBasedTest {
|
||||
null,
|
||||
personRepo.findPersonByOptionalNameLike("Hostsharing eG")
|
||||
.stream()
|
||||
.map(HsOfficePersonEntity::getUuid)
|
||||
.map(HsOfficePersonRbacEntity::getUuid)
|
||||
.reduce(Reducer::toSingleElement).orElseThrow())
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user