diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-08-19 16:17:03 +0200 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-08-19 16:33:11 +0200 |
commit | e98fe40ba47af72eb26d11722d3bba16da374cc8 (patch) | |
tree | 8240529cc29a6d16a13bffa182aee2885e1d62f1 /aai-core/src | |
parent | d2a63fcf3c5ee6b8363cc9db87706b2491c7aeb0 (diff) |
Update spring-boot to 2.5 in aai-common
- update spring-boot (2.4 -> 2.5.15)
- update vulnerable dependencies (spring-jms)
- remove old codehaus.jackson dependency
Issue-ID: AAI-3972
Change-Id: Ie0854c192a3a7bb719e9ac0e080e83a48e1b964a
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-core/src')
-rw-r--r-- | aai-core/src/main/java/org/onap/aai/util/PojoUtils.java | 8 | ||||
-rw-r--r-- | aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java | 12 |
2 files changed, 7 insertions, 13 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java b/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java index f974ba14..4c2ce942 100644 --- a/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java +++ b/aai-core/src/main/java/org/onap/aai/util/PojoUtils.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; import com.google.common.base.CaseFormat; import com.google.common.collect.Multimap; @@ -124,12 +125,15 @@ public class PojoUtils { */ public <T> String getJsonFromObject(T clazz, boolean wrapRoot, boolean indent) throws JsonGenerationException, JsonMappingException, IOException { - ObjectMapper mapper = JsonMapper.builder().serializationInclusion(JsonInclude.Include.NON_NULL) + ObjectMapper mapper = JsonMapper.builder() + .addModule(new JaxbAnnotationModule()) + .addModule(new JavaTimeModule()) + .serializationInclusion(JsonInclude.Include.NON_NULL) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .configure(SerializationFeature.INDENT_OUTPUT, indent) .configure(SerializationFeature.WRAP_ROOT_VALUE, wrapRoot) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot).addModule(new JaxbAnnotationModule()) + .configure(DeserializationFeature.UNWRAP_ROOT_VALUE, wrapRoot) .build(); return mapper.writeValueAsString(clazz); diff --git a/aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java b/aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java index 68f01962..a6a8c33d 100644 --- a/aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java +++ b/aai-core/src/test/java/org/onap/aai/util/PojoUtilsTest.java @@ -100,18 +100,8 @@ public class PojoUtilsTest { LocalDateTime date = LocalDateTime.of(2017, Month.SEPTEMBER, 18, 10, 55, 0, 300); String res = pojoUtils.getJsonFromObject(date); - + assertEquals("\"2017-09-18T10:55:00.0000003\"", res); assertNotNull(res); - assertTrue(res.contains("\"dayOfMonth\" : 18")); - assertTrue(res.contains("\"dayOfWeek\" : \"MONDAY\"")); - assertTrue(res.contains("\"dayOfYear\" : 261")); - assertTrue(res.contains("\"hour\" : 10")); - assertTrue(res.contains("\"minute\" : 55")); - assertTrue(res.contains("\"month\" : \"SEPTEMBER\"")); - assertTrue(res.contains("\"monthValue\" : 9")); - assertTrue(res.contains("\"nano\" : 300")); - assertTrue(res.contains("\"second\" : 0")); - assertTrue(res.contains("\"year\" : 2017")); } @Test |