From 1a234d1528f09908e038f90193100899b23986f6 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 13 Jan 2025 18:17:32 +0100 Subject: [PATCH] fix theContactAdmin_canNotPatchARelatedDebitor --- .../hs/office/contact/HsOfficeContact.java | 3 ++- .../office/debitor/HsOfficeDebitorController.java | 4 +++- .../hs/office/partner/HsOfficePartnerEntity.java | 4 +++- .../HsOfficeDebitorControllerAcceptanceTest.java | 14 +++++++------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContact.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContact.java index dc5bca3e..63d6cfd5 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContact.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContact.java @@ -12,6 +12,7 @@ import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.mapper.PatchableMapWrapper; import net.hostsharing.hsadminng.persistence.BaseEntity; +import net.hostsharing.hsadminng.rbac.role.WithRoleId; import net.hostsharing.hsadminng.repr.Stringify; import net.hostsharing.hsadminng.repr.Stringifyable; import org.hibernate.annotations.GenericGenerator; @@ -37,7 +38,7 @@ import static net.hostsharing.hsadminng.repr.Stringify.stringify; @SuperBuilder(toBuilder = true) @FieldNameConstants @DisplayAs("Contact") -public class HsOfficeContact implements Stringifyable, BaseEntity { +public class HsOfficeContact implements Stringifyable, BaseEntity, WithRoleId { private static Stringify toString = stringify(HsOfficeContact.class, "contact") .withProp(Fields.caption, HsOfficeContact::getCaption) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java index 73ede563..70efafd4 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java @@ -228,6 +228,8 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { final BiConsumer ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> { resource.setDebitorNumber(entity.getTaggedDebitorNumber()); - resource.getPartner().setPartnerNumber(entity.getPartner().getTaggedPartnerNumber()); + if (resource.getPartner() != null) { // FIXME: should not happen + resource.getPartner().setPartnerNumber(entity.getPartner().getTaggedPartnerNumber()); + } }; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java index 69fb49c9..3575b24b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java @@ -82,7 +82,9 @@ public class HsOfficePartnerEntity implements Stringifyable, BaseEntity