From 9153c8b12a417885bf3c58d9c6115e51025a918b Mon Sep 17 00:00:00 2001 From: Andrei Arlou Date: Wed, 21 Feb 2024 18:38:06 +0200 Subject: [PATCH] Replace deprecated API for configuring ObjectMapper (#8395) --- .../java/io/helidon/builder/test/CustomNamedTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/builder/tests/builder/src/test/java/io/helidon/builder/test/CustomNamedTest.java b/builder/tests/builder/src/test/java/io/helidon/builder/test/CustomNamedTest.java index c78354a4b47..217023a93d6 100644 --- a/builder/tests/builder/src/test/java/io/helidon/builder/test/CustomNamedTest.java +++ b/builder/tests/builder/src/test/java/io/helidon/builder/test/CustomNamedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package io.helidon.builder.test; +import com.fasterxml.jackson.databind.json.JsonMapper; import io.helidon.builder.test.testsubjects.CustomNamed; import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; @@ -50,8 +51,9 @@ void testIt() throws Exception { customNamed.toString(), equalTo("CustomNamed{stringSet=[b, a, y],stringList=[b, a, b, y],stringToIntegerMap={b=1, e=2, a=3}}")); - ObjectMapper mapper = new ObjectMapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true) - .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); + ObjectMapper mapper = JsonMapper.builder().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true) + .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true) + .build(); DefaultPrettyPrinter printer = new DefaultPrettyPrinter(); String json = mapper.writer(printer).writeValueAsString(customNamed); assertThat(json, equalTo("{\n" + " \"stringSet\" : [ \"b\", \"a\", \"y\" ]\n" + "}"));