split HsOfficePersonEntity into HsOfficePerson+HsOfficePersonRealEntity+HsOfficePersonRbacEntity

This commit is contained in:
Michael Hoennig 2024-12-04 15:56:34 +01:00
parent ed9e824179
commit df3f1dd5aa
37 changed files with 239 additions and 233 deletions

View File

@ -36,7 +36,7 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
JOIN HsOfficePartnerEntity partner JOIN HsOfficePartnerEntity partner
ON partner.partnerRel.holder = debitor.debitorRel.anchor ON partner.partnerRel.holder = debitor.debitorRel.anchor
AND partner.partnerRel.type = 'PARTNER' AND debitor.debitorRel.type = 'DEBITOR' AND partner.partnerRel.type = 'PARTNER' AND debitor.debitorRel.type = 'DEBITOR'
JOIN HsOfficePersonEntity person JOIN HsOfficePersonRealEntity person
ON person.uuid = partner.partnerRel.holder.uuid ON person.uuid = partner.partnerRel.holder.uuid
OR person.uuid = debitor.debitorRel.holder.uuid OR person.uuid = debitor.debitorRel.holder.uuid
JOIN HsOfficeContactRealEntity contact JOIN HsOfficeContactRealEntity contact

View File

@ -9,7 +9,7 @@ import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartne
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerResource;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerRelInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerRelInsertResource;
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.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
@ -166,8 +166,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
private HsOfficeRelationRealEntity persistPartnerRel(final HsOfficePartnerRelInsertResource resource) { private HsOfficeRelationRealEntity persistPartnerRel(final HsOfficePartnerRelInsertResource resource) {
final var entity = new HsOfficeRelationRealEntity(); final var entity = new HsOfficeRelationRealEntity();
entity.setType(HsOfficeRelationType.PARTNER); entity.setType(HsOfficeRelationType.PARTNER);
entity.setAnchor(ref(HsOfficePersonEntity.class, resource.getAnchorUuid())); entity.setAnchor(ref(HsOfficePersonRealEntity.class, resource.getAnchorUuid()));
entity.setHolder(ref(HsOfficePersonEntity.class, resource.getHolderUuid())); entity.setHolder(ref(HsOfficePersonRealEntity.class, resource.getHolderUuid()));
entity.setContact(ref(HsOfficeContactRealEntity.class, resource.getContactUuid())); entity.setContact(ref(HsOfficeContactRealEntity.class, resource.getContactUuid()));
em.persist(entity); em.persist(entity);
return entity; return entity;

View File

@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.errors.DisplayAs;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContact; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContact;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePerson;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.persistence.BaseEntity;
@ -51,7 +51,7 @@ public class HsOfficePartnerEntity implements Stringifyable, BaseEntity<HsOffice
.withIdProp(HsOfficePartnerEntity::toShortString) .withIdProp(HsOfficePartnerEntity::toShortString)
.withProp(p -> ofNullable(p.getPartnerRel()) .withProp(p -> ofNullable(p.getPartnerRel())
.map(HsOfficeRelation::getHolder) .map(HsOfficeRelation::getHolder)
.map(HsOfficePersonEntity::toShortString) .map(HsOfficePerson::toShortString)
.orElse(null)) .orElse(null))
.withProp(p -> ofNullable(p.getPartnerRel()) .withProp(p -> ofNullable(p.getPartnerRel())
.map(HsOfficeRelation::getContact) .map(HsOfficeRelation::getContact)

View File

@ -20,7 +20,7 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
SELECT partner FROM HsOfficePartnerEntity partner SELECT partner FROM HsOfficePartnerEntity partner
JOIN HsOfficeRelationRealEntity rel ON rel.uuid = partner.partnerRel.uuid JOIN HsOfficeRelationRealEntity rel ON rel.uuid = partner.partnerRel.uuid
JOIN HsOfficeContactRealEntity contact ON contact.uuid = rel.contact.uuid JOIN HsOfficeContactRealEntity contact ON contact.uuid = rel.contact.uuid
JOIN HsOfficePersonEntity person ON person.uuid = rel.holder.uuid JOIN HsOfficePersonRealEntity person ON person.uuid = rel.holder.uuid
WHERE :name is null WHERE :name is null
OR partner.details.birthName like concat(cast(:name as text), '%') OR partner.details.birthName like concat(cast(:name as text), '%')
OR contact.caption like concat(cast(:name as text), '%') OR contact.caption like concat(cast(:name as text), '%')

View File

@ -27,7 +27,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
private StandardMapper mapper; private StandardMapper mapper;
@Autowired @Autowired
private HsOfficePersonRepository personRepo; private HsOfficePersonRbacRepository personRepo;
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@ -54,7 +54,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
context.define(currentSubject, assumedRoles); context.define(currentSubject, assumedRoles);
final var entityToSave = mapper.map(body, HsOfficePersonEntity.class); final var entityToSave = mapper.map(body, HsOfficePersonRbacEntity.class);
final var saved = personRepo.save(entityToSave); final var saved = personRepo.save(entityToSave);

View File

@ -1,103 +0,0 @@
package net.hostsharing.hsadminng.hs.office.person;
import lombok.*;
import lombok.experimental.FieldNameConstants;
import net.hostsharing.hsadminng.errors.DisplayAs;
import net.hostsharing.hsadminng.persistence.BaseEntity;
import net.hostsharing.hsadminng.rbac.generator.RbacView;
import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL;
import net.hostsharing.hsadminng.repr.Stringify;
import net.hostsharing.hsadminng.repr.Stringifyable;
import org.apache.commons.lang3.StringUtils;
import jakarta.persistence.*;
import java.io.IOException;
import java.util.UUID;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor;
import static net.hostsharing.hsadminng.repr.Stringify.stringify;
// TODO.refa: split HsOfficePersonEntity into Real+Rbac-Entity
@Entity
@Table(schema = "hs_office", name = "person_rv")
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@DisplayAs("Person")
public class HsOfficePersonEntity implements BaseEntity<HsOfficePersonEntity>, Stringifyable {
private static Stringify<HsOfficePersonEntity> toString = stringify(HsOfficePersonEntity.class, "person")
.withProp(Fields.personType, HsOfficePersonEntity::getPersonType)
.withProp(Fields.tradeName, HsOfficePersonEntity::getTradeName)
.withProp(Fields.salutation, HsOfficePersonEntity::getSalutation)
.withProp(Fields.title, HsOfficePersonEntity::getTitle)
.withProp(Fields.familyName, HsOfficePersonEntity::getFamilyName)
.withProp(Fields.givenName, HsOfficePersonEntity::getGivenName);
@Id
@GeneratedValue
private UUID uuid;
@Version
private int version;
@Column(name = "persontype")
private HsOfficePersonType personType;
@Column(name = "tradename")
private String tradeName;
@Column(name = "salutation")
private String salutation;
@Column(name = "title")
private String title;
@Column(name = "familyname")
private String familyName;
@Column(name = "givenname")
private String givenName;
@Override
public String toString() {
return toString.apply(this);
}
@Override
public String toShortString() {
return personType + " " +
(!StringUtils.isEmpty(tradeName) ? tradeName : (familyName + ", " + givenName));
}
public static RbacView rbac() {
return rbacViewFor("person", HsOfficePersonEntity.class)
.withIdentityView(SQL.projection("concat(tradeName, familyName, givenName)"))
.withUpdatableColumns("personType", "title", "salutation", "tradeName", "givenName", "familyName")
.toRole(GLOBAL, GUEST).grantPermission(INSERT)
.createRole(OWNER, (with) -> {
with.permission(DELETE);
with.owningUser(CREATOR);
with.incomingSuperRole(GLOBAL, ADMIN);
})
.createSubRole(ADMIN, (with) -> {
with.permission(UPDATE);
})
.createSubRole(REFERRER, (with) -> {
with.permission(SELECT);
});
}
public static void main(String[] args) throws IOException {
rbac().generateWithBaseFileName("5-hs-office/502-person/5023-hs-office-person-rbac");
}
}

View File

@ -9,9 +9,9 @@ import java.util.Optional;
class HsOfficePersonEntityPatcher implements EntityPatcher<HsOfficePersonPatchResource> { class HsOfficePersonEntityPatcher implements EntityPatcher<HsOfficePersonPatchResource> {
private final HsOfficePersonEntity entity; private final HsOfficePersonRbacEntity entity;
HsOfficePersonEntityPatcher(final HsOfficePersonEntity entity) { HsOfficePersonEntityPatcher(final HsOfficePersonRbacEntity entity) {
this.entity = entity; this.entity = entity;
} }

View File

@ -0,0 +1,52 @@
package net.hostsharing.hsadminng.hs.office.person;
import lombok.*;
import lombok.experimental.FieldNameConstants;
import lombok.experimental.SuperBuilder;
import net.hostsharing.hsadminng.errors.DisplayAs;
import net.hostsharing.hsadminng.rbac.generator.RbacView;
import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL;
import jakarta.persistence.*;
import java.io.IOException;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*;
import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor;
@Entity
@Table(schema = "hs_office", name = "person_rv")
@Getter
@Setter
@NoArgsConstructor
@SuperBuilder(toBuilder = true)
@FieldNameConstants
@DisplayAs("RbacPerson")
public class HsOfficePersonRbacEntity extends HsOfficePerson<HsOfficePersonRbacEntity> {
public static RbacView rbac() {
return rbacViewFor("person", HsOfficePersonRbacEntity.class)
.withIdentityView(SQL.projection("concat(tradeName, familyName, givenName)"))
.withUpdatableColumns("personType", "title", "salutation", "tradeName", "givenName", "familyName")
.toRole(GLOBAL, GUEST).grantPermission(INSERT)
.createRole(OWNER, (with) -> {
with.permission(DELETE);
with.owningUser(CREATOR);
with.incomingSuperRole(GLOBAL, ADMIN);
})
.createSubRole(ADMIN, (with) -> {
with.permission(UPDATE);
})
.createSubRole(REFERRER, (with) -> {
with.permission(SELECT);
});
}
public static void main(String[] args) throws IOException {
rbac().generateWithBaseFileName("5-hs-office/502-person/5023-hs-office-person-rbac");
}
}

View File

@ -8,23 +8,23 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
public interface HsOfficePersonRepository extends Repository<HsOfficePersonEntity, UUID> { public interface HsOfficePersonRbacRepository extends Repository<HsOfficePersonRbacEntity, UUID> {
@Timed("app.office.persons.repo.findByUuid.rbac") @Timed("app.office.persons.repo.findByUuid.rbac")
Optional<HsOfficePersonEntity> findByUuid(UUID personUuid); Optional<HsOfficePersonRbacEntity> findByUuid(UUID personUuid);
@Query(""" @Query("""
SELECT p FROM HsOfficePersonEntity p SELECT p FROM HsOfficePersonRbacEntity p
WHERE :name is null WHERE :name is null
OR p.tradeName like concat(cast(:name as text), '%') OR p.tradeName like concat(cast(:name as text), '%')
OR p.givenName like concat(cast(:name as text), '%') OR p.givenName like concat(cast(:name as text), '%')
OR p.familyName like concat(cast(:name as text), '%') OR p.familyName like concat(cast(:name as text), '%')
""") """)
@Timed("app.office.persons.repo.findPersonByOptionalNameLike.rbac") @Timed("app.office.persons.repo.findPersonByOptionalNameLike.rbac")
List<HsOfficePersonEntity> findPersonByOptionalNameLike(String name); List<HsOfficePersonRbacEntity> findPersonByOptionalNameLike(String name);
@Timed("app.office.persons.repo.save.rbac") @Timed("app.office.persons.repo.save.rbac")
HsOfficePersonEntity save(final HsOfficePersonEntity entity); HsOfficePersonRbacEntity save(final HsOfficePersonRbacEntity entity);
@Timed("app.office.persons.repo.deleteByUuid.rbac") @Timed("app.office.persons.repo.deleteByUuid.rbac")
int deleteByUuid(final UUID personUuid); int deleteByUuid(final UUID personUuid);

View File

@ -0,0 +1,23 @@
package net.hostsharing.hsadminng.hs.office.person;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.FieldNameConstants;
import lombok.experimental.SuperBuilder;
import net.hostsharing.hsadminng.errors.DisplayAs;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
@Entity
@Table(schema = "hs_office", name = "person")
@Getter
@Setter
@NoArgsConstructor
@SuperBuilder(toBuilder = true)
@FieldNameConstants
@DisplayAs("RealPerson")
public class HsOfficePersonRealEntity extends HsOfficePerson<HsOfficePersonRealEntity> {
}

View File

@ -0,0 +1,34 @@
package net.hostsharing.hsadminng.hs.office.person;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
public interface HsOfficePersonRealRepository extends Repository<HsOfficePersonRealEntity, UUID> {
@Timed("app.office.persons.repo.findByUuid.rbac")
Optional<HsOfficePersonRealEntity> findByUuid(UUID personUuid);
@Query("""
SELECT p FROM HsOfficePersonRbacEntity p
WHERE :name is null
OR p.tradeName like concat(cast(:name as text), '%')
OR p.givenName like concat(cast(:name as text), '%')
OR p.familyName like concat(cast(:name as text), '%')
""")
@Timed("app.office.persons.repo.findPersonByOptionalNameLike.rbac")
List<HsOfficePersonRealEntity> findPersonByOptionalNameLike(String name);
@Timed("app.office.persons.repo.save.rbac")
HsOfficePersonRealEntity save(final HsOfficePersonRealEntity entity);
@Timed("app.office.persons.repo.deleteByUuid.rbac")
int deleteByUuid(final UUID personUuid);
@Timed("app.office.persons.repo.count.rbac")
long count();
}

View File

@ -4,7 +4,7 @@ import lombok.*;
import lombok.experimental.FieldNameConstants; import lombok.experimental.FieldNameConstants;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; 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.persistence.BaseEntity; import net.hostsharing.hsadminng.persistence.BaseEntity;
import net.hostsharing.hsadminng.repr.Stringify; import net.hostsharing.hsadminng.repr.Stringify;
import net.hostsharing.hsadminng.repr.Stringifyable; import net.hostsharing.hsadminng.repr.Stringifyable;
@ -45,11 +45,11 @@ public class HsOfficeRelation implements BaseEntity<HsOfficeRelation>, Stringify
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "anchoruuid") @JoinColumn(name = "anchoruuid")
private HsOfficePersonEntity anchor; private HsOfficePersonRealEntity anchor;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "holderuuid") @JoinColumn(name = "holderuuid")
private HsOfficePersonEntity holder; private HsOfficePersonRealEntity holder;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "contactuuid") @JoinColumn(name = "contactuuid")

View File

@ -5,7 +5,7 @@ import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeRelationsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeRelationsApi;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.*; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.*;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository;
import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.mapper.StandardMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -34,7 +34,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
private HsOfficeRelationRbacRepository relationRbacRepo; private HsOfficeRelationRbacRepository relationRbacRepo;
@Autowired @Autowired
private HsOfficePersonRepository holderRepo; private HsOfficePersonRealRepository personRepo;
@Autowired @Autowired
private HsOfficeContactRealRepository realContactRepo; private HsOfficeContactRealRepository realContactRepo;
@ -78,10 +78,10 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
final var entityToSave = new HsOfficeRelationRbacEntity(); final var entityToSave = new HsOfficeRelationRbacEntity();
entityToSave.setType(HsOfficeRelationType.valueOf(body.getType())); entityToSave.setType(HsOfficeRelationType.valueOf(body.getType()));
entityToSave.setMark(body.getMark()); entityToSave.setMark(body.getMark());
entityToSave.setAnchor(holderRepo.findByUuid(body.getAnchorUuid()).orElseThrow( entityToSave.setAnchor(personRepo.findByUuid(body.getAnchorUuid()).orElseThrow(
() -> new NoSuchElementException("cannot find Person by anchorUuid: " + body.getAnchorUuid()) () -> new NoSuchElementException("cannot find Person by anchorUuid: " + body.getAnchorUuid())
)); ));
entityToSave.setHolder(holderRepo.findByUuid(body.getHolderUuid()).orElseThrow( entityToSave.setHolder(personRepo.findByUuid(body.getHolderUuid()).orElseThrow(
() -> new NoSuchElementException("cannot find Person by holderUuid: " + body.getHolderUuid()) () -> new NoSuchElementException("cannot find Person by holderUuid: " + body.getHolderUuid())
)); ));
entityToSave.setContact(realContactRepo.findByUuid(body.getContactUuid()).orElseThrow( entityToSave.setContact(realContactRepo.findByUuid(body.getContactUuid()).orElseThrow(

View File

@ -6,7 +6,7 @@ import lombok.Setter;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.errors.DisplayAs;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity;
import net.hostsharing.hsadminng.rbac.generator.RbacView; import net.hostsharing.hsadminng.rbac.generator.RbacView;
import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL;
@ -52,11 +52,11 @@ public class HsOfficeRelationRbacEntity extends HsOfficeRelation {
.withRestrictedViewOrderBy(SQL.expression( .withRestrictedViewOrderBy(SQL.expression(
"(select idName from hs_office.person_iv p where p.uuid = target.holderUuid)")) "(select idName from hs_office.person_iv p where p.uuid = target.holderUuid)"))
.withUpdatableColumns("contactUuid") .withUpdatableColumns("contactUuid")
.importEntityAlias("anchorPerson", HsOfficePersonEntity.class, usingDefaultCase(), .importEntityAlias("anchorPerson", HsOfficePersonRbacEntity.class, usingDefaultCase(),
dependsOnColumn("anchorUuid"), dependsOnColumn("anchorUuid"),
directlyFetchedByDependsOnColumn(), directlyFetchedByDependsOnColumn(),
NOT_NULL) NOT_NULL)
.importEntityAlias("holderPerson", HsOfficePersonEntity.class, usingDefaultCase(), .importEntityAlias("holderPerson", HsOfficePersonRbacEntity.class, usingDefaultCase(),
dependsOnColumn("holderUuid"), dependsOnColumn("holderUuid"),
directlyFetchedByDependsOnColumn(), directlyFetchedByDependsOnColumn(),
NOT_NULL) NOT_NULL)

View File

@ -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.membership.HsOfficeMembershipStatus;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerDetailsEntity; import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerDetailsEntity;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; 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.person.HsOfficePersonType;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; 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, 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, HsOfficePartnerEntity> partners = new WriteOnceMap<>();
static Map<Integer, HsOfficeDebitorEntity> debitors = new WriteOnceMap<>(); static Map<Integer, HsOfficeDebitorEntity> debitors = new WriteOnceMap<>();
static Map<Integer, HsOfficeMembershipEntity> memberships = new WriteOnceMap<>(); static Map<Integer, HsOfficeMembershipEntity> memberships = new WriteOnceMap<>();
@ -731,7 +731,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
return; return;
} }
final var person = HsOfficePersonEntity.builder().build(); final var person = HsOfficePersonRealEntity.builder().build();
final var partnerRel = addRelation( final var partnerRel = addRelation(
HsOfficeRelationType.PARTNER, HsOfficeRelationType.PARTNER,
@ -994,14 +994,14 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
addPerson(partnerPerson, rec); addPerson(partnerPerson, rec);
} }
HsOfficePersonEntity contactPerson = partnerPerson; HsOfficePersonRealEntity contactPerson = partnerPerson;
if (!StringUtils.equals(rec.getString("firma"), partnerPerson.getTradeName()) || if (!StringUtils.equals(rec.getString("firma"), partnerPerson.getTradeName()) ||
partnerPerson.getPersonType() != determinePersonType(rec) || partnerPerson.getPersonType() != determinePersonType(rec) ||
!StringUtils.equals(rec.getString("title"), partnerPerson.getTitle()) || !StringUtils.equals(rec.getString("title"), partnerPerson.getTitle()) ||
!StringUtils.equals(rec.getString("salut"), partnerPerson.getSalutation()) || !StringUtils.equals(rec.getString("salut"), partnerPerson.getSalutation()) ||
!StringUtils.equals(rec.getString("first_name"), partnerPerson.getGivenName()) || !StringUtils.equals(rec.getString("first_name"), partnerPerson.getGivenName()) ||
!StringUtils.equals(rec.getString("last_name"), partnerPerson.getFamilyName())) { !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(); final var contact = HsOfficeContactRealEntity.builder().build();
@ -1084,8 +1084,8 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
private static HsOfficeRelationRealEntity addRelation( private static HsOfficeRelationRealEntity addRelation(
final HsOfficeRelationType type, final HsOfficeRelationType type,
final HsOfficePersonEntity anchor, final HsOfficePersonRealEntity anchor,
final HsOfficePersonEntity holder, final HsOfficePersonRealEntity holder,
final HsOfficeContactRealEntity contact) { final HsOfficeContactRealEntity contact) {
final var rel = HsOfficeRelationRealEntity.builder() final var rel = HsOfficeRelationRealEntity.builder()
.anchor(anchor) .anchor(anchor)
@ -1097,7 +1097,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
return rel; 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.setSalutation(contactRecord.getString("salut"));
person.setTitle(contactRecord.getString("title")); person.setTitle(contactRecord.getString("title"));
person.setGivenName(contactRecord.getString("first_name")); person.setGivenName(contactRecord.getString("first_name"));

View File

@ -7,7 +7,7 @@ import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; 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.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
@ -57,16 +57,16 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
HsOfficePartnerRepository partnerRepo; HsOfficePartnerRepository partnerRepo;
@Autowired @Autowired
HsOfficeContactRealRepository contactrealRepo; HsOfficeContactRealRepository contactRealRepo;
@Autowired @Autowired
HsOfficeBankAccountRepository bankAccountRepo; HsOfficeBankAccountRepository bankAccountRepo;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRealRepository personRealRepo;
@Autowired @Autowired
HsOfficeRelationRealRepository relrealRepo; HsOfficeRelationRealRepository relationRealRepo;
@Autowired @Autowired
JpaAttempt jpaAttempt; JpaAttempt jpaAttempt;
@ -270,13 +270,13 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0); 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 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(() -> { final var givenDebitorRelUUid = jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
return relrealRepo.save(HsOfficeRelationRealEntity.builder() return relationRealRepo.save(HsOfficeRelationRealEntity.builder()
.type(DEBITOR) .type(DEBITOR)
.anchor(givenPartner.getPartnerRel().getHolder()) .anchor(givenPartner.getPartnerRel().getHolder())
.holder(givenBillingPerson) .holder(givenBillingPerson)
@ -327,7 +327,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0); 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 final var location = RestAssured // @formatter:off
.given() .given()
@ -554,7 +554,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = givenSomeTemporaryDebitor(); 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 final var location = RestAssured // @formatter:off
.given() .given()
@ -724,7 +724,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
return jpaAttempt.transacted(() -> { return jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0).load(); 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() final var newDebitor = HsOfficeDebitorEntity.builder()
.debitorNumberSuffix(nextDebitorSuffix()) .debitorNumberSuffix(nextDebitorSuffix())
.billable(true) .billable(true)

View File

@ -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.contact.HsOfficeContactRealEntity;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; 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.person.HsOfficePersonType;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
@ -13,11 +13,11 @@ import static org.assertj.core.api.Assertions.assertThat;
class HsOfficeDebitorEntityUnitTest { class HsOfficeDebitorEntityUnitTest {
private final HsOfficeRelationRealEntity givenDebitorRel = HsOfficeRelationRealEntity.builder() private final HsOfficeRelationRealEntity givenDebitorRel = HsOfficeRelationRealEntity.builder()
.anchor(HsOfficePersonEntity.builder() .anchor(HsOfficePersonRealEntity.builder()
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some partner trade name") .tradeName("some partner trade name")
.build()) .build())
.holder(HsOfficePersonEntity.builder() .holder(HsOfficePersonRealEntity.builder()
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some billing trade name") .tradeName("some billing trade name")
.build()) .build())

View File

@ -4,7 +4,7 @@ import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; 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.HsOfficeRelation;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
@ -53,7 +53,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
HsOfficeContactRealRepository contactrealRepo; HsOfficeContactRealRepository contactrealRepo;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRealRepository personRepo;
@Autowired @Autowired
HsOfficeBankAccountRepository bankAccountRepo; HsOfficeBankAccountRepository bankAccountRepo;

View File

@ -1,7 +1,7 @@
package net.hostsharing.hsadminng.hs.office.debitor; package net.hostsharing.hsadminng.hs.office.debitor;
import lombok.experimental.UtilityClass; 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 net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import static net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealTestEntity.TEST_REAL_CONTACT; 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() public static final HsOfficeDebitorEntity TEST_DEBITOR = HsOfficeDebitorEntity.builder()
.debitorNumberSuffix(DEFAULT_DEBITOR_SUFFIX) .debitorNumberSuffix(DEFAULT_DEBITOR_SUFFIX)
.debitorRel(HsOfficeRelationRealEntity.builder() .debitorRel(HsOfficeRelationRealEntity.builder()
.holder(HsOfficePersonEntity.builder().build()) .holder(HsOfficePersonRealEntity.builder().build())
.anchor(HsOfficePersonEntity.builder().build()) .anchor(HsOfficePersonRealEntity.builder().build())
.contact(TEST_REAL_CONTACT) .contact(TEST_REAL_CONTACT)
.build()) .build())
.partner(TEST_PARTNER) .partner(TEST_PARTNER)

View File

@ -5,8 +5,8 @@ import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity;
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.HsOfficeRelation;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
@ -48,7 +48,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
HsOfficeRelationRealRepository relationRepo; HsOfficeRelationRealRepository relationRepo;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRealRepository personRepo;
@Autowired @Autowired
HsOfficeContactRealRepository contactrealRepo; HsOfficeContactRealRepository contactrealRepo;
@ -224,7 +224,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
// TODO.impl: we want this error message: // TODO.impl: we want this error message:
// .body("message", is("ERROR: [400] Unable to find Person by uuid: " + GIVEN_NON_EXISTING_UUID)); // .body("message", is("ERROR: [400] Unable to find Person by uuid: " + GIVEN_NON_EXISTING_UUID));
// but ModelMapper creates this error message: // 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 " + HsOfficePersonRbacEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID));
// @formatter:on // @formatter:on
} }
} }

View File

@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.mapper.StandardMapper;
@ -66,10 +66,10 @@ class HsOfficePartnerControllerRestTest {
EntityManagerFactory emf; EntityManagerFactory emf;
@Mock @Mock
HsOfficePersonEntity mandateMock; HsOfficePersonRbacEntity mandateMock;
@Mock @Mock
HsOfficePersonEntity personMock; HsOfficePersonRbacEntity personMock;
@Mock @Mock
HsOfficeContactRbacEntity contactMock; HsOfficeContactRbacEntity contactMock;
@ -84,8 +84,8 @@ class HsOfficePartnerControllerRestTest {
when(emf.createEntityManager(any(SynchronizationType.class))).thenReturn(em); when(emf.createEntityManager(any(SynchronizationType.class))).thenReturn(em);
when(emf.createEntityManager(any(SynchronizationType.class), any(Map.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(HsOfficePersonRbacEntity.class, GIVEN_MANDANTE_UUID)).thenReturn(mandateMock);
lenient().when(em.getReference(HsOfficePersonEntity.class, GIVEN_PERSON_UUID)).thenReturn(personMock); lenient().when(em.getReference(HsOfficePersonRbacEntity.class, GIVEN_PERSON_UUID)).thenReturn(personMock);
lenient().when(em.getReference(HsOfficeContactRbacEntity.class, GIVEN_CONTACT_UUID)).thenReturn(contactMock); lenient().when(em.getReference(HsOfficeContactRbacEntity.class, GIVEN_CONTACT_UUID)).thenReturn(contactMock);
lenient().when(em.getReference(any(), eq(GIVEN_INVALID_UUID))).thenThrow(EntityNotFoundException.class); lenient().when(em.getReference(any(), eq(GIVEN_INVALID_UUID))).thenThrow(EntityNotFoundException.class);
} }

View File

@ -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.contact.HsOfficeContactRbacEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource; 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 net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
@ -45,8 +45,8 @@ class HsOfficePartnerDetailsEntityPatcherUnitTest extends PatchUnitTestBase<
void initMocks() { void initMocks() {
lenient().when(em.getReference(eq(HsOfficeContactRbacEntity.class), any())).thenAnswer(invocation -> lenient().when(em.getReference(eq(HsOfficeContactRbacEntity.class), any())).thenAnswer(invocation ->
HsOfficeContactRbacEntity.builder().uuid(invocation.getArgument(1)).build()); HsOfficeContactRbacEntity.builder().uuid(invocation.getArgument(1)).build());
lenient().when(em.getReference(eq(HsOfficePersonEntity.class), any())).thenAnswer(invocation -> lenient().when(em.getReference(eq(HsOfficePersonRbacEntity.class), any())).thenAnswer(invocation ->
HsOfficePersonEntity.builder().uuid(invocation.getArgument(1)).build()); HsOfficePersonRbacEntity.builder().uuid(invocation.getArgument(1)).build());
} }
@Override @Override

View File

@ -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.contact.HsOfficeContactRealEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource; 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.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase; import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach; 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 INITIAL_DETAILS_UUID = UUID.randomUUID();
private static final UUID PATCHED_PARTNER_ROLE_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) .uuid(INITIAL_PERSON_UUID)
.build(); .build();
private final HsOfficeContactRealEntity givenInitialContact = HsOfficeContactRealEntity.builder() private final HsOfficeContactRealEntity givenInitialContact = HsOfficeContactRealEntity.builder()

View File

@ -1,7 +1,7 @@
package net.hostsharing.hsadminng.hs.office.partner; package net.hostsharing.hsadminng.hs.office.partner;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; 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.person.HsOfficePersonType;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
@ -15,12 +15,12 @@ class HsOfficePartnerEntityUnitTest {
private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder() private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder()
.partnerNumber(12345) .partnerNumber(12345)
.partnerRel(HsOfficeRelationRealEntity.builder() .partnerRel(HsOfficeRelationRealEntity.builder()
.anchor(HsOfficePersonEntity.builder() .anchor(HsOfficePersonRealEntity.builder()
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("Hostsharing eG") .tradeName("Hostsharing eG")
.build()) .build())
.type(HsOfficeRelationType.PARTNER) .type(HsOfficeRelationType.PARTNER)
.holder(HsOfficePersonEntity.builder() .holder(HsOfficePersonRealEntity.builder()
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.build()) .build())

View File

@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; 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.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
@ -45,7 +45,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
HsOfficeRelationRealRepository relationRepo; HsOfficeRelationRealRepository relationRepo;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRealRepository personRepo;
@Autowired @Autowired
HsOfficeContactRealRepository contactrealRepo; HsOfficeContactRealRepository contactrealRepo;

View File

@ -1,7 +1,7 @@
package net.hostsharing.hsadminng.hs.office.partner; package net.hostsharing.hsadminng.hs.office.partner;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; 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.HsOfficeRelationRealEntity;
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
@ -16,12 +16,12 @@ public class TestHsOfficePartner {
.partnerNumber(10001) .partnerNumber(10001)
.partnerRel( .partnerRel(
HsOfficeRelationRealEntity.builder() HsOfficeRelationRealEntity.builder()
.holder(HsOfficePersonEntity.builder() .holder(HsOfficePersonRealEntity.builder()
.personType(LEGAL_PERSON) .personType(LEGAL_PERSON)
.tradeName("Hostsharing eG") .tradeName("Hostsharing eG")
.build()) .build())
.type(HsOfficeRelationType.PARTNER) .type(HsOfficeRelationType.PARTNER)
.holder(HsOfficePersonEntity.builder() .holder(HsOfficePersonRealEntity.builder()
.personType(LEGAL_PERSON) .personType(LEGAL_PERSON)
.tradeName(tradeName) .tradeName(tradeName)
.build()) .build())

View File

@ -43,7 +43,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
Context contextMock; Context contextMock;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRealRepository personRepo;
@Autowired @Autowired
JpaAttempt jpaAttempt; 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(() -> { return jpaAttempt.transacted(() -> {
context.define(creatingUser); context.define(creatingUser);
final var newPerson = HsOfficePersonEntity.builder() final var newPerson = HsOfficePersonRealEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("Temp " + Context.getCallerMethodNameFromStackFrame(2)) .tradeName("Temp " + Context.getCallerMethodNameFromStackFrame(2))
@ -347,7 +347,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
jpaAttempt.transacted(() -> { jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net", null); context.define("superuser-alex@hostsharing.net", null);
em.createQuery(""" em.createQuery("""
DELETE FROM HsOfficePersonEntity p DELETE FROM HsOfficePersonRealEntity p
WHERE p.tradeName LIKE 'Temp %' OR p.givenName LIKE 'Temp %' WHERE p.tradeName LIKE 'Temp %' OR p.givenName LIKE 'Temp %'
""").executeUpdate(); """).executeUpdate();
}).assertSuccessful(); }).assertSuccessful();

View File

@ -13,14 +13,14 @@ import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
@TestInstance(PER_CLASS) @TestInstance(PER_CLASS)
class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase< class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
HsOfficePersonPatchResource, HsOfficePersonPatchResource,
HsOfficePersonEntity HsOfficePersonRbacEntity
> { > {
private static final UUID INITIAL_PERSON_UUID = UUID.randomUUID(); private static final UUID INITIAL_PERSON_UUID = UUID.randomUUID();
@Override @Override
protected HsOfficePersonEntity newInitialEntity() { protected HsOfficePersonRbacEntity newInitialEntity() {
final var entity = new HsOfficePersonEntity(); final var entity = new HsOfficePersonRbacEntity();
entity.setUuid(INITIAL_PERSON_UUID); entity.setUuid(INITIAL_PERSON_UUID);
entity.setPersonType(HsOfficePersonType.LEGAL_PERSON); entity.setPersonType(HsOfficePersonType.LEGAL_PERSON);
entity.setTradeName("initial trade name"); entity.setTradeName("initial trade name");
@ -37,7 +37,7 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
} }
@Override @Override
protected HsOfficePersonEntityPatcher createPatcher(final HsOfficePersonEntity entity) { protected HsOfficePersonEntityPatcher createPatcher(final HsOfficePersonRbacEntity entity) {
return new HsOfficePersonEntityPatcher(entity); return new HsOfficePersonEntityPatcher(entity);
} }
@ -48,34 +48,34 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase<
"personType", "personType",
HsOfficePersonPatchResource::setPersonType, HsOfficePersonPatchResource::setPersonType,
HsOfficePersonTypeResource.INCORPORATED_FIRM, HsOfficePersonTypeResource.INCORPORATED_FIRM,
HsOfficePersonEntity::setPersonType, HsOfficePersonRbacEntity::setPersonType,
HsOfficePersonType.INCORPORATED_FIRM) HsOfficePersonType.INCORPORATED_FIRM)
.notNullable(), .notNullable(),
new JsonNullableProperty<>( new JsonNullableProperty<>(
"tradeName", "tradeName",
HsOfficePersonPatchResource::setTradeName, HsOfficePersonPatchResource::setTradeName,
"patched trade name", "patched trade name",
HsOfficePersonEntity::setTradeName), HsOfficePersonRbacEntity::setTradeName),
new JsonNullableProperty<>( new JsonNullableProperty<>(
"title", "title",
HsOfficePersonPatchResource::setTitle, HsOfficePersonPatchResource::setTitle,
"Dr. Patch.", "Dr. Patch.",
HsOfficePersonEntity::setTitle), HsOfficePersonRbacEntity::setTitle),
new JsonNullableProperty<>( new JsonNullableProperty<>(
"salutation", "salutation",
HsOfficePersonPatchResource::setSalutation, HsOfficePersonPatchResource::setSalutation,
"Hallo Ini", "Hallo Ini",
HsOfficePersonEntity::setSalutation), HsOfficePersonRbacEntity::setSalutation),
new JsonNullableProperty<>( new JsonNullableProperty<>(
"familyName", "familyName",
HsOfficePersonPatchResource::setFamilyName, HsOfficePersonPatchResource::setFamilyName,
"patched family name", "patched family name",
HsOfficePersonEntity::setFamilyName), HsOfficePersonRbacEntity::setFamilyName),
new JsonNullableProperty<>( new JsonNullableProperty<>(
"patched given name", "patched given name",
HsOfficePersonPatchResource::setGivenName, HsOfficePersonPatchResource::setGivenName,
"patched given name", "patched given name",
HsOfficePersonEntity::setGivenName) HsOfficePersonRbacEntity::setGivenName)
); );
} }
} }

View File

@ -11,7 +11,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void getDisplayReturnsTradeNameIfAvailable() { void getDisplayReturnsTradeNameIfAvailable() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.build(); .build();
@ -23,7 +23,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void getDisplayReturnsFamilyAndGivenNameIfNoTradeNameAvailable() { void getDisplayReturnsFamilyAndGivenNameIfNoTradeNameAvailable() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
@ -36,7 +36,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void toShortStringWithTradeNameReturnsTradeName() { void toShortStringWithTradeNameReturnsTradeName() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.familyName("some family name") .familyName("some family name")
@ -50,7 +50,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void toShortStringWithoutTradeNameReturnsFamilyAndGivenName() { void toShortStringWithoutTradeNameReturnsFamilyAndGivenName() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
@ -63,7 +63,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void toShortStringWithSalutationAndTitleReturnsSalutationAndTitle() { void toShortStringWithSalutationAndTitleReturnsSalutationAndTitle() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.salutation("Frau") .salutation("Frau")
.title("Dr.") .title("Dr.")
@ -78,7 +78,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void toShortStringWithSalutationAndWithoutTitleReturnsSalutation() { void toShortStringWithSalutationAndWithoutTitleReturnsSalutation() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.salutation("Frau") .salutation("Frau")
.familyName("some family name") .familyName("some family name")
@ -92,7 +92,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void toShortStringWithoutSalutationAndWithTitleReturnsTitle() { void toShortStringWithoutSalutationAndWithTitleReturnsTitle() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.title("Dr. Dr.") .title("Dr. Dr.")
.familyName("some family name") .familyName("some family name")
@ -106,7 +106,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void toStringWithAllFieldsReturnsAllButUuid() { void toStringWithAllFieldsReturnsAllButUuid() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
@ -122,7 +122,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void toStringSkipsNullFields() { void toStringSkipsNullFields() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
.build(); .build();
@ -133,7 +133,7 @@ class HsOfficePersonEntityUnitTest {
} }
@Test @Test
void toStringWithSalutationAndTitleRetursSalutationAndTitle() { void toStringWithSalutationAndTitleRetursSalutationAndTitle() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.salutation("Herr") .salutation("Herr")
.title("Prof. Dr.") .title("Prof. Dr.")
.familyName("some family name") .familyName("some family name")
@ -146,7 +146,7 @@ class HsOfficePersonEntityUnitTest {
} }
@Test @Test
void toStringWithSalutationAndWithoutTitleSkipsTitle() { void toStringWithSalutationAndWithoutTitleSkipsTitle() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.salutation("Herr") .salutation("Herr")
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
@ -159,7 +159,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void toStringWithoutSalutationAndWithTitleSkipsSalutation() { void toStringWithoutSalutationAndWithTitleSkipsSalutation() {
final var givenPersonEntity = HsOfficePersonEntity.builder() final var givenPersonEntity = HsOfficePersonRbacEntity.builder()
.title("some title") .title("some title")
.familyName("some family name") .familyName("some family name")
.givenName("some given name") .givenName("some given name")
@ -172,7 +172,7 @@ class HsOfficePersonEntityUnitTest {
@Test @Test
void definesRbac() { void definesRbac() {
final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePersonEntity.rbac()).toString(); final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePersonRbacEntity.rbac()).toString();
assertThat(rbacFlowchart).isEqualTo(""" assertThat(rbacFlowchart).isEqualTo("""
%%{init:{'flowchart':{'htmlLabels':false}}}%% %%{init:{'flowchart':{'htmlLabels':false}}}%%
flowchart TB flowchart TB

View File

@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanup { class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRbacRepository personRepo;
@Autowired @Autowired
RawRbacRoleRepository rawRoleRepo; RawRbacRoleRepository rawRoleRepo;
@ -64,7 +64,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
// then // then
result.assertSuccessful(); result.assertSuccessful();
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonEntity::getUuid).isNotNull(); assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRbacEntity::getUuid).isNotNull();
assertThatPersonIsPersisted(result.returnedValue()); assertThatPersonIsPersisted(result.returnedValue());
assertThat(personRepo.count()).isEqualTo(count + 1); assertThat(personRepo.count()).isEqualTo(count + 1);
} }
@ -81,7 +81,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
// then // then
result.assertSuccessful(); result.assertSuccessful();
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonEntity::getUuid).isNotNull(); assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRbacEntity::getUuid).isNotNull();
assertThatPersonIsPersisted(result.returnedValue()); assertThatPersonIsPersisted(result.returnedValue());
assertThat(personRepo.count()).isEqualTo(count + 1); assertThat(personRepo.count()).isEqualTo(count + 1);
} }
@ -122,7 +122,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
)); ));
} }
private void assertThatPersonIsPersisted(final HsOfficePersonEntity saved) { private void assertThatPersonIsPersisted(final HsOfficePersonRbacEntity saved) {
final var found = personRepo.findByUuid(saved.getUuid()); final var found = personRepo.findByUuid(saved.getUuid());
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString()); assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
} }
@ -276,27 +276,27 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu
"[creating person test-data, hs_office.person, INSERT, Third OHG, null]"); "[creating person test-data, hs_office.person, INSERT, Third OHG, null]");
} }
private HsOfficePersonEntity givenSomeTemporaryPerson( private HsOfficePersonRbacEntity givenSomeTemporaryPerson(
final String createdByUser, final String createdByUser,
Supplier<HsOfficePersonEntity> entitySupplier) { Supplier<HsOfficePersonRbacEntity> entitySupplier) {
return jpaAttempt.transacted(() -> { return jpaAttempt.transacted(() -> {
context(createdByUser); context(createdByUser);
return toCleanup(personRepo.save(entitySupplier.get())); return toCleanup(personRepo.save(entitySupplier.get()));
}).assumeSuccessful().returnedValue(); }).assumeSuccessful().returnedValue();
} }
private HsOfficePersonEntity givenSomeTemporaryPerson(final String createdByUser) { private HsOfficePersonRbacEntity givenSomeTemporaryPerson(final String createdByUser) {
return givenSomeTemporaryPerson(createdByUser, () -> return givenSomeTemporaryPerson(createdByUser, () ->
hsOfficePerson("some temporary person #" + RandomStringUtils.random(12))); hsOfficePerson("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) assertThat(actualResult)
.extracting(HsOfficePersonEntity::getTradeName) .extracting(HsOfficePersonRbacEntity::getTradeName)
.containsExactlyInAnyOrder(personCaptions); .containsExactlyInAnyOrder(personCaptions);
} }
void allThesePersonsAreReturned(final List<HsOfficePersonEntity> actualResult, final String... personCaptions) { void allThesePersonsAreReturned(final List<HsOfficePersonRbacEntity> actualResult, final String... personCaptions) {
assertThat(actualResult) assertThat(actualResult)
.extracting(hsOfficePersonEntity -> hsOfficePersonEntity.toShortString()) .extracting(hsOfficePersonEntity -> hsOfficePersonEntity.toShortString())
.contains(personCaptions); .contains(personCaptions);

View File

@ -3,10 +3,10 @@ package net.hostsharing.hsadminng.hs.office.person;
public class TestHsOfficePerson { public class TestHsOfficePerson {
public static final HsOfficePersonEntity somePerson = hsOfficePerson("some person"); public static final HsOfficePersonRbacEntity somePerson = hsOfficePerson("some person");
static public HsOfficePersonEntity hsOfficePerson(final String tradeName) { static public HsOfficePersonRbacEntity hsOfficePerson(final String tradeName) {
return HsOfficePersonEntity.builder() return HsOfficePersonRbacEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.tradeName(tradeName) .tradeName(tradeName)
.build(); .build();

View File

@ -1,7 +1,7 @@
package net.hostsharing.hsadminng.hs.office.relation; package net.hostsharing.hsadminng.hs.office.relation;
import net.hostsharing.hsadminng.context.Context; 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.hs.office.person.HsOfficePersonType;
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
@ -30,7 +30,7 @@ class HsOfficeRealRelationRepositoryIntegrationTest extends ContextBasedTestWith
HsOfficeRelationRealRepository relationRealRepo; HsOfficeRelationRealRepository relationRealRepo;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRbacRepository personRepo;
@PersistenceContext @PersistenceContext
EntityManager em; EntityManager em;

View File

@ -3,11 +3,11 @@ package net.hostsharing.hsadminng.hs.office.relation;
import io.restassured.RestAssured; import io.restassured.RestAssured;
import io.restassured.http.ContentType; import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; 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.rbac.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationTypeResource; 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.rbac.test.JpaAttempt;
import net.hostsharing.hsadminng.test.DisableSecurityConfig; import net.hostsharing.hsadminng.test.DisableSecurityConfig;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
@ -45,7 +45,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
HsOfficeRelationRealRepository relationrealRepo; HsOfficeRelationRealRepository relationrealRepo;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRealRepository personRepo;
@Autowired @Autowired
HsOfficeContactRealRepository contactrealRepo; HsOfficeContactRealRepository contactrealRepo;

View File

@ -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.contact.HsOfficeContactRealEntity;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationPatchResource; 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 net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
@ -38,10 +38,10 @@ class HsOfficeRelationPatcherUnitTest extends PatchUnitTestBase<
HsOfficeContactRealEntity.builder().uuid(invocation.getArgument(1)).build()); HsOfficeContactRealEntity.builder().uuid(invocation.getArgument(1)).build());
} }
final HsOfficePersonEntity givenInitialAnchorPerson = HsOfficePersonEntity.builder() final HsOfficePersonRealEntity givenInitialAnchorPerson = HsOfficePersonRealEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.build(); .build();
final HsOfficePersonEntity givenInitialHolderPerson = HsOfficePersonEntity.builder() final HsOfficePersonRealEntity givenInitialHolderPerson = HsOfficePersonRealEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())
.build(); .build();
final HsOfficeContactRealEntity givenInitialContact = HsOfficeContactRealEntity.builder() final HsOfficeContactRealEntity givenInitialContact = HsOfficeContactRealEntity.builder()

View File

@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.relation;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; 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.test.ContextBasedTestWithCleanup;
import net.hostsharing.hsadminng.rbac.grant.RawRbacGrantRepository; import net.hostsharing.hsadminng.rbac.grant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository;
@ -37,7 +37,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
HsOfficeRelationRbacRepository relationRbacRepo; HsOfficeRelationRbacRepository relationRbacRepo;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRealRepository personRepo;
@Autowired @Autowired
HsOfficeContactRealRepository contactrealRepo; HsOfficeContactRealRepository contactrealRepo;

View File

@ -1,6 +1,6 @@
package net.hostsharing.hsadminng.hs.office.relation; 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.hs.office.person.HsOfficePersonType;
import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -9,11 +9,11 @@ import static org.assertj.core.api.Assertions.assertThat;
class HsOfficeRelationUnitTest { class HsOfficeRelationUnitTest {
private HsOfficePersonEntity anchor = HsOfficePersonEntity.builder() private HsOfficePersonRealEntity anchor = HsOfficePersonRealEntity.builder()
.personType(HsOfficePersonType.LEGAL_PERSON) .personType(HsOfficePersonType.LEGAL_PERSON)
.tradeName("some trade name") .tradeName("some trade name")
.build(); .build();
private HsOfficePersonEntity holder = HsOfficePersonEntity.builder() private HsOfficePersonRealEntity holder = HsOfficePersonRealEntity.builder()
.personType(HsOfficePersonType.NATURAL_PERSON) .personType(HsOfficePersonType.NATURAL_PERSON)
.familyName("Meier") .familyName("Meier")
.givenName("Mellie") .givenName("Mellie")

View File

@ -1,8 +1,8 @@
package net.hostsharing.hsadminng.hs.scenarios; package net.hostsharing.hsadminng.hs.scenarios;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacRepository;
import net.hostsharing.hsadminng.lambda.Reducer; import net.hostsharing.hsadminng.lambda.Reducer;
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest; import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
@ -68,7 +68,7 @@ public abstract class ScenarioTest extends ContextBasedTest {
Integer port; Integer port;
@Autowired @Autowired
HsOfficePersonRepository personRepo; HsOfficePersonRbacRepository personRepo;
@Autowired @Autowired
JpaAttempt jpaAttempt; JpaAttempt jpaAttempt;
@ -117,7 +117,7 @@ public abstract class ScenarioTest extends ContextBasedTest {
null, null,
personRepo.findPersonByOptionalNameLike("Hostsharing eG") personRepo.findPersonByOptionalNameLike("Hostsharing eG")
.stream() .stream()
.map(HsOfficePersonEntity::getUuid) .map(HsOfficePersonRbacEntity::getUuid)
.reduce(Reducer::toSingleElement).orElseThrow()) .reduce(Reducer::toSingleElement).orElseThrow())
); );
} }