split PersonEntity/Repo into Rbac and Real Entity/Repo and use in Relation for faster lazy loading #130
@ -5,7 +5,7 @@ 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.HsOfficePersonRbacEntity;
|
||||
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;
|
||||
@ -48,10 +48,10 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
HsOfficeRelationRealRepository relationRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRealRepository 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 " + HsOfficePersonRbacEntity.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);
|
||||
|
@ -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.HsOfficePersonRbacEntity;
|
||||
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
|
||||
HsOfficePersonRbacEntity mandateMock;
|
||||
HsOfficePersonRealEntity mandateMock;
|
||||
|
||||
@Mock
|
||||
HsOfficePersonRbacEntity 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(HsOfficePersonRbacEntity.class, GIVEN_MANDANTE_UUID)).thenReturn(mandateMock);
|
||||
lenient().when(em.getReference(HsOfficePersonRbacEntity.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
|
||||
|
Loading…
Reference in New Issue
Block a user