From 7b964b3c15503e1daddd87145e42b40ca34968dc Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Wed, 13 Nov 2024 15:54:20 +0100 Subject: [PATCH 1/2] fix run test Signed-off-by: Etienne LESOT --- .../server/configuration/RestTemplateConfig.java | 8 +++++--- .../server/SensitivityAnalysisControllerTest.java | 3 --- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gridsuite/sensitivityanalysis/server/configuration/RestTemplateConfig.java b/src/main/java/org/gridsuite/sensitivityanalysis/server/configuration/RestTemplateConfig.java index 799b6fa2..b041cd4a 100644 --- a/src/main/java/org/gridsuite/sensitivityanalysis/server/configuration/RestTemplateConfig.java +++ b/src/main/java/org/gridsuite/sensitivityanalysis/server/configuration/RestTemplateConfig.java @@ -7,9 +7,9 @@ package org.gridsuite.sensitivityanalysis.server.configuration; -import com.fasterxml.jackson.databind.InjectableValues; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.core.json.JsonReadFeature; +import com.fasterxml.jackson.core.json.JsonWriteFeature; +import com.fasterxml.jackson.databind.*; import com.powsybl.commons.report.ReportNodeDeserializer; import com.powsybl.commons.report.ReportNodeJsonModule; import com.powsybl.contingency.json.ContingencyJsonModule; @@ -52,6 +52,8 @@ private MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter( private static ObjectMapper createObjectMapper() { var objectMapper = Jackson2ObjectMapperBuilder.json().build(); + objectMapper.enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS.mappedFeature()) + .disable(JsonWriteFeature.WRITE_NAN_AS_STRINGS.mappedFeature()); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.registerModule(new ContingencyJsonModule()); objectMapper.registerModule(new LoadFlowResultJsonModule()); diff --git a/src/test/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisControllerTest.java b/src/test/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisControllerTest.java index 11116d3c..b9463b9c 100644 --- a/src/test/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisControllerTest.java +++ b/src/test/java/org/gridsuite/sensitivityanalysis/server/SensitivityAnalysisControllerTest.java @@ -31,7 +31,6 @@ import org.gridsuite.sensitivityanalysis.server.service.LoadFlowService; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; @@ -225,8 +224,6 @@ void tearDown() throws Exception { mockMvc.perform(delete("/" + VERSION + "/results")).andExpect(status().isOk()); } - // TODO to fix as soon as possible - @Disabled @Test void runTest() throws Exception { SensitivityAnalysisResult result = runInMemory(); From 940dea4b2b83444ccb55d1502a3413c5e8b23e97 Mon Sep 17 00:00:00 2001 From: Etienne LESOT Date: Thu, 14 Nov 2024 15:37:50 +0100 Subject: [PATCH 2/2] refactoring Signed-off-by: Etienne LESOT --- .../server/configuration/RestTemplateConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gridsuite/sensitivityanalysis/server/configuration/RestTemplateConfig.java b/src/main/java/org/gridsuite/sensitivityanalysis/server/configuration/RestTemplateConfig.java index b041cd4a..f583ff80 100644 --- a/src/main/java/org/gridsuite/sensitivityanalysis/server/configuration/RestTemplateConfig.java +++ b/src/main/java/org/gridsuite/sensitivityanalysis/server/configuration/RestTemplateConfig.java @@ -52,8 +52,8 @@ private MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter( private static ObjectMapper createObjectMapper() { var objectMapper = Jackson2ObjectMapperBuilder.json().build(); - objectMapper.enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS.mappedFeature()) - .disable(JsonWriteFeature.WRITE_NAN_AS_STRINGS.mappedFeature()); + objectMapper.enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS.mappedFeature()); + objectMapper.disable(JsonWriteFeature.WRITE_NAN_AS_STRINGS.mappedFeature()); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); objectMapper.registerModule(new ContingencyJsonModule()); objectMapper.registerModule(new LoadFlowResultJsonModule());