From 557bb28ca31d8353acf04993cb6a167fe48dc4a5 Mon Sep 17 00:00:00 2001 From: David Ryan Date: Tue, 22 Oct 2024 11:55:41 +1100 Subject: [PATCH] Update a two tests files that contain deprecated methods. --- .../publisher/MetricsPublisherManagerTest.java | 5 +++-- .../infrastructure/restapi/OpenApiTestUtil.java | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/data/publisher/src/test/java/tech/pegasys/teku/data/publisher/MetricsPublisherManagerTest.java b/data/publisher/src/test/java/tech/pegasys/teku/data/publisher/MetricsPublisherManagerTest.java index 03ff3079c1c..3c641d4ffb1 100644 --- a/data/publisher/src/test/java/tech/pegasys/teku/data/publisher/MetricsPublisherManagerTest.java +++ b/data/publisher/src/test/java/tech/pegasys/teku/data/publisher/MetricsPublisherManagerTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.when; import java.io.IOException; -import java.net.URL; +import java.net.URI; import java.nio.file.Path; import java.util.List; import java.util.Optional; @@ -56,7 +56,8 @@ void setup() throws IOException { when(metricsConfig.getPublicationInterval()).thenReturn(1); when(metricsEndpoint.getMetricsSystem()).thenReturn(prometheusMetricsSystem); when(metricsEndpoint.getMetricConfig()).thenReturn(metricsConfig); - when(metricsConfig.getMetricsEndpoint()).thenReturn(Optional.of(new URL("http://host.com/"))); + when(metricsConfig.getMetricsEndpoint()) + .thenReturn(Optional.of(URI.create("http://host.com/").toURL())); } @Test diff --git a/infrastructure/restapi/src/testFixtures/java/tech/pegasys/teku/infrastructure/restapi/OpenApiTestUtil.java b/infrastructure/restapi/src/testFixtures/java/tech/pegasys/teku/infrastructure/restapi/OpenApiTestUtil.java index 7eb2645211b..cbf357dfb55 100644 --- a/infrastructure/restapi/src/testFixtures/java/tech/pegasys/teku/infrastructure/restapi/OpenApiTestUtil.java +++ b/infrastructure/restapi/src/testFixtures/java/tech/pegasys/teku/infrastructure/restapi/OpenApiTestUtil.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; import com.google.common.collect.ImmutableList; import com.google.common.io.Resources; import java.io.IOException; @@ -44,12 +45,13 @@ public class OpenApiTestUtil { private final String path; public OpenApiTestUtil(final Class clazz) { - this.mapper = new ObjectMapper(); - mapper - .configure(SerializationFeature.INDENT_OUTPUT, true) - .configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true) - .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true) - .configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true); + this.mapper = + JsonMapper.builder() + .configure(SerializationFeature.INDENT_OUTPUT, true) + .configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true) + .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true) + .configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true) + .build(); this.clazz = clazz; this.path = clazz.getPackageName().replaceAll("\\.", "/"); }