introduce HsOfficeRelationRawEntity (WIP) Import working, but not normal tests
This commit is contained in:
parent
e4e1216a85
commit
457fe37306
@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartne
|
||||
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.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.mapper.Mapper;
|
||||
@ -156,7 +157,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity persistPartnerRel(final HsOfficePartnerRelInsertResource resource) {
|
||||
final var entity = new HsOfficeRelationEntity();
|
||||
final var entity = new HsOfficeRelationRbacEntity();
|
||||
entity.setType(HsOfficeRelationType.PARTNER);
|
||||
entity.setAnchor(ref(HsOfficePersonEntity.class, resource.getAnchorUuid()));
|
||||
entity.setHolder(ref(HsOfficePersonEntity.class, resource.getHolderUuid()));
|
||||
|
@ -68,7 +68,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
|
||||
|
||||
context.define(currentUser, assumedRoles);
|
||||
|
||||
final var entityToSave = new HsOfficeRelationEntity();
|
||||
final var entityToSave = new HsOfficeRelationRbacEntity();
|
||||
entityToSave.setType(HsOfficeRelationType.valueOf(body.getType()));
|
||||
entityToSave.setMark(body.getMark());
|
||||
entityToSave.setAnchor(holderRepo.findByUuid(body.getAnchorUuid()).orElseThrow(
|
||||
|
@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
@ -15,6 +16,7 @@ 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;
|
||||
@ -28,14 +30,14 @@ import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL.directlyFetche
|
||||
import static net.hostsharing.hsadminng.stringify.Stringify.stringify;
|
||||
|
||||
@Entity
|
||||
@Table(name = "hs_office_relation_rv")
|
||||
@Inheritance(strategy = TABLE_PER_CLASS)
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder(toBuilder = true)
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@FieldNameConstants
|
||||
public class HsOfficeRelationEntity implements RbacObject, Stringifyable {
|
||||
public abstract class HsOfficeRelationEntity implements RbacObject<HsOfficeRelationEntity>, Stringifyable {
|
||||
|
||||
private static Stringify<HsOfficeRelationEntity> toString = stringify(HsOfficeRelationEntity.class, "rel")
|
||||
.withProp(Fields.anchor, HsOfficeRelationEntity::getAnchor)
|
||||
@ -94,6 +96,8 @@ public class HsOfficeRelationEntity implements RbacObject, Stringifyable {
|
||||
return toShortString.apply(this);
|
||||
}
|
||||
|
||||
public abstract <T extends HsOfficeRelationEntity> HsOfficeRelationEntityBuilder<T, ?> toBuilder();
|
||||
|
||||
public static RbacView rbac() {
|
||||
return rbacViewFor("relation", HsOfficeRelationEntity.class)
|
||||
.withIdentityView(SQL.projection("""
|
||||
|
@ -0,0 +1,25 @@
|
||||
package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "hs_office_relation")
|
||||
//@DiscriminatorValue("0")
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class HsOfficeRelationRawEntity extends HsOfficeRelationEntity {
|
||||
|
||||
@Override
|
||||
public HsOfficeRelationEntityBuilder<?, ?> toBuilder() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package net.hostsharing.hsadminng.hs.office.relation;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView;
|
||||
import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import java.io.IOException;
|
||||
|
||||
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.GLOBAL;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Nullable.NOT_NULL;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Permission.DELETE;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Permission.INSERT;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Permission.SELECT;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Permission.UPDATE;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.RbacUserReference.UserRole.CREATOR;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Role.ADMIN;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Role.AGENT;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Role.OWNER;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Role.REFERRER;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.Role.TENANT;
|
||||
import static net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL.directlyFetchedByDependsOnColumn;
|
||||
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;
|
||||
}
|
||||
|
||||
public static RbacView rbac() {
|
||||
return rbacViewFor("relation", HsOfficeRelationRbacEntity.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", HsOfficeContactEntity.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");
|
||||
}
|
||||
}
|
@ -8,11 +8,11 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static java.util.Optional.ofNullable;
|
||||
|
||||
public final class Stringify<B> {
|
||||
|
||||
@ -32,11 +32,14 @@ public final class Stringify<B> {
|
||||
|
||||
public <T extends B> Stringify<T> using(final Class<T> subClass) {
|
||||
//noinspection unchecked
|
||||
return (Stringify<T>) new Stringify<T>(subClass, null)
|
||||
final var stringify = new Stringify<T>(subClass, null)
|
||||
.withIdProp(cast(idProp))
|
||||
.withProps(cast(props))
|
||||
.withSeparator(separator)
|
||||
.quotedValues(quotedValues);
|
||||
.withSeparator(separator);
|
||||
if (quotedValues != null) {
|
||||
stringify.quotedValues(quotedValues);
|
||||
}
|
||||
return stringify;
|
||||
}
|
||||
|
||||
private Stringify(final Class<B> clazz, final String name) {
|
||||
@ -96,7 +99,7 @@ public final class Stringify<B> {
|
||||
}
|
||||
|
||||
private String propName(final PropertyValue<B> propVal, final String delimiter) {
|
||||
return Optional.ofNullable(propVal.prop.name).map(v -> v + delimiter).orElse("");
|
||||
return ofNullable(propVal.prop.name).map(v -> v + delimiter).orElse("");
|
||||
}
|
||||
|
||||
private String optionallyQuoted(final PropertyValue<B> propVal) {
|
||||
|
@ -15,6 +15,7 @@ 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.HsOfficeRelationRawEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.hs.office.sepamandate.HsOfficeSepaMandateEntity;
|
||||
import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject;
|
||||
@ -1057,7 +1058,7 @@ public class ImportOfficeData extends CsvDataImport {
|
||||
final HsOfficePersonEntity anchor,
|
||||
final HsOfficePersonEntity holder,
|
||||
final HsOfficeContactEntity contact) {
|
||||
final var rel = HsOfficeRelationEntity.builder()
|
||||
final var rel = HsOfficeRelationRawEntity.builder()
|
||||
.anchor(anchor)
|
||||
.holder(holder)
|
||||
.contact(contact)
|
||||
|
@ -8,7 +8,7 @@ import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountReposi
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||
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.HsOfficeRelationRepository;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
@ -274,7 +274,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
|
||||
final var givenDebitorRelUUid = jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
return relRepo.save(HsOfficeRelationEntity.builder()
|
||||
return relRepo.save(HsOfficeRelationRbacEntity.builder()
|
||||
.type(DEBITOR)
|
||||
.anchor(givenPartner.getPartnerRel().getHolder())
|
||||
.holder(givenBillingPerson)
|
||||
@ -726,7 +726,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
.debitorNumberSuffix(nextDebitorSuffix())
|
||||
.billable(true)
|
||||
.debitorRel(
|
||||
HsOfficeRelationEntity.builder()
|
||||
HsOfficeRelationRbacEntity.builder()
|
||||
.type(DEBITOR)
|
||||
.anchor(givenPartner.getPartnerRel().getHolder())
|
||||
.holder(givenPartner.getPartnerRel().getHolder())
|
||||
|
@ -3,6 +3,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.rbac.test.PatchUnitTestBase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
@ -44,7 +45,7 @@ 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 = HsOfficeRelationEntity.builder()
|
||||
private final HsOfficeRelationEntity givenInitialDebitorRel = HsOfficeRelationRbacEntity.builder()
|
||||
.uuid(INITIAL_DEBITOR_REL_UUID)
|
||||
.build();
|
||||
|
||||
@ -57,7 +58,7 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
@BeforeEach
|
||||
void initMocks() {
|
||||
lenient().when(em.getReference(eq(HsOfficeRelationEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeRelationEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
HsOfficeRelationRbacEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
lenient().when(em.getReference(eq(HsOfficeBankAccountEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeBankAccountEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
}
|
||||
@ -142,7 +143,7 @@ class HsOfficeDebitorEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
}
|
||||
|
||||
private HsOfficeRelationEntity newDebitorRel(final UUID uuid) {
|
||||
return HsOfficeRelationEntity.builder()
|
||||
return HsOfficeRelationRbacEntity.builder()
|
||||
.uuid(uuid)
|
||||
.build();
|
||||
}
|
||||
|
@ -5,13 +5,14 @@ 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 org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class HsOfficeDebitorEntityUnitTest {
|
||||
|
||||
private HsOfficeRelationEntity givenDebitorRel = HsOfficeRelationEntity.builder()
|
||||
private HsOfficeRelationEntity givenDebitorRel = HsOfficeRelationRbacEntity.builder()
|
||||
.anchor(HsOfficePersonEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("some partner trade name")
|
||||
|
@ -6,6 +6,7 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||
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.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
|
||||
@ -91,7 +92,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.partner(givenPartner)
|
||||
.debitorNumberSuffix("21")
|
||||
.debitorRel(HsOfficeRelationEntity.builder()
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenPartnerPerson)
|
||||
.holder(givenPartnerPerson)
|
||||
@ -124,7 +125,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var result = attempt(em, () -> {
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix("21")
|
||||
.debitorRel(HsOfficeRelationEntity.builder()
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenPartnerPerson)
|
||||
.holder(givenPartnerPerson)
|
||||
@ -159,7 +160,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var givenContact = one(contactRepo.findContactByOptionalCaptionLike("fourth contact"));
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.debitorNumberSuffix("22")
|
||||
.debitorRel(HsOfficeRelationEntity.builder()
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenPartnerPerson)
|
||||
.holder(givenDebitorPerson)
|
||||
@ -331,7 +332,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
givenDebitor.setDebitorRel(HsOfficeRelationEntity.builder()
|
||||
givenDebitor.setDebitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.type(HsOfficeRelationType.DEBITOR)
|
||||
.anchor(givenNewPartnerPerson)
|
||||
.holder(givenNewBillingPerson)
|
||||
@ -616,7 +617,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||
.partner(givenPartner)
|
||||
.debitorNumberSuffix("20")
|
||||
.debitorRel(HsOfficeRelationEntity.builder()
|
||||
.debitorRel(HsOfficeRelationRbacEntity.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.HsOfficeRelationEntity;
|
||||
import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.office.contact.TestHsOfficeContact.TEST_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(HsOfficeRelationEntity.builder()
|
||||
.debitorRel(HsOfficeRelationRbacEntity.builder()
|
||||
.holder(HsOfficePersonEntity.builder().build())
|
||||
.anchor(HsOfficePersonEntity.builder().build())
|
||||
.contact(TEST_CONTACT)
|
||||
|
@ -8,6 +8,7 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||
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.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
@ -525,7 +526,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
||||
final var givenPerson = personRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow();
|
||||
final var givenContact = contactRepo.findContactByOptionalCaptionLike(contactName).stream().findFirst().orElseThrow();
|
||||
|
||||
final var partnerRel = new HsOfficeRelationEntity();
|
||||
final var partnerRel = new HsOfficeRelationRbacEntity();
|
||||
partnerRel.setType(HsOfficeRelationType.PARTNER);
|
||||
partnerRel.setAnchor(givenMandantPerson);
|
||||
partnerRel.setHolder(givenPerson);
|
||||
|
@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
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.mapper.Mapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -176,7 +176,7 @@ class HsOfficePartnerControllerRestTest {
|
||||
when(partnerRepo.deleteByUuid(givenPartnerUuid)).thenReturn(0);
|
||||
|
||||
final UUID givenRelationUuid = UUID.randomUUID();
|
||||
when(partnerMock.getPartnerRel()).thenReturn(HsOfficeRelationEntity.builder()
|
||||
when(partnerMock.getPartnerRel()).thenReturn(HsOfficeRelationRbacEntity.builder()
|
||||
.uuid(givenRelationUuid)
|
||||
.build());
|
||||
when(relationRepo.deleteByUuid(givenRelationUuid)).thenReturn(0);
|
||||
|
@ -4,6 +4,7 @@ import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
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.rbac.test.PatchUnitTestBase;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
@ -49,7 +50,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
@BeforeEach
|
||||
void initMocks() {
|
||||
lenient().when(em.getReference(eq(HsOfficeRelationEntity.class), any())).thenAnswer(invocation ->
|
||||
HsOfficeRelationEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
HsOfficeRelationRbacEntity.builder().uuid(invocation.getArgument(1)).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,7 +58,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
final var entity = HsOfficePartnerEntity.builder()
|
||||
.uuid(INITIAL_PARTNER_UUID)
|
||||
.partnerNumber(12345)
|
||||
.partnerRel(HsOfficeRelationEntity.builder()
|
||||
.partnerRel(HsOfficeRelationRbacEntity.builder()
|
||||
.holder(givenInitialPerson)
|
||||
.contact(givenInitialContact)
|
||||
.build())
|
||||
@ -90,7 +91,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
}
|
||||
|
||||
private static HsOfficeRelationEntity newPartnerRel(final UUID uuid) {
|
||||
final var newPartnerRel = HsOfficeRelationEntity.builder()
|
||||
final var newPartnerRel = HsOfficeRelationRbacEntity.builder()
|
||||
.uuid(uuid)
|
||||
.build();
|
||||
return newPartnerRel;
|
||||
|
@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.partner;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
|
||||
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.HsOfficeRelationType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -13,7 +13,7 @@ class HsOfficePartnerEntityUnitTest {
|
||||
|
||||
private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder()
|
||||
.partnerNumber(12345)
|
||||
.partnerRel(HsOfficeRelationEntity.builder()
|
||||
.partnerRel(HsOfficeRelationRbacEntity.builder()
|
||||
.anchor(HsOfficePersonEntity.builder()
|
||||
.personType(HsOfficePersonType.LEGAL_PERSON)
|
||||
.tradeName("Hostsharing eG")
|
||||
|
@ -4,6 +4,7 @@ import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRepository;
|
||||
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.HsOfficeRelationType;
|
||||
import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup;
|
||||
@ -112,7 +113,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
|
||||
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
|
||||
|
||||
final var newRelation = HsOfficeRelationEntity.builder()
|
||||
final var newRelation = HsOfficeRelationRbacEntity.builder()
|
||||
.holder(givenPartnerPerson)
|
||||
.type(HsOfficeRelationType.PARTNER)
|
||||
.anchor(givenMandantPerson)
|
||||
@ -467,7 +468,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean
|
||||
final var givenPartnerPerson = personRepo.findPersonByOptionalNameLike(person).get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalCaptionLike(contact).get(0);
|
||||
|
||||
final var partnerRel = HsOfficeRelationEntity.builder()
|
||||
final var partnerRel = HsOfficeRelationRbacEntity.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.HsOfficeContactEntity;
|
||||
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.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(
|
||||
HsOfficeRelationEntity.builder()
|
||||
HsOfficeRelationRbacEntity.builder()
|
||||
.holder(HsOfficePersonEntity.builder()
|
||||
.personType(LEGAL_PERSON)
|
||||
.tradeName("Hostsharing eG")
|
||||
|
@ -456,7 +456,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike("Winkler").get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalCaptionLike("seventh contact").get(0);
|
||||
final var newRelation = HsOfficeRelationEntity.builder()
|
||||
final var newRelation = HsOfficeRelationRbacEntity.builder()
|
||||
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||
.anchor(givenAnchorPerson)
|
||||
.holder(givenHolderPerson)
|
||||
|
@ -50,7 +50,7 @@ class HsOfficeRelationEntityPatcherUnitTest extends PatchUnitTestBase<
|
||||
|
||||
@Override
|
||||
protected HsOfficeRelationEntity newInitialEntity() {
|
||||
final var entity = new HsOfficeRelationEntity();
|
||||
final var entity = new HsOfficeRelationRbacEntity();
|
||||
entity.setUuid(INITIAL_RELATION_UUID);
|
||||
entity.setType(HsOfficeRelationType.REPRESENTATIVE);
|
||||
entity.setAnchor(givenInitialAnchorPerson);
|
||||
|
@ -20,7 +20,7 @@ class HsOfficeRelationEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toStringReturnsAllProperties() {
|
||||
final var given = HsOfficeRelationEntity.builder()
|
||||
final var given = HsOfficeRelationRbacEntity.builder()
|
||||
.type(HsOfficeRelationType.SUBSCRIBER)
|
||||
.mark("members-announce")
|
||||
.anchor(anchor)
|
||||
@ -32,7 +32,7 @@ class HsOfficeRelationEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toShortString() {
|
||||
final var given = HsOfficeRelationEntity.builder()
|
||||
final var given = HsOfficeRelationRbacEntity.builder()
|
||||
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||
.anchor(anchor)
|
||||
.holder(holder)
|
||||
|
@ -76,7 +76,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
final var newRelation = HsOfficeRelationEntity.builder()
|
||||
final var newRelation = HsOfficeRelationRbacEntity.builder()
|
||||
.anchor(givenAnchorPerson)
|
||||
.holder(givenHolderPerson)
|
||||
.type(HsOfficeRelationType.SUBSCRIBER)
|
||||
@ -113,7 +113,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
.findFirst().orElseThrow();
|
||||
final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").stream()
|
||||
.findFirst().orElseThrow();
|
||||
final var newRelation = HsOfficeRelationEntity.builder()
|
||||
final var newRelation = HsOfficeRelationRbacEntity.builder()
|
||||
.anchor(givenAnchorPerson)
|
||||
.holder(givenHolderPerson)
|
||||
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||
@ -414,7 +414,7 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
final var givenAnchorPerson = personRepo.findPersonByOptionalNameLike("Erben Bessler").get(0);
|
||||
final var givenHolderPerson = personRepo.findPersonByOptionalNameLike(holderPerson).get(0);
|
||||
final var givenContact = contactRepo.findContactByOptionalCaptionLike(contact).get(0);
|
||||
final var newRelation = HsOfficeRelationEntity.builder()
|
||||
final var newRelation = HsOfficeRelationRbacEntity.builder()
|
||||
.type(HsOfficeRelationType.REPRESENTATIVE)
|
||||
.anchor(givenAnchorPerson)
|
||||
.holder(givenHolderPerson)
|
||||
|
Loading…
Reference in New Issue
Block a user