improve-performance-of-office-data-import #83
@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.booking.project;
|
||||
import lombok.*;
|
||||
import net.hostsharing.hsadminng.hs.booking.debitor.HsBookingDebitorEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
@ -81,7 +81,7 @@ public class HsBookingProjectEntity implements Stringifyable, RbacObject<HsBooki
|
||||
directlyFetchedByDependsOnColumn(),
|
||||
NOT_NULL)
|
||||
|
||||
.importEntityAlias("debitorRel", HsOfficeRelationEntity.class, usingCase(DEBITOR),
|
||||
.importEntityAlias("debitorRel", HsOfficeRelation.class, usingCase(DEBITOR),
|
||||
dependsOnColumn("debitorUuid"),
|
||||
fetchedBySql("""
|
||||
SELECT ${columns}
|
||||
|
@ -32,8 +32,8 @@ import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
||||
@MappedSuperclass
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@AllArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@SuperBuilder(toBuilder = true)
|
||||
@FieldNameConstants
|
||||
@DisplayName("Contact")
|
||||
|
@ -5,8 +5,8 @@ import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeDebitors
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorInsertResource;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorResource;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareRepository;
|
||||
import net.hostsharing.hsadminng.mapper.Mapper;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hibernate.Hibernate;
|
||||
@ -38,7 +38,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
|
||||
private HsOfficeDebitorRepository debitorRepo;
|
||||
|
||||
@Autowired
|
||||
private HsOfficeRelationRepository relRepo;
|
||||
private HsOfficeRelationBareRepository relBareRepo;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
@ -82,12 +82,12 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
|
||||
final var entityToSave = mapper.map(body, HsOfficeDebitorEntity.class);
|
||||
if ( body.getDebitorRel() != null ) {
|
||||
body.getDebitorRel().setType(DEBITOR.name());
|
||||
final var debitorRel = mapper.map(body.getDebitorRel(), HsOfficeRelationEntity.class);
|
||||
entityToSave.setDebitorRel(relRepo.save(debitorRel));
|
||||
final var debitorRel = mapper.map(body.getDebitorRel(), HsOfficeRelation.class);
|
||||
entityToSave.setDebitorRel(relBareRepo.save(debitorRel));
|
||||
} else {
|
||||
final var debitorRelOptional = relRepo.findByUuid(body.getDebitorRelUuid());
|
||||
final var debitorRelOptional = relBareRepo.findByUuid(body.getDebitorRelUuid());
|
||||
debitorRelOptional.ifPresentOrElse(
|
||||
debitorRel -> {entityToSave.setDebitorRel(relRepo.save(debitorRel));},
|
||||
debitorRel -> {entityToSave.setDebitorRel(relBareRepo.save(debitorRel));},
|
||||
() -> { throw new EntityNotFoundException("ERROR: [400] debitorRelUuid not found: " + body.getDebitorRelUuid());});
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,8 @@ import lombok.Setter;
|
||||
import net.hostsharing.hsadminng.errors.DisplayName;
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
||||
@ -66,7 +67,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
|
||||
private static Stringify<HsOfficeDebitorEntity> stringify =
|
||||
stringify(HsOfficeDebitorEntity.class, "debitor")
|
||||
.withIdProp(HsOfficeDebitorEntity::toShortString)
|
||||
.withProp(e -> ofNullable(e.getDebitorRel()).map(HsOfficeRelationEntity::toShortString).orElse(null))
|
||||
.withProp(e -> ofNullable(e.getDebitorRel()).map(HsOfficeRelation::toShortString).orElse(null))
|
||||
.withProp(HsOfficeDebitorEntity::getDefaultPrefix)
|
||||
.quotedValues(false);
|
||||
|
||||
@ -101,7 +102,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
|
||||
|
||||
@ManyToOne(cascade = { PERSIST, MERGE, REFRESH, DETACH }, optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "debitorreluuid", nullable = false)
|
||||
private HsOfficeRelationEntity debitorRel;
|
||||
private HsOfficeRelationBareEntity debitorRel;
|
||||
|
||||
@Column(name = "billable", nullable = false)
|
||||
private Boolean billable; // not a primitive because otherwise the default would be false
|
||||
@ -188,7 +189,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
|
||||
"defaultPrefix")
|
||||
.toRole("global", ADMIN).grantPermission(INSERT)
|
||||
|
||||
.importRootEntityAliasProxy("debitorRel", HsOfficeRelationEntity.class, usingCase(DEBITOR),
|
||||
.importRootEntityAliasProxy("debitorRel", HsOfficeRelation.class, usingCase(DEBITOR),
|
||||
directlyFetchedByDependsOnColumn(),
|
||||
dependsOnColumn("debitorRelUuid"))
|
||||
.createPermission(DELETE).grantedTo("debitorRel", OWNER)
|
||||
@ -202,7 +203,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
|
||||
.toRole("refundBankAccount", ADMIN).grantRole("debitorRel", AGENT)
|
||||
.toRole("debitorRel", AGENT).grantRole("refundBankAccount", REFERRER)
|
||||
|
||||
.importEntityAlias("partnerRel", HsOfficeRelationEntity.class, usingDefaultCase(),
|
||||
.importEntityAlias("partnerRel", HsOfficeRelation.class, usingDefaultCase(),
|
||||
dependsOnColumn("debitorRelUuid"),
|
||||
fetchedBySql("""
|
||||
SELECT ${columns}
|
||||
|
@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.debitor;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
||||
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
||||
|
||||
@ -25,7 +25,7 @@ class HsOfficeDebitorEntityPatcher implements EntityPatcher<HsOfficeDebitorPatch
|
||||
public void apply(final HsOfficeDebitorPatchResource resource) {
|
||||
OptionalFromJson.of(resource.getDebitorRelUuid()).ifPresent(newValue -> {
|
||||
verifyNotNull(newValue, "debitorRel");
|
||||
entity.setDebitorRel(em.getReference(HsOfficeRelationEntity.class, newValue));
|
||||
entity.setDebitorRel(em.getReference(HsOfficeRelationBareEntity.class, newValue));
|
||||
});
|
||||
Optional.ofNullable(resource.getBillable()).ifPresent(entity::setBillable);
|
||||
OptionalFromJson.of(resource.getVatId()).ifPresent(entity::setVatId);
|
||||
|
@ -8,7 +8,7 @@ import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import net.hostsharing.hsadminng.errors.DisplayName;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||
@ -165,7 +165,7 @@ public class HsOfficeMembershipEntity implements RbacObject<HsOfficeMembershipEn
|
||||
.withRestrictedViewOrderBy(SQL.projection("validity"))
|
||||
.withUpdatableColumns("validity", "membershipFeeBillable", "status")
|
||||
|
||||
.importEntityAlias("partnerRel", HsOfficeRelationEntity.class, usingDefaultCase(),
|
||||
.importEntityAlias("partnerRel", HsOfficeRelation.class, usingDefaultCase(),
|
||||
dependsOnColumn("partnerUuid"),
|
||||
fetchedBySql("""
|
||||
SELECT ${columns}
|
||||
|
@ -9,9 +9,9 @@ import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartne
|
||||
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.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.mapper.Mapper;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
@ -43,7 +43,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
||||
private HsOfficePartnerRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
private HsOfficeRelationRepository relationRepo;
|
||||
private HsOfficeRelationBareRepository relationRepo;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
@ -142,7 +142,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
||||
return ResponseEntity.ok(mapped);
|
||||
}
|
||||
|
||||
private void optionallyCreateExPartnerRelation(final HsOfficePartnerEntity saved, final HsOfficeRelationEntity previousPartnerRel) {
|
||||
private void optionallyCreateExPartnerRelation(final HsOfficePartnerEntity saved, final HsOfficeRelation previousPartnerRel) {
|
||||
if (!saved.getPartnerRel().getUuid().equals(previousPartnerRel.getUuid())) {
|
||||
relationRepo.save(previousPartnerRel.toBuilder().uuid(null).type(EX_PARTNER).build());
|
||||
}
|
||||
@ -156,8 +156,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
||||
return entityToSave;
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity persistPartnerRel(final HsOfficePartnerRelInsertResource resource) {
|
||||
final var entity = new HsOfficeRelationRbacEntity();
|
||||
private HsOfficeRelationBareEntity persistPartnerRel(final HsOfficePartnerRelInsertResource resource) {
|
||||
final var entity = new HsOfficeRelationBareEntity();
|
||||
entity.setType(HsOfficeRelationType.PARTNER);
|
||||
entity.setAnchor(ref(HsOfficePersonEntity.class, resource.getAnchorUuid()));
|
||||
entity.setHolder(ref(HsOfficePersonEntity.class, resource.getHolderUuid()));
|
||||
|
@ -8,8 +8,9 @@ import lombok.Setter;
|
||||
import net.hostsharing.hsadminng.errors.DisplayName;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContact;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
||||
import net.hostsharing.hsadminng.stringify.Stringify;
|
||||
@ -47,11 +48,11 @@ public class HsOfficePartnerEntity implements Stringifyable, RbacObject<HsOffice
|
||||
private static Stringify<HsOfficePartnerEntity> stringify = stringify(HsOfficePartnerEntity.class, "partner")
|
||||
.withIdProp(HsOfficePartnerEntity::toShortString)
|
||||
.withProp(p -> ofNullable(p.getPartnerRel())
|
||||
.map(HsOfficeRelationEntity::getHolder)
|
||||
.map(HsOfficeRelation::getHolder)
|
||||
.map(HsOfficePersonEntity::toShortString)
|
||||
.orElse(null))
|
||||
.withProp(p -> ofNullable(p.getPartnerRel())
|
||||
.map(HsOfficeRelationEntity::getContact)
|
||||
.map(HsOfficeRelation::getContact)
|
||||
.map(HsOfficeContact::toShortString)
|
||||
.orElse(null))
|
||||
.quotedValues(false);
|
||||
@ -68,7 +69,7 @@ public class HsOfficePartnerEntity implements Stringifyable, RbacObject<HsOffice
|
||||
|
||||
@ManyToOne(cascade = { PERSIST, MERGE, REFRESH, DETACH }, optional = false, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "partnerreluuid", nullable = false)
|
||||
private HsOfficeRelationEntity partnerRel;
|
||||
private HsOfficeRelationBareEntity partnerRel;
|
||||
|
||||
@ManyToOne(cascade = { PERSIST, MERGE, REFRESH, DETACH }, optional = true, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "detailsuuid")
|
||||
@ -103,7 +104,7 @@ public class HsOfficePartnerEntity implements Stringifyable, RbacObject<HsOffice
|
||||
.withUpdatableColumns("partnerRelUuid")
|
||||
.toRole("global", ADMIN).grantPermission(INSERT)
|
||||
|
||||
.importRootEntityAliasProxy("partnerRel", HsOfficeRelationEntity.class,
|
||||
.importRootEntityAliasProxy("partnerRel", HsOfficeRelation.class,
|
||||
usingDefaultCase(),
|
||||
directlyFetchedByDependsOnColumn(),
|
||||
dependsOnColumn("partnerRelUuid"))
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.mapper.EntityPatcher;
|
||||
import net.hostsharing.hsadminng.mapper.OptionalFromJson;
|
||||
|
||||
@ -21,7 +21,7 @@ class HsOfficePartnerEntityPatcher implements EntityPatcher<HsOfficePartnerPatch
|
||||
public void apply(final HsOfficePartnerPatchResource resource) {
|
||||
OptionalFromJson.of(resource.getPartnerRelUuid()).ifPresent(newValue -> {
|
||||
verifyNotNull(newValue, "partnerRel");
|
||||
entity.setPartnerRel(em.getReference(HsOfficeRelationEntity.class, newValue));
|
||||
entity.setPartnerRel(em.getReference(HsOfficeRelationBareEntity.class, newValue));
|
||||
});
|
||||
|
||||
new HsOfficePartnerDetailsEntityPatcher(em, entity.getDetails()).apply(resource.getDetails());
|
||||
|
@ -15,7 +15,7 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
|
||||
|
||||
@Query("""
|
||||
SELECT partner FROM HsOfficePartnerEntity partner
|
||||
JOIN HsOfficeRelationEntity rel ON rel.uuid = partner.partnerRel.uuid
|
||||
JOIN HsOfficeRelationBareEntity rel ON rel.uuid = partner.partnerRel.uuid
|
||||
JOIN HsOfficeContactBareEntity contact ON contact.uuid = rel.contact.uuid
|
||||
JOIN HsOfficePersonEntity person ON person.uuid = rel.holder.uuid
|
||||
WHERE :name is null
|
||||
|
@ -0,0 +1,83 @@
|
||||
package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
import net.hostsharing.hsadminng.stringify.Stringify;
|
||||
import net.hostsharing.hsadminng.stringify.Stringifyable;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import java.util.UUID;
|
||||
|
||||
import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
||||
|
||||
@MappedSuperclass
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@AllArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder(toBuilder = true)
|
||||
@FieldNameConstants
|
||||
public class HsOfficeRelation implements RbacObject<HsOfficeRelation>, Stringifyable {
|
||||
|
||||
private static Stringify<HsOfficeRelation> toString = stringify(HsOfficeRelation.class, "rel")
|
||||
.withProp(Fields.anchor, HsOfficeRelation::getAnchor)
|
||||
.withProp(Fields.type, HsOfficeRelation::getType)
|
||||
.withProp(Fields.mark, HsOfficeRelation::getMark)
|
||||
.withProp(Fields.holder, HsOfficeRelation::getHolder)
|
||||
.withProp(Fields.contact, HsOfficeRelation::getContact);
|
||||
|
||||
private static Stringify<HsOfficeRelation> toShortString = stringify(HsOfficeRelation.class, "rel")
|
||||
.withProp(Fields.anchor, HsOfficeRelation::getAnchor)
|
||||
.withProp(Fields.type, HsOfficeRelation::getType)
|
||||
.withProp(Fields.holder, HsOfficeRelation::getHolder);
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private UUID uuid;
|
||||
|
||||
@Version
|
||||
private int version;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "anchoruuid")
|
||||
private HsOfficePersonEntity anchor;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "holderuuid")
|
||||
private HsOfficePersonEntity holder;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "contactuuid")
|
||||
private HsOfficeContactBareEntity contact;
|
||||
|
||||
@Column(name = "type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private HsOfficeRelationType type;
|
||||
|
||||
@Column(name = "mark")
|
||||
private String mark;
|
||||
|
||||
@Override
|
||||
public HsOfficeRelation load() {
|
||||
RbacObject.super.load();
|
||||
anchor.load();
|
||||
holder.load();
|
||||
contact.load();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString.apply(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toShortString() {
|
||||
return toShortString.apply(this);
|
||||
}
|
||||
}
|
@ -11,14 +11,9 @@ import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "hs_office_relation")
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class HsOfficeRelationBareEntity extends HsOfficeRelationEntity {
|
||||
|
||||
@Override
|
||||
public HsOfficeRelationEntityBuilder<?, ?> toBuilder() {
|
||||
return null; // FIXME: also the ugly generics, if possible
|
||||
}
|
||||
@SuperBuilder(toBuilder = true)
|
||||
public class HsOfficeRelationBareEntity extends HsOfficeRelation {
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface HsOfficeRelationRepository extends Repository<HsOfficeRelationEntity, UUID> {
|
||||
public interface HsOfficeRelationBareRepository extends Repository<HsOfficeRelationBareEntity, UUID> {
|
||||
|
||||
Optional<HsOfficeRelationEntity> findByUuid(UUID id);
|
||||
Optional<HsOfficeRelationBareEntity> findByUuid(UUID id);
|
||||
|
||||
default List<HsOfficeRelationEntity> findRelationRelatedToPersonUuidAndRelationType(@NotNull UUID personUuid, HsOfficeRelationType relationType) {
|
||||
default List<HsOfficeRelationBareEntity> findRelationRelatedToPersonUuidAndRelationType(@NotNull UUID personUuid, HsOfficeRelationType relationType) {
|
||||
return findRelationRelatedToPersonUuidAndRelationTypeString(personUuid, relationType.toString());
|
||||
}
|
||||
|
||||
@ -20,16 +20,16 @@ public interface HsOfficeRelationRepository extends Repository<HsOfficeRelationE
|
||||
SELECT p.* FROM hs_office_relation_rv AS p
|
||||
WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid
|
||||
""", nativeQuery = true)
|
||||
List<HsOfficeRelationEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid);
|
||||
List<HsOfficeRelationBareEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid);
|
||||
|
||||
@Query(value = """
|
||||
SELECT p.* FROM hs_office_relation_rv AS p
|
||||
WHERE (:relationType IS NULL OR p.type = cast(:relationType AS HsOfficeRelationType))
|
||||
AND ( p.anchorUuid = :personUuid OR p.holderUuid = :personUuid)
|
||||
""", nativeQuery = true)
|
||||
List<HsOfficeRelationEntity> findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType);
|
||||
List<HsOfficeRelationBareEntity> findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType);
|
||||
|
||||
HsOfficeRelationEntity save(final HsOfficeRelationEntity entity);
|
||||
HsOfficeRelationBareEntity save(final HsOfficeRelation entity);
|
||||
|
||||
long count();
|
||||
|
@ -31,7 +31,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
|
||||
private Mapper mapper;
|
||||
|
||||
@Autowired
|
||||
private HsOfficeRelationRepository relationRepo;
|
||||
private HsOfficeRelationRbacRepository relationRbacRepo;
|
||||
|
||||
@Autowired
|
||||
private HsOfficePersonRepository holderRepo;
|
||||
@ -51,7 +51,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
|
||||
final HsOfficeRelationTypeResource relationType) {
|
||||
context.define(currentUser, assumedRoles);
|
||||
|
||||
final var entities = relationRepo.findRelationRelatedToPersonUuidAndRelationType(personUuid,
|
||||
final var entities = relationRbacRepo.findRelationRelatedToPersonUuidAndRelationType(personUuid,
|
||||
mapper.map(relationType, HsOfficeRelationType.class));
|
||||
|
||||
final var resources = mapper.mapList(entities, HsOfficeRelationResource.class,
|
||||
@ -81,7 +81,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
|
||||
() -> new NoSuchElementException("cannot find contactUuid " + body.getContactUuid())
|
||||
));
|
||||
|
||||
final var saved = relationRepo.save(entityToSave);
|
||||
final var saved = relationRbacRepo.save(entityToSave);
|
||||
|
||||
final var uri =
|
||||
MvcUriComponentsBuilder.fromController(getClass())
|
||||
@ -102,7 +102,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
|
||||
|
||||
context.define(currentUser, assumedRoles);
|
||||
|
||||
final var result = relationRepo.findByUuid(relationUuid);
|
||||
final var result = relationRbacRepo.findByUuid(relationUuid);
|
||||
if (result.isEmpty()) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
|
||||
final UUID relationUuid) {
|
||||
context.define(currentUser, assumedRoles);
|
||||
|
||||
final var result = relationRepo.deleteByUuid(relationUuid);
|
||||
final var result = relationRbacRepo.deleteByUuid(relationUuid);
|
||||
if (result == 0) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
@ -135,17 +135,17 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
|
||||
|
||||
context.define(currentUser, assumedRoles);
|
||||
|
||||
final var current = relationRepo.findByUuid(relationUuid).orElseThrow();
|
||||
final var current = relationRbacRepo.findByUuid(relationUuid).orElseThrow();
|
||||
|
||||
new HsOfficeRelationEntityPatcher(em, current).apply(body);
|
||||
|
||||
final var saved = relationRepo.save(current);
|
||||
final var saved = relationRbacRepo.save(current);
|
||||
final var mapped = mapper.map(saved, HsOfficeRelationResource.class);
|
||||
return ResponseEntity.ok(mapped);
|
||||
}
|
||||
|
||||
|
||||
final BiConsumer<HsOfficeRelationEntity, HsOfficeRelationResource> RELATION_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
|
||||
final BiConsumer<HsOfficeRelationRbacEntity, HsOfficeRelationResource> RELATION_ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
|
||||
resource.setAnchor(mapper.map(entity.getAnchor(), HsOfficePersonResource.class));
|
||||
resource.setHolder(mapper.map(entity.getHolder(), HsOfficePersonResource.class));
|
||||
resource.setContact(mapper.map(entity.getContact(), HsOfficeContactResource.class));
|
||||
|
@ -1,179 +0,0 @@
|
||||
package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
||||
import net.hostsharing.hsadminng.stringify.Stringify;
|
||||
import net.hostsharing.hsadminng.stringify.Stringifyable;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static jakarta.persistence.InheritanceType.TABLE_PER_CLASS;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.*;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.CaseDef.inCaseOf;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.CaseDef.inOtherCases;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Column.dependsOnColumn;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.ColumnValue.usingDefaultCase;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Nullable.NOT_NULL;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Permission.*;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.RbacUserReference.UserRole.CREATOR;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Role.*;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL.directlyFetchedByDependsOnColumn;
|
||||
import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = TABLE_PER_CLASS)
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@FieldNameConstants
|
||||
public abstract class HsOfficeRelationEntity implements RbacObject<HsOfficeRelationEntity>, Stringifyable {
|
||||
|
||||
private static Stringify<HsOfficeRelationEntity> toString = stringify(HsOfficeRelationEntity.class, "rel")
|
||||
.withProp(Fields.anchor, HsOfficeRelationEntity::getAnchor)
|
||||
.withProp(Fields.type, HsOfficeRelationEntity::getType)
|
||||
.withProp(Fields.mark, HsOfficeRelationEntity::getMark)
|
||||
.withProp(Fields.holder, HsOfficeRelationEntity::getHolder)
|
||||
.withProp(Fields.contact, HsOfficeRelationEntity::getContact);
|
||||
|
||||
private static Stringify<HsOfficeRelationEntity> toShortString = stringify(HsOfficeRelationEntity.class, "rel")
|
||||
.withProp(Fields.anchor, HsOfficeRelationEntity::getAnchor)
|
||||
.withProp(Fields.type, HsOfficeRelationEntity::getType)
|
||||
.withProp(Fields.holder, HsOfficeRelationEntity::getHolder);
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private UUID uuid;
|
||||
|
||||
@Version
|
||||
private int version;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "anchoruuid")
|
||||
private HsOfficePersonEntity anchor;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "holderuuid")
|
||||
private HsOfficePersonEntity holder;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "contactuuid")
|
||||
private HsOfficeContactBareEntity contact;
|
||||
|
||||
@Column(name = "type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private HsOfficeRelationType type;
|
||||
|
||||
@Column(name = "mark")
|
||||
private String mark;
|
||||
|
||||
@Override
|
||||
public HsOfficeRelationEntity load() {
|
||||
RbacObject.super.load();
|
||||
anchor.load();
|
||||
holder.load();
|
||||
contact.load();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString.apply(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toShortString() {
|
||||
return toShortString.apply(this);
|
||||
}
|
||||
|
||||
public abstract <T extends HsOfficeRelationEntity> HsOfficeRelationEntityBuilder<T, ?> toBuilder();
|
||||
|
||||
public static RbacView rbac() {
|
||||
return rbacViewFor("relation", HsOfficeRelationEntity.class)
|
||||
.withIdentityView(SQL.projection("""
|
||||
(select idName from hs_office_person_iv p where p.uuid = anchorUuid)
|
||||
|| '-with-' || target.type || '-'
|
||||
|| (select idName from hs_office_person_iv p where p.uuid = holderUuid)
|
||||
"""))
|
||||
.withRestrictedViewOrderBy(SQL.expression(
|
||||
"(select idName from hs_office_person_iv p where p.uuid = target.holderUuid)"))
|
||||
.withUpdatableColumns("contactUuid")
|
||||
.importEntityAlias("anchorPerson", HsOfficePersonEntity.class, usingDefaultCase(),
|
||||
dependsOnColumn("anchorUuid"),
|
||||
directlyFetchedByDependsOnColumn(),
|
||||
NOT_NULL)
|
||||
.importEntityAlias("holderPerson", HsOfficePersonEntity.class, usingDefaultCase(),
|
||||
dependsOnColumn("holderUuid"),
|
||||
directlyFetchedByDependsOnColumn(),
|
||||
NOT_NULL)
|
||||
.importEntityAlias("contact", HsOfficeContactRbacEntity.class, usingDefaultCase(),
|
||||
dependsOnColumn("contactUuid"),
|
||||
directlyFetchedByDependsOnColumn(),
|
||||
NOT_NULL)
|
||||
.switchOnColumn("type",
|
||||
inCaseOf("REPRESENTATIVE", then -> {
|
||||
then.createRole(OWNER, (with) -> {
|
||||
with.owningUser(CREATOR);
|
||||
with.incomingSuperRole(GLOBAL, ADMIN);
|
||||
with.incomingSuperRole("holderPerson", ADMIN);
|
||||
with.permission(DELETE);
|
||||
})
|
||||
.createSubRole(ADMIN, (with) -> {
|
||||
with.outgoingSubRole("anchorPerson", OWNER);
|
||||
with.permission(UPDATE);
|
||||
})
|
||||
.createSubRole(AGENT, (with) -> {
|
||||
with.incomingSuperRole("anchorPerson", ADMIN);
|
||||
})
|
||||
.createSubRole(TENANT, (with) -> {
|
||||
with.incomingSuperRole("contact", ADMIN);
|
||||
with.outgoingSubRole("anchorPerson", REFERRER);
|
||||
with.outgoingSubRole("holderPerson", REFERRER);
|
||||
with.outgoingSubRole("contact", REFERRER);
|
||||
with.permission(SELECT);
|
||||
});
|
||||
}),
|
||||
// inCaseOf("DEBITOR", then -> {}), TODO.spec: needs to be defined
|
||||
inOtherCases(then -> {
|
||||
then.createRole(OWNER, (with) -> {
|
||||
with.owningUser(CREATOR);
|
||||
with.incomingSuperRole(GLOBAL, ADMIN);
|
||||
with.incomingSuperRole("anchorPerson", ADMIN);
|
||||
with.permission(DELETE);
|
||||
})
|
||||
.createSubRole(ADMIN, (with) -> {
|
||||
with.permission(UPDATE);
|
||||
})
|
||||
.createSubRole(AGENT, (with) -> {
|
||||
// TODO.rbac: we need relation:PROXY, to allow changing the relation contact.
|
||||
// the alternative would be to move this to the relation:ADMIN role,
|
||||
// but then the partner holder person could update the partner relation itself,
|
||||
// see partner entity.
|
||||
with.incomingSuperRole("holderPerson", ADMIN);
|
||||
})
|
||||
.createSubRole(TENANT, (with) -> {
|
||||
with.incomingSuperRole("contact", ADMIN);
|
||||
with.outgoingSubRole("anchorPerson", REFERRER);
|
||||
with.outgoingSubRole("holderPerson", REFERRER);
|
||||
with.outgoingSubRole("contact", REFERRER);
|
||||
with.permission(SELECT);
|
||||
});
|
||||
}))
|
||||
.toRole("anchorPerson", ADMIN).grantPermission(INSERT);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
rbac().generateWithBaseFileName("5-hs-office/503-relation/5033-hs-office-relation-rbac");
|
||||
}
|
||||
}
|
@ -11,9 +11,9 @@ import java.util.UUID;
|
||||
class HsOfficeRelationEntityPatcher implements EntityPatcher<HsOfficeRelationPatchResource> {
|
||||
|
||||
private final EntityManager em;
|
||||
private final HsOfficeRelationEntity entity;
|
||||
private final HsOfficeRelation entity;
|
||||
|
||||
HsOfficeRelationEntityPatcher(final EntityManager em, final HsOfficeRelationEntity entity) {
|
||||
HsOfficeRelationEntityPatcher(final EntityManager em, final HsOfficeRelation entity) {
|
||||
this.em = em;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
@ -34,16 +34,11 @@ import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.rbacViewFor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "hs_office_relation_rv")
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class HsOfficeRelationRbacEntity extends HsOfficeRelationEntity {
|
||||
|
||||
@Override
|
||||
public HsOfficeRelationRbacEntityBuilder<HsOfficeRelationRbacEntity, ?> toBuilder() {
|
||||
return null;
|
||||
}
|
||||
@SuperBuilder(toBuilder = true)
|
||||
public class HsOfficeRelationRbacEntity extends HsOfficeRelation {
|
||||
|
||||
public static RbacView rbac() {
|
||||
return rbacViewFor("relation", HsOfficeRelationRbacEntity.class)
|
||||
|
@ -0,0 +1,37 @@
|
||||
package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface HsOfficeRelationRbacRepository extends Repository<HsOfficeRelationRbacEntity, UUID> {
|
||||
|
||||
Optional<HsOfficeRelationRbacEntity> findByUuid(UUID id);
|
||||
|
||||
default List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidAndRelationType(@NotNull UUID personUuid, HsOfficeRelationType relationType) {
|
||||
return findRelationRelatedToPersonUuidAndRelationTypeString(personUuid, relationType.toString());
|
||||
}
|
||||
|
||||
@Query(value = """
|
||||
SELECT p.* FROM hs_office_relation_rv AS p
|
||||
WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid
|
||||
""", nativeQuery = true)
|
||||
List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid);
|
||||
|
||||
@Query(value = """
|
||||
SELECT p.* FROM hs_office_relation_rv AS p
|
||||
WHERE (:relationType IS NULL OR p.type = cast(:relationType AS HsOfficeRelationType))
|
||||
AND ( p.anchorUuid = :personUuid OR p.holderUuid = :personUuid)
|
||||
""", nativeQuery = true)
|
||||
List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType);
|
||||
|
||||
HsOfficeRelationRbacEntity save(final HsOfficeRelationRbacEntity entity);
|
||||
|
||||
long count();
|
||||
|
||||
int deleteByUuid(UUID uuid);
|
||||
}
|
@ -6,7 +6,7 @@ import lombok.*;
|
||||
import net.hostsharing.hsadminng.errors.DisplayName;
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||
import net.hostsharing.hsadminng.stringify.Stringify;
|
||||
@ -110,7 +110,7 @@ public class HsOfficeSepaMandateEntity implements Stringifyable, RbacObject<HsOf
|
||||
.withRestrictedViewOrderBy(expression("validity"))
|
||||
.withUpdatableColumns("reference", "agreement", "validity")
|
||||
|
||||
.importEntityAlias("debitorRel", HsOfficeRelationEntity.class, usingCase(DEBITOR),
|
||||
.importEntityAlias("debitorRel", HsOfficeRelation.class, usingCase(DEBITOR),
|
||||
dependsOnColumn("debitorUuid"),
|
||||
fetchedBySql("""
|
||||
SELECT ${columns}
|
||||
|
@ -14,7 +14,7 @@ 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.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.hs.office.sepamandate.HsOfficeSepaMandateEntity;
|
||||
@ -127,7 +127,7 @@ public class ImportOfficeData extends CsvDataImport {
|
||||
static Map<Integer, HsOfficeDebitorEntity> debitors = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeMembershipEntity> memberships = new WriteOnceMap<>();
|
||||
|
||||
static Map<Integer, HsOfficeRelationEntity> relations = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeRelation> relations = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeSepaMandateEntity> sepaMandates = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeBankAccountEntity> bankAccounts = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeCoopSharesTransactionEntity> coopShares = new WriteOnceMap<>();
|
||||
@ -1053,7 +1053,7 @@ public class ImportOfficeData extends CsvDataImport {
|
||||
return containsRole(rec, "partner");
|
||||
}
|
||||
|
||||
private static HsOfficeRelationEntity addRelation(
|
||||
private static HsOfficeRelationBareEntity addRelation(
|
||||
final HsOfficeRelationType type,
|
||||
final HsOfficePersonEntity anchor,
|
||||
final HsOfficePersonEntity holder,
|
||||
|
@ -8,8 +8,9 @@ import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountReposi
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
import org.json.JSONException;
|
||||
@ -64,7 +65,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
HsOfficePersonRepository personRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationRepository relRepo;
|
||||
HsOfficeRelationBareRepository relRepo;
|
||||
|
||||
@Autowired
|
||||
JpaAttempt jpaAttempt;
|
||||
@ -726,7 +727,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
.debitorNumberSuffix(nextDebitorSuffix())
|
||||
.billable(true)
|
||||
.debitorRel(
|
||||
HsOfficeRelationRbacEntity.builder()
|
||||
HsOfficeRelationBareEntity.builder()
|
||||
.type(DEBITOR)
|
||||
.anchor(givenPartner.getPartnerRel().getHolder())
|
||||
.holder(givenPartner.getPartnerRel().getHolder())
|
||||
|
@ -2,8 +2,7 @@ package net.hostsharing.hsadminng.hs.office.debitor;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
@ -22,10 +21,7 @@ import static org.mockito.Mockito.lenient;
|
||||
|
||||
@TestInstance(PER_CLASS)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
HsOfficeDebitorPatchResource,
|
||||
HsOfficeDebitorEntity
|
||||
> {
|
||||
class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<HsOfficeDebitorPatchResource, HsOfficeDebitorEntity> {
|
||||
|
||||
private static final UUID INITIAL_DEBITOR_UUID = UUID.randomUUID();
|
||||
private static final UUID INITIAL_DEBITOR_REL_UUID = UUID.randomUUID();
|
||||
@ -45,20 +41,21 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
private static final UUID INITIAL_REFUND_BANK_ACCOUNT_UUID = UUID.randomUUID();
|
||||
private static final UUID PATCHED_REFUND_BANK_ACCOUNT_UUID = UUID.randomUUID();
|
||||
|
||||
private final HsOfficeRelationEntity givenInitialDebitorRel = HsOfficeRelationRbacEntity.builder()
|
||||
private final HsOfficeRelationBareEntity givenInitialDebitorRel = HsOfficeRelationBareEntity.builder()
|
||||
.uuid(INITIAL_DEBITOR_REL_UUID)
|
||||
.build();
|
||||
|
||||
private final HsOfficeBankAccountEntity givenInitialBankAccount = HsOfficeBankAccountEntity.builder()
|
||||
.uuid(INITIAL_REFUND_BANK_ACCOUNT_UUID)
|
||||
.build();
|
||||
|
||||
@Mock
|
||||
private EntityManager em;
|
||||
|
||||
@BeforeEach
|
||||
void initMocks() {
|
||||
lenient().when(em.getReference(eq(HsOfficeRelationEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeRelationRbacEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficeRelationBareEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeRelationBareEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficeBankAccountEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeBankAccountEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
}
|
||||
@ -142,8 +139,8 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
);
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity newDebitorRel(final UUID uuid) {
|
||||
return HsOfficeRelationRbacEntity.builder()
|
||||
private HsOfficeRelationBareEntity newDebitorRel(final UUID uuid) {
|
||||
return HsOfficeRelationBareEntity.builder()
|
||||
.uuid(uuid)
|
||||
.build();
|
||||
}
|
||||
|
@ -4,15 +4,14 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class HsOfficeDebitorEntityUnitTest {
|
||||
|
||||
private HsOfficeRelationEntity givenDebitorRel = HsOfficeRelationRbacEntity.builder()
|
||||
private HsOfficeRelationBareEntity givenDebitorRel = HsOfficeRelationBareEntity.builder()
|
||||
.anchor(HsOfficePersonEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("some partner trade name")
|
||||
|
@ -5,8 +5,9 @@ import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountReposi
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
||||
@ -92,7 +93,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.partner(givenPartner)
|
||||
.debitorNumberSuffix("21")
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.debitorRel(HsOfficeRelationBareEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenPartnerPerson)
|
||||
.holder(givenPartnerPerson)
|
||||
@ -125,7 +126,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var result = attempt(em, () -> {
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix("21")
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.debitorRel(HsOfficeRelationBareEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenPartnerPerson)
|
||||
.holder(givenPartnerPerson)
|
||||
@ -160,7 +161,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var givenContact = one(contactBareRepo.findContactByOptionalCaptionLike("fourth contact"));
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix("22")
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.debitorRel(HsOfficeRelationBareEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenPartnerPerson)
|
||||
.holder(givenDebitorPerson)
|
||||
@ -332,7 +333,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
givenDebitor.setDebitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
givenDebitor.setDebitorRel(HsOfficeRelationBareEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenNewPartnerPerson)
|
||||
.holder(givenNewBillingPerson)
|
||||
@ -489,7 +490,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
if (withPartner) {
|
||||
assertThat(foundEntity.getPartner()).isNotNull();
|
||||
}
|
||||
assertThat(foundEntity.getDebitorRel()).extracting(HsOfficeRelationEntity::toString)
|
||||
assertThat(foundEntity.getDebitorRel()).extracting(HsOfficeRelation::toString)
|
||||
.isEqualTo(saved.getDebitorRel().toString());
|
||||
});
|
||||
}
|
||||
@ -617,7 +618,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.partner(givenPartner)
|
||||
.debitorNumberSuffix("20")
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.debitorRel(HsOfficeRelationBareEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenPartnerPerson)
|
||||
.holder(givenPartnerPerson)
|
||||
|
@ -2,7 +2,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.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareTestEntity.TEST_BARE_CONTACT;
|
||||
import static net.hostsharing.hsadminng.hs.office.partner.TestHsOfficePartner.TEST_PARTNER;
|
||||
@ -14,7 +14,7 @@ public class TestHsOfficeDebitor {
|
||||
|
||||
public static final HsOfficeDebitorEntity TEST_DEBITOR = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix(DEFAULT_DEBITOR_SUFFIX)
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.debitorRel(HsOfficeRelationBareEntity.builder()
|
||||
.holder(HsOfficePersonEntity.builder().build())
|
||||
.anchor(HsOfficePersonEntity.builder().build())
|
||||
.contact(TEST_BARE_CONTACT)
|
||||
|
@ -3,13 +3,13 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.http.ContentType;
|
||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
@ -42,7 +42,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationRepository relationRepo;
|
||||
HsOfficeRelationBareRepository relationRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
@ -180,7 +180,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
.post("http://localhost/api/hs/office/partners")
|
||||
.then().log().all().assertThat()
|
||||
.statusCode(400)
|
||||
.body("message", is("Unable to find " + HsOfficeContactRbacEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID));
|
||||
.body("message", is("Unable to find " + HsOfficeContactBareEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID));
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
// and an ex-partner-relation got created
|
||||
final var anchorpartnerPersonUUid = givenPartner.getPartnerRel().getAnchor().getUuid();
|
||||
assertThat(relationRepo.findRelationRelatedToPersonUuidAndRelationType(anchorpartnerPersonUUid, EX_PARTNER))
|
||||
.map(HsOfficeRelationEntity::toShortString)
|
||||
.map(HsOfficeRelation::toShortString)
|
||||
.contains("rel(anchor='LP Hostsharing eG', type='EX_PARTNER', holder='UF Erben Bessler')");
|
||||
}
|
||||
|
||||
@ -517,7 +517,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
}
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity givenSomeTemporaryPartnerRel(
|
||||
private HsOfficeRelationBareEntity givenSomeTemporaryPartnerRel(
|
||||
final String partnerHolderName,
|
||||
final String contactName) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
@ -526,7 +526,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow();
|
||||
final var givenContact = contactBareRepo.findContactByOptionalCaptionLike(contactName).stream().findFirst().orElseThrow();
|
||||
|
||||
final var partnerRel = new HsOfficeRelationRbacEntity();
|
||||
final var partnerRel = new HsOfficeRelationBareEntity();
|
||||
partnerRel.setType(HsOfficeRelationType.PARTNER);
|
||||
partnerRel.setAnchor(givenMandantPerson);
|
||||
partnerRel.setHolder(givenPerson);
|
||||
@ -558,6 +558,6 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
cleanupAllNew(HsOfficePartnerEntity.class);
|
||||
|
||||
// TODO: should not be necessary anymore, once it's deleted via after delete trigger
|
||||
cleanupAllNew(HsOfficeRelationEntity.class);
|
||||
cleanupAllNew(HsOfficeRelationBareEntity.class);
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ 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.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareRepository;
|
||||
import net.hostsharing.hsadminng.mapper.Mapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
@ -54,7 +54,7 @@ class HsOfficePartnerControllerRestTest {
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
|
||||
@MockBean
|
||||
HsOfficeRelationRepository relationRepo;
|
||||
HsOfficeRelationBareRepository relationRepo;
|
||||
|
||||
@MockBean
|
||||
EntityManager em;
|
||||
@ -176,7 +176,7 @@ class HsOfficePartnerControllerRestTest {
|
||||
when(partnerRepo.deleteByUuid(givenPartnerUuid)).thenReturn(0);
|
||||
|
||||
final UUID givenRelationUuid = UUID.randomUUID();
|
||||
when(partnerMock.getPartnerRel()).thenReturn(HsOfficeRelationRbacEntity.builder()
|
||||
when(partnerMock.getPartnerRel()).thenReturn(HsOfficeRelationBareEntity.builder()
|
||||
.uuid(givenRelationUuid)
|
||||
.build());
|
||||
when(relationRepo.deleteByUuid(givenRelationUuid)).thenReturn(0);
|
||||
|
@ -3,8 +3,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareEntity;
|
||||
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.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
@ -49,8 +48,8 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
|
||||
@BeforeEach
|
||||
void initMocks() {
|
||||
lenient().when(em.getReference(eq(HsOfficeRelationEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeRelationRbacEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficeRelationBareEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeRelationBareEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,7 +57,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
final var entity = HsOfficePartnerEntity.builder()
|
||||
.uuid(INITIAL_PARTNER_UUID)
|
||||
.partnerNumber(12345)
|
||||
.partnerRel(HsOfficeRelationRbacEntity.builder()
|
||||
.partnerRel(HsOfficeRelationBareEntity.builder()
|
||||
.holder(givenInitialPerson)
|
||||
.contact(givenInitialContact)
|
||||
.build())
|
||||
@ -90,10 +89,9 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
);
|
||||
}
|
||||
|
||||
private static HsOfficeRelationEntity newPartnerRel(final UUID uuid) {
|
||||
final var newPartnerRel = HsOfficeRelationRbacEntity.builder()
|
||||
private static HsOfficeRelationBareEntity newPartnerRel(final UUID uuid) {
|
||||
return HsOfficeRelationBareEntity.builder()
|
||||
.uuid(uuid)
|
||||
.build();
|
||||
return newPartnerRel;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -13,7 +13,7 @@ class HsOfficePartnerEntityUnitTest {
|
||||
|
||||
private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.partnerRel(HsOfficeRelationRbacEntity.builder()
|
||||
.partnerRel(HsOfficeRelationBareEntity.builder()
|
||||
.anchor(HsOfficePersonEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("Hostsharing eG")
|
||||
|
@ -3,9 +3,8 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareRepository;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
||||
@ -43,7 +42,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
HsOfficePartnerRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationRepository relationRepo;
|
||||
HsOfficeRelationBareRepository relationRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
@ -113,7 +112,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var givenContact = contactBareRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
|
||||
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||
|
||||
final var newRelation = HsOfficeRelationRbacEntity.builder()
|
||||
final var newRelation = HsOfficeRelationBareEntity.builder()
|
||||
.holder(givenPartnerPerson)
|
||||
.type(HsOfficeRelationType.PARTNER)
|
||||
.anchor(givenMandantPerson)
|
||||
@ -463,12 +462,12 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
}).assertSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity givenSomeTemporaryHostsharingPartnerRel(final String person, final String contact) {
|
||||
private HsOfficeRelationBareEntity givenSomeTemporaryHostsharingPartnerRel(final String person, final String contact) {
|
||||
final var givenMandantorPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||
final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike(person).get(0);
|
||||
final var givenContact = contactBareRepo.findContactByOptionalCaptionLike(contact).get(0);
|
||||
|
||||
final var partnerRel = HsOfficeRelationRbacEntity.builder()
|
||||
final var partnerRel = HsOfficeRelationBareEntity.builder()
|
||||
.holder(givenPartnerPerson)
|
||||
.type(HsOfficeRelationType.PARTNER)
|
||||
.anchor(givenMandantorPerson)
|
||||
|
@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGAL_PERSON;
|
||||
@ -15,7 +15,7 @@ public class TestHsOfficePartner {
|
||||
return HsOfficePartnerEntity.builder()
|
||||
.partnerNumber(10001)
|
||||
.partnerRel(
|
||||
HsOfficeRelationRbacEntity.builder()
|
||||
HsOfficeRelationBareEntity.builder()
|
||||
.holder(HsOfficePersonEntity.builder()
|
||||
.personType(LEGAL_PERSON)
|
||||
.tradeName("Hostsharing eG")
|
||||
|
@ -43,7 +43,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
Context contextMock;
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationRepository relationRepo;
|
||||
HsOfficeRelationBareRepository relationBareRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
@ -161,7 +161,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
.extract().header("Location"); // @formatter:on
|
||||
|
||||
// finally, the new relation can be accessed under the generated UUID
|
||||
final var newUserUuid = toCleanup(HsOfficeRelationEntity.class, UUID.fromString(
|
||||
final var newUserUuid = toCleanup(HsOfficeRelation.class, UUID.fromString(
|
||||
location.substring(location.lastIndexOf('/') + 1)));
|
||||
assertThat(newUserUuid).isNotNull();
|
||||
}
|
||||
@ -331,12 +331,12 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
}
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity findRelation(
|
||||
private HsOfficeRelation findRelation(
|
||||
final String anchorPersonName,
|
||||
final String holderPersoneName) {
|
||||
final var anchorPersonUuid = personRepo.findPersonByOptionalNameLike(anchorPersonName).get(0).getUuid();
|
||||
final var holderPersonUuid = personRepo.findPersonByOptionalNameLike(holderPersoneName).get(0).getUuid();
|
||||
final var givenRelation = relationRepo
|
||||
final var givenRelation = relationBareRepo
|
||||
.findRelationRelatedToPersonUuid(anchorPersonUuid)
|
||||
.stream()
|
||||
.filter(r -> r.getHolder().getUuid().equals(holderPersonUuid))
|
||||
@ -379,7 +379,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
|
||||
// finally, the relation is actually updated
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isPresent().get()
|
||||
assertThat(relationBareRepo.findByUuid(givenRelation.getUuid())).isPresent().get()
|
||||
.matches(rel -> {
|
||||
assertThat(rel.getAnchor().getTradeName()).contains("Bessler");
|
||||
assertThat(rel.getHolder().getFamilyName()).contains("Winkler");
|
||||
@ -408,7 +408,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
.statusCode(204); // @formatter:on
|
||||
|
||||
// then the given relation is gone
|
||||
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isEmpty();
|
||||
assertThat(relationBareRepo.findByUuid(givenRelation.getUuid())).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -427,7 +427,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
.statusCode(403); // @formatter:on
|
||||
|
||||
// then the given relation is still there
|
||||
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isNotEmpty();
|
||||
assertThat(relationBareRepo.findByUuid(givenRelation.getUuid())).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -446,24 +446,24 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
.statusCode(404); // @formatter:on
|
||||
|
||||
// then the given relation is still there
|
||||
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isNotEmpty();
|
||||
assertThat(relationBareRepo.findByUuid(givenRelation.getUuid())).isNotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity givenSomeTemporaryRelationBessler() {
|
||||
private HsOfficeRelation givenSomeTemporaryRelationBessler() {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Winkler").get(0);
|
||||
final var givenContact = contactBareRepo.findContactByOptionalCaptionLike("seventh contact").get(0);
|
||||
final var newRelation = HsOfficeRelationRbacEntity.builder()
|
||||
final var newRelation = HsOfficeRelationBareEntity.builder()
|
||||
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||
.anchor(givenAnchorPerson)
|
||||
.holder(givenHolderPerson)
|
||||
.contact(givenContact)
|
||||
.build();
|
||||
|
||||
assertThat(toCleanup(relationRepo.save(newRelation))).isEqualTo(newRelation);
|
||||
assertThat(toCleanup(relationBareRepo.save(newRelation))).isEqualTo(newRelation);
|
||||
|
||||
return newRelation;
|
||||
}).assertSuccessful().returnedValue();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactBareEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationPatchResource;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase;
|
||||
@ -22,9 +21,9 @@ import static org.mockito.Mockito.lenient;
|
||||
|
||||
@TestInstance(PER_CLASS)
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class HsOfficeRelationEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
class HsOfficeRelationPatcherUnitTest extends PatchUnitTestBase<
|
||||
HsOfficeRelationPatchResource,
|
||||
HsOfficeRelationEntity
|
||||
HsOfficeRelation
|
||||
> {
|
||||
|
||||
static final UUID INITIAL_RELATION_UUID = UUID.randomUUID();
|
||||
@ -35,8 +34,8 @@ class HsOfficeRelationEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
|
||||
@BeforeEach
|
||||
void initMocks() {
|
||||
lenient().when(em.getReference(eq(HsOfficeContactRbacEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeContactRbacEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficeContactBareEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeContactBareEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
}
|
||||
|
||||
final HsOfficePersonEntity givenInitialAnchorPerson = HsOfficePersonEntity.builder()
|
||||
@ -50,7 +49,7 @@ class HsOfficeRelationEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
.build();
|
||||
|
||||
@Override
|
||||
protected HsOfficeRelationEntity newInitialEntity() {
|
||||
protected HsOfficeRelation newInitialEntity() {
|
||||
final var entity = new HsOfficeRelationRbacEntity();
|
||||
entity.setUuid(INITIAL_RELATION_UUID);
|
||||
entity.setType(HsOfficeRelationType.REPRESENTATIVE);
|
||||
@ -66,7 +65,7 @@ class HsOfficeRelationEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HsOfficeRelationEntityPatcher createPatcher(final HsOfficeRelationEntity relation) {
|
||||
protected HsOfficeRelationEntityPatcher createPatcher(final HsOfficeRelation relation) {
|
||||
return new HsOfficeRelationEntityPatcher(em, relation);
|
||||
}
|
||||
|
||||
@ -77,7 +76,7 @@ class HsOfficeRelationEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
"contact",
|
||||
HsOfficeRelationPatchResource::setContactUuid,
|
||||
PATCHED_CONTACT_UUID,
|
||||
HsOfficeRelationEntity::setContact,
|
||||
HsOfficeRelation::setContact,
|
||||
newContact(PATCHED_CONTACT_UUID))
|
||||
.notNullable()
|
||||
);
|
@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithCleanup {
|
||||
|
||||
@Autowired
|
||||
HsOfficeRelationRepository relationRepo;
|
||||
HsOfficeRelationRbacRepository relationRbacRepo;
|
||||
|
||||
@Autowired
|
||||
HsOfficePersonRepository personRepo;
|
||||
@ -64,7 +64,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
public void testHostsharingAdmin_withoutAssumedRole_canCreateNewRelation() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var count = relationRepo.count();
|
||||
final var count = relationRbacRepo.count();
|
||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Bessler").stream()
|
||||
.filter(p -> p.getPersonType() == UNINCORPORATED_FIRM)
|
||||
.findFirst().orElseThrow();
|
||||
@ -83,16 +83,16 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
.mark("operations-announce")
|
||||
.contact(givenContact)
|
||||
.build();
|
||||
return toCleanup(relationRepo.save(newRelation));
|
||||
return toCleanup(relationRbacRepo.save(newRelation));
|
||||
});
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeRelationEntity::getUuid).isNotNull();
|
||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeRelation::getUuid).isNotNull();
|
||||
assertThatRelationIsPersisted(result.returnedValue());
|
||||
assertThat(relationRepo.count()).isEqualTo(count + 1);
|
||||
final var stored = relationRepo.findByUuid(result.returnedValue().getUuid());
|
||||
assertThat(stored).isNotEmpty().map(HsOfficeRelationEntity::toString).get()
|
||||
assertThat(relationRbacRepo.count()).isEqualTo(count + 1);
|
||||
final var stored = relationRbacRepo.findByUuid(result.returnedValue().getUuid());
|
||||
assertThat(stored).isNotEmpty().map(HsOfficeRelation::toString).get()
|
||||
.isEqualTo("rel(anchor='UF Erben Bessler', type='SUBSCRIBER', mark='operations-announce', holder='NP Winkler, Paul', contact='fourth contact')");
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||
.contact(givenContact)
|
||||
.build();
|
||||
return toCleanup(relationRepo.save(newRelation));
|
||||
return toCleanup(relationRbacRepo.save(newRelation));
|
||||
});
|
||||
|
||||
// then
|
||||
@ -156,8 +156,8 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
);
|
||||
}
|
||||
|
||||
private void assertThatRelationIsPersisted(final HsOfficeRelationEntity saved) {
|
||||
final var found = relationRepo.findByUuid(saved.getUuid());
|
||||
private void assertThatRelationIsPersisted(final HsOfficeRelation saved) {
|
||||
final var found = relationRbacRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString());
|
||||
}
|
||||
}
|
||||
@ -174,7 +174,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
.findFirst().orElseThrow();
|
||||
|
||||
// when
|
||||
final var result = relationRepo.findRelationRelatedToPersonUuid(person.getUuid());
|
||||
final var result = relationRbacRepo.findRelationRelatedToPersonUuid(person.getUuid());
|
||||
|
||||
// then
|
||||
allTheseRelationsAreReturned(
|
||||
@ -193,7 +193,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
.findFirst().orElseThrow();
|
||||
|
||||
// when:
|
||||
final var result = relationRepo.findRelationRelatedToPersonUuid(person.getUuid());
|
||||
final var result = relationRbacRepo.findRelationRelatedToPersonUuid(person.getUuid());
|
||||
|
||||
// then:
|
||||
exactlyTheseRelationsAreReturned(
|
||||
@ -225,7 +225,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
givenRelation.setContact(givenContact);
|
||||
return toCleanup(relationRepo.save(givenRelation).load());
|
||||
return toCleanup(relationRbacRepo.save(givenRelation).load());
|
||||
});
|
||||
|
||||
// then
|
||||
@ -242,7 +242,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
result.returnedValue(),
|
||||
"hs_office_contact#fifthcontact:ADMIN");
|
||||
|
||||
relationRepo.deleteByUuid(givenRelation.getUuid());
|
||||
relationRbacRepo.deleteByUuid(givenRelation.getUuid());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -260,7 +260,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", "hs_office_relation#ErbenBesslerMelBessler-with-REPRESENTATIVE-BesslerAnita:AGENT");
|
||||
givenRelation.setContact(null);
|
||||
return relationRepo.save(givenRelation);
|
||||
return relationRbacRepo.save(givenRelation);
|
||||
});
|
||||
|
||||
// then
|
||||
@ -283,7 +283,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", "hs_office_contact#ninthcontact:ADMIN");
|
||||
givenRelation.setContact(null); // TODO
|
||||
return relationRepo.save(givenRelation);
|
||||
return relationRbacRepo.save(givenRelation);
|
||||
});
|
||||
|
||||
// then
|
||||
@ -291,16 +291,16 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
"[403] Subject ", " is not allowed to update hs_office_relation uuid");
|
||||
}
|
||||
|
||||
private void assertThatRelationActuallyInDatabase(final HsOfficeRelationEntity saved) {
|
||||
final var found = relationRepo.findByUuid(saved.getUuid());
|
||||
private void assertThatRelationActuallyInDatabase(final HsOfficeRelation saved) {
|
||||
final var found = relationRbacRepo.findByUuid(saved.getUuid());
|
||||
assertThat(found).isNotEmpty().get()
|
||||
.isNotSameAs(saved)
|
||||
.extracting(HsOfficeRelationEntity::toString)
|
||||
.extracting(HsOfficeRelation::toString)
|
||||
.isEqualTo(saved.toString());
|
||||
}
|
||||
|
||||
private void assertThatRelationIsVisibleForUserWithRole(
|
||||
final HsOfficeRelationEntity entity,
|
||||
final HsOfficeRelation entity,
|
||||
final String assumedRoles) {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", assumedRoles);
|
||||
@ -309,11 +309,11 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
}
|
||||
|
||||
private void assertThatRelationIsNotVisibleForUserWithRole(
|
||||
final HsOfficeRelationEntity entity,
|
||||
final HsOfficeRelation entity,
|
||||
final String assumedRoles) {
|
||||
jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net", assumedRoles);
|
||||
final var found = relationRepo.findByUuid(entity.getUuid());
|
||||
final var found = relationRbacRepo.findByUuid(entity.getUuid());
|
||||
assertThat(found).isEmpty();
|
||||
}).assertSuccessful();
|
||||
}
|
||||
@ -332,14 +332,14 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
relationRepo.deleteByUuid(givenRelation.getUuid());
|
||||
relationRbacRepo.deleteByUuid(givenRelation.getUuid());
|
||||
});
|
||||
|
||||
// then
|
||||
result.assertSuccessful();
|
||||
assertThat(jpaAttempt.transacted(() -> {
|
||||
context("superuser-fran@hostsharing.net", null);
|
||||
return relationRepo.findByUuid(givenRelation.getUuid());
|
||||
return relationRbacRepo.findByUuid(givenRelation.getUuid());
|
||||
}).assertSuccessful().returnedValue()).isEmpty();
|
||||
}
|
||||
|
||||
@ -353,8 +353,8 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("contact-admin@eleventhcontact.example.com");
|
||||
assertThat(relationRepo.findByUuid(givenRelation.getUuid())).isPresent();
|
||||
relationRepo.deleteByUuid(givenRelation.getUuid());
|
||||
assertThat(relationRbacRepo.findByUuid(givenRelation.getUuid())).isPresent();
|
||||
relationRbacRepo.deleteByUuid(givenRelation.getUuid());
|
||||
});
|
||||
|
||||
// then
|
||||
@ -363,7 +363,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
"[403] Subject ", " not allowed to delete hs_office_relation");
|
||||
assertThat(jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
return relationRepo.findByUuid(givenRelation.getUuid());
|
||||
return relationRbacRepo.findByUuid(givenRelation.getUuid());
|
||||
}).assertSuccessful().returnedValue()).isPresent(); // still there
|
||||
}
|
||||
|
||||
@ -379,7 +379,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
return relationRepo.deleteByUuid(givenRelation.getUuid());
|
||||
return relationRbacRepo.deleteByUuid(givenRelation.getUuid());
|
||||
});
|
||||
|
||||
// then
|
||||
@ -408,7 +408,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
"[creating relation test-data FirstGmbH-Firby, hs_office_relation, INSERT]");
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity givenSomeTemporaryRelationBessler(final String holderPerson, final String contact) {
|
||||
private HsOfficeRelationRbacEntity givenSomeTemporaryRelationBessler(final String holderPerson, final String contact) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
@ -421,23 +421,23 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
.contact(givenContact)
|
||||
.build();
|
||||
|
||||
return toCleanup(relationRepo.save(newRelation));
|
||||
return toCleanup(relationRbacRepo.save(newRelation));
|
||||
}).assertSuccessful().returnedValue();
|
||||
}
|
||||
|
||||
void exactlyTheseRelationsAreReturned(
|
||||
final List<HsOfficeRelationEntity> actualResult,
|
||||
final List<HsOfficeRelationRbacEntity> actualResult,
|
||||
final String... relationNames) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsOfficeRelationEntity::toString)
|
||||
.extracting(HsOfficeRelation::toString)
|
||||
.containsExactlyInAnyOrder(relationNames);
|
||||
}
|
||||
|
||||
void allTheseRelationsAreReturned(
|
||||
final List<HsOfficeRelationEntity> actualResult,
|
||||
final List<HsOfficeRelationRbacEntity> actualResult,
|
||||
final String... relationNames) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsOfficeRelationEntity::toString)
|
||||
.extracting(HsOfficeRelation::toString)
|
||||
.contains(relationNames);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class HsOfficeRelationEntityUnitTest {
|
||||
class HsOfficeRelationUnitTest {
|
||||
|
||||
private HsOfficePersonEntity anchor = HsOfficePersonEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
Loading…
Reference in New Issue
Block a user