From b21f44cafa4c867bff421800991191facb2f4fe8 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 12 Oct 2023 10:15:52 +0200 Subject: [PATCH] OZG-4428 process non string data --- .../src/main/resources/application-local.yml | 6 +++ .../enterprise/entry/EntryDataMapperTest.java | 5 +- .../entry/EntryFormDataTestFactory.java | 50 +++++++++++++++---- .../src/test/resources/request/simple.json | 12 +++++ pom.xml | 2 +- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/enterprise-adapter/src/main/resources/application-local.yml b/enterprise-adapter/src/main/resources/application-local.yml index 59827f122..d9a71da93 100644 --- a/enterprise-adapter/src/main/resources/application-local.yml +++ b/enterprise-adapter/src/main/resources/application-local.yml @@ -5,6 +5,12 @@ server: port: 9294 error: include-stacktrace: always + +management: + server: + port: 0 + endpoints: + enabled-by-default: false kop: adapter: diff --git a/enterprise-adapter/src/test/java/de/ozgcloud/eingang/enterprise/entry/EntryDataMapperTest.java b/enterprise-adapter/src/test/java/de/ozgcloud/eingang/enterprise/entry/EntryDataMapperTest.java index 238ce95c1..120c99e5c 100644 --- a/enterprise-adapter/src/test/java/de/ozgcloud/eingang/enterprise/entry/EntryDataMapperTest.java +++ b/enterprise-adapter/src/test/java/de/ozgcloud/eingang/enterprise/entry/EntryDataMapperTest.java @@ -15,6 +15,7 @@ import org.mockito.Spy; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import de.itvsh.kop.common.test.TestUtils; import de.ozgcloud.eingang.common.formdata.FormData; @@ -30,7 +31,9 @@ class EntryDataMapperTest { private FormDataMapper formDataMapper; @Spy - private ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true); + private ObjectMapper objectMapper = new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true) + .registerModule(new JavaTimeModule()); @Nested class TestMappingEntryData { diff --git a/enterprise-adapter/src/test/java/de/ozgcloud/eingang/enterprise/entry/EntryFormDataTestFactory.java b/enterprise-adapter/src/test/java/de/ozgcloud/eingang/enterprise/entry/EntryFormDataTestFactory.java index 6e6bf6802..26ca19bb7 100644 --- a/enterprise-adapter/src/test/java/de/ozgcloud/eingang/enterprise/entry/EntryFormDataTestFactory.java +++ b/enterprise-adapter/src/test/java/de/ozgcloud/eingang/enterprise/entry/EntryFormDataTestFactory.java @@ -2,6 +2,7 @@ package de.ozgcloud.eingang.enterprise.entry; import static de.ozgcloud.eingang.enterprise.entry.FormDataMapper.*; +import java.time.LocalDate; import java.util.List; import java.util.Map; @@ -14,20 +15,46 @@ public class EntryFormDataTestFactory { public static final String SUB_FORM_NAME = "antragsteller"; public static final String SUB_FORM_LABEL = "Antragstellende Person"; - public static final String SUB_FORM_FIELD_NAME = "lastname"; - public static final String SUB_FORM_FIELD_LABEL = "Nachname"; - public static final String SUB_FORM_FIELD_VALUE = "Täst"; + public static final String SUB_FORM_STRING_FIELD_NAME = "lastname"; + public static final String SUB_FORM_STRING_FIELD_LABEL = "Nachname"; + public static final String SUB_FORM_STRING_FIELD_VALUE = "Täst"; + + public static final String SUB_FORM_NUMBER_FIELD_NAME = "age"; + public static final String SUB_FORM_NUMBER_FIELD_LABEL = "Alter"; + public static final Number SUB_FORM_NUMBER_FIELD_VALUE = 5.5; + + public static final String SUB_FORM_DATE_FIELD_NAME = "birthday"; + public static final String SUB_FORM_DATE_FIELD_LABEL = "Geburtsdatum"; + public static final LocalDate SUB_FORM_DATE_FIELD_VALUE = LocalDate.parse("2017-05-01"); + + public static final String SUB_FORM_BOOLEAN_FIELD_NAME = "geprüft"; + public static final String SUB_FORM_BOOLEAN_FIELD_LABEL = "Geprüft"; + public static final Boolean SUB_FORM_BOOLEAN_FIELD_VALUE = true; public static List<EntryFormDataItem> create() { return List.of( EntryFormDataField.builder().name(FORM_FIELD_NAME).label(FORM_FIELD_LABEL).stringValue(FORM_FIELD_VALUE).build(), EntryFormDataSubForm.builder().name(SUB_FORM_NAME).label(SUB_FORM_LABEL) - .formItem( - EntryFormDataField.builder() - .name(SUB_FORM_FIELD_NAME) - .label(SUB_FORM_FIELD_LABEL) - .stringValue(SUB_FORM_FIELD_VALUE) - .build()) + .formItem(EntryFormDataField.builder() + .name(SUB_FORM_STRING_FIELD_NAME) + .label(SUB_FORM_STRING_FIELD_LABEL) + .stringValue(SUB_FORM_STRING_FIELD_VALUE) + .build()) + .formItem(EntryFormDataField.builder() + .name(SUB_FORM_NUMBER_FIELD_NAME) + .label(SUB_FORM_NUMBER_FIELD_LABEL) + .numberValue(SUB_FORM_NUMBER_FIELD_VALUE) + .build()) + .formItem(EntryFormDataField.builder() + .name(SUB_FORM_DATE_FIELD_NAME) + .label(SUB_FORM_DATE_FIELD_LABEL) + .dateValue(SUB_FORM_DATE_FIELD_VALUE) + .build()) + .formItem(EntryFormDataField.builder() + .name(SUB_FORM_BOOLEAN_FIELD_NAME) + .label(SUB_FORM_BOOLEAN_FIELD_LABEL) + .booleanValue(SUB_FORM_BOOLEAN_FIELD_VALUE) + .build()) .build()); } @@ -35,6 +62,9 @@ public class EntryFormDataTestFactory { return Map.of( FORM_FIELD_NAME, Map.of(LABEL_KEY, FORM_FIELD_LABEL, VALUE_KEY, FORM_FIELD_VALUE), SUB_FORM_NAME, Map.of(LABEL_KEY, SUB_FORM_LABEL, VALUE_KEY, Map.of( - SUB_FORM_FIELD_NAME, Map.of(LABEL_KEY, SUB_FORM_FIELD_LABEL, VALUE_KEY, SUB_FORM_FIELD_VALUE)))); + SUB_FORM_STRING_FIELD_NAME, Map.of(LABEL_KEY, SUB_FORM_STRING_FIELD_LABEL, VALUE_KEY, SUB_FORM_STRING_FIELD_VALUE), + SUB_FORM_NUMBER_FIELD_NAME, Map.of(LABEL_KEY, SUB_FORM_NUMBER_FIELD_LABEL, VALUE_KEY, SUB_FORM_NUMBER_FIELD_VALUE), + SUB_FORM_DATE_FIELD_NAME, Map.of(LABEL_KEY, SUB_FORM_DATE_FIELD_LABEL, VALUE_KEY, SUB_FORM_DATE_FIELD_VALUE), + SUB_FORM_BOOLEAN_FIELD_NAME, Map.of(LABEL_KEY, SUB_FORM_BOOLEAN_FIELD_LABEL, VALUE_KEY, SUB_FORM_BOOLEAN_FIELD_VALUE)))); } } diff --git a/enterprise-adapter/src/test/resources/request/simple.json b/enterprise-adapter/src/test/resources/request/simple.json index cb55a7580..de767a235 100644 --- a/enterprise-adapter/src/test/resources/request/simple.json +++ b/enterprise-adapter/src/test/resources/request/simple.json @@ -26,6 +26,18 @@ "name": "lastname", "label": "Nachname", "stringValue": "Täst" + }, { + "name": "age", + "label": "Alter", + "numberValue": 5.5 + }, { + "name": "birthday", + "label": "Geburtsdatum", + "dateValue": "2017-05-01" + }, { + "name": "geprüft", + "label": "Geprüft", + "booleanValue": true } ] } diff --git a/pom.xml b/pom.xml index 163fadcc9..ee801b1b0 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ <properties> <mapstruct.version>1.4.2.Final</mapstruct.version> - <pluto.version>1.10.0</pluto.version> + <pluto.version>1.16.0-SNAPSHOT</pluto.version> <jsoup.version>1.14.3</jsoup.version> <xmlschema.version>2.3.0</xmlschema.version> -- GitLab