diff --git a/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java b/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java index d5ff80d9..87276f34 100644 --- a/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java +++ b/src/main/java/net/hostsharing/hsadminng/config/JsonObjectMapperConfiguration.java @@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.config; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.openapitools.jackson.nullable.JsonNullableModule; @@ -14,6 +15,10 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; @Configuration public class JsonObjectMapperConfiguration { + public static ObjectMapper build() { + return new JsonObjectMapperConfiguration().customObjectMapper().build(); + } + @Bean @Primary public Jackson2ObjectMapperBuilder customObjectMapper() { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index 7f797c14..15045cf7 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -605,10 +605,12 @@ class HsOfficeScenarioTests extends ScenarioTest { .given("partnerNumber", "P-31011") .given("nameOfDeceasedPerson", "Michelle Matthieu") // FIXME: redundant .given("dateOfDeath", "2024-11-15") + .given("representativeGivenName", "Lena") + .given("representativeFamilyName", "Stadland") .given( // "name": "Erbengemeinschaft Michelle Matthieu", // FIXME: automatic? "communityOfHeirsPostalAddress", """ - "co": "Lena Stadland", + "co": "Lena Stadland", // FIXME: take this form representative...? "street": "Im Wischer 14", "zipcode": "22987", "city": "Hamburg", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/ReplaceDeceasedPartnerWithCommunityOfHeirs.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/ReplaceDeceasedPartnerWithCommunityOfHeirs.java index a59da0d4..e9fb8d7b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/ReplaceDeceasedPartnerWithCommunityOfHeirs.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/ReplaceDeceasedPartnerWithCommunityOfHeirs.java @@ -6,6 +6,7 @@ import net.hostsharing.hsadminng.hs.scenarios.UseCase; import org.springframework.http.HttpStatus; import static io.restassured.http.ContentType.JSON; +import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.OK; public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase { @@ -44,9 +45,36 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase - httpPost("/api/hs/office/contacts", usingJsonBody(""" - { +// obtain("Contact: Erbengemeinschaft %{nameOfDeceasedPerson}", () -> +// httpPost("/api/hs/office/contacts", usingJsonBody(""" +// { +// "caption": "Erbengemeinschaft %{nameOfDeceasedPerson}", +// "postalAddress": { +// "name": "Erbengemeinschaft %{nameOfDeceasedPerson}", +// %{communityOfHeirsPostalAddress} +// }, +// "phoneNumbers": { +// "office": ${communityOfHeirsOfficePhoneNumber} +// }, +// "emailAddresses": { +// "main": ${communityOfHeirsEmailAddress} +// } +// } +// """)) +// .expecting(HttpStatus.CREATED).expecting(ContentType.JSON) +// ); + + obtain("Partner-Relation: Erbengemeinschaft %{nameOfDeceasedPerson}", () -> + httpPost("/api/hs/office/relations", usingJsonBody(""" + { + "type": "PARTNER", + "anchor.uuid": ${Person: Hostsharing eG}, + "holder": { + "personType": "NATURAL_PERSON", + "givenName": ${representativeGivenName}, + "familyName": ${representativeFamilyName} + }, + "contact": { "caption": "Erbengemeinschaft %{nameOfDeceasedPerson}", "postalAddress": { "name": "Erbengemeinschaft %{nameOfDeceasedPerson}", @@ -59,15 +87,44 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase +// httpPost("/api/hs/office/persons", usingJsonBody(""" +// { +// "personType": "NATURAL_PERSON", +// "givenName": ${representativeGivenName}, +// "familyName": ${representativeFamilyName} +// } +// """)) +// .expecting(HttpStatus.CREATED).expecting(ContentType.JSON), +// "A community of heirs needs at least one representative.", +// "If there are more than one, each needs their own contact" +// ); + + obtain("Representative-Relation: %{subscriberGivenName} %{subscriberFamilyName} for Erbengemeinschaft %{nameOfDeceasedPerson}", () -> + httpPost("/api/hs/office/relations", usingJsonBody(""" + { + "type": "REPRESENTATIVE", + "anchor.uuid": ${Person: %{partnerPersonTradeName}}, + "holder.uuid": { + "personType": "NATURAL_PERSON", + "givenName": ${representativeGivenName}, + "familyName": ${representativeFamilyName} + }, + "contact.uuid": ${Contact: %{subscriberGivenName} %{subscriberFamilyName}} + } + """)) + .expecting(CREATED).expecting(JSON), + "" + ); + obtain("Partner-Relation: Erbengemeinschaft %{nameOfDeceasedPerson}", () -> httpPost("/api/hs/office/relations", usingJsonBody(""" { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/TestReport.java b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/TestReport.java index c55bddce..57728f8a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/TestReport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/TestReport.java @@ -3,6 +3,7 @@ package net.hostsharing.hsadminng.hs.scenarios; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.SneakyThrows; +import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration; import net.hostsharing.hsadminng.system.SystemProcess; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Order; @@ -28,7 +29,7 @@ public class TestReport { public static final SimpleDateFormat MM_DD_YYYY_HH_MM_SS = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss"); private static final File markdownLogFile = new File(BUILD_DOC_SCENARIOS, ".last-debug-log.md"); - private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final ObjectMapper objectMapper = JsonObjectMapperConfiguration.build(); private final Map aliases; private final PrintWriter markdownLog; // records everything for debugging purposes