From aa2720d9736f33efacdba38e4532373518813d1e Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 13 Nov 2025 17:04:51 +0100 Subject: [PATCH 1/3] Harmonize exceptions handling --- pom.xml | 8 +++ .../server/PropertyServerNameProvider.java | 28 ++++++++ .../RestResponseEntityExceptionHandler.java | 38 +++++++--- .../server/ShortCircuitException.java | 29 +++----- .../server/ShortcircuitBusinessErrorCode.java | 20 ++++++ .../server/service/ShortCircuitService.java | 69 ++++++++++--------- .../service/ShortCircuitWorkerService.java | 6 +- .../PropertyServerNameProviderTest.java | 23 +++++++ .../ShortCircuitParametersControllerTest.java | 11 ++- .../server/ShortCircuitParametersITest.java | 38 ++++++---- 10 files changed, 192 insertions(+), 78 deletions(-) create mode 100644 src/main/java/org/gridsuite/shortcircuit/server/PropertyServerNameProvider.java create mode 100644 src/main/java/org/gridsuite/shortcircuit/server/ShortcircuitBusinessErrorCode.java create mode 100644 src/test/java/org/gridsuite/shortcircuit/server/PropertyServerNameProviderTest.java diff --git a/pom.xml b/pom.xml index 39a3c669..10f289bb 100644 --- a/pom.xml +++ b/pom.xml @@ -115,6 +115,13 @@ + + com.rte-france.powsybl + powsybl-courcirc-integration + 4.10.2 + runtime + + org.projectlombok @@ -162,6 +169,7 @@ org.gridsuite gridsuite-computation + 1.6.0-SNAPSHOT diff --git a/src/main/java/org/gridsuite/shortcircuit/server/PropertyServerNameProvider.java b/src/main/java/org/gridsuite/shortcircuit/server/PropertyServerNameProvider.java new file mode 100644 index 00000000..b5a6a044 --- /dev/null +++ b/src/main/java/org/gridsuite/shortcircuit/server/PropertyServerNameProvider.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.gridsuite.shortcircuit.server; + +import com.powsybl.ws.commons.error.ServerNameProvider; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @author Hugo Marcellin + */ +@Component +public class PropertyServerNameProvider implements ServerNameProvider { + private final String name; + + public PropertyServerNameProvider(@Value("${spring.application.name:shortcircuit-server}") String name) { + this.name = name; + } + + @Override + public String serverName() { + return name; + } +} diff --git a/src/main/java/org/gridsuite/shortcircuit/server/RestResponseEntityExceptionHandler.java b/src/main/java/org/gridsuite/shortcircuit/server/RestResponseEntityExceptionHandler.java index 454c3cc5..5464e2ec 100644 --- a/src/main/java/org/gridsuite/shortcircuit/server/RestResponseEntityExceptionHandler.java +++ b/src/main/java/org/gridsuite/shortcircuit/server/RestResponseEntityExceptionHandler.java @@ -7,23 +7,41 @@ package org.gridsuite.shortcircuit.server; +import com.powsybl.ws.commons.error.AbstractBaseRestExceptionHandler; +import com.powsybl.ws.commons.error.AbstractBusinessException; +import com.powsybl.ws.commons.error.BusinessErrorCode; +import com.powsybl.ws.commons.error.ServerNameProvider; +import lombok.NonNull; import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; + +import static org.gridsuite.computation.ComputationBusinessErrorCode.*; +import static org.gridsuite.shortcircuit.server.ShortcircuitBusinessErrorCode.*; /** * @author Ghazwa Rehili */ @ControllerAdvice -public class RestResponseEntityExceptionHandler { - @ExceptionHandler(ShortCircuitException.class) - protected ResponseEntity handleShortCircuitException(ShortCircuitException exception) { - return switch (exception.getType()) { - case RESULT_NOT_FOUND -> ResponseEntity.status(HttpStatus.NOT_FOUND).body(exception.getMessage()); - case INVALID_EXPORT_PARAMS -> ResponseEntity.status(HttpStatus.BAD_REQUEST).body(exception.getMessage()); - case BUS_OUT_OF_VOLTAGE, FILE_EXPORT_ERROR, MISSING_EXTENSION_DATA, INCONSISTENT_VOLTAGE_LEVELS -> - ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(exception.getMessage()); +public class RestResponseEntityExceptionHandler extends AbstractBaseRestExceptionHandler { + + protected RestResponseEntityExceptionHandler(ServerNameProvider serverNameProvider) { + super(serverNameProvider); + } + + @Override + protected @NonNull BusinessErrorCode getBusinessCode(AbstractBusinessException e) { + return e.getBusinessErrorCode(); + } + + @Override + protected HttpStatus mapStatus(BusinessErrorCode businessErrorCode) { + return switch (businessErrorCode) { + case RESULT_NOT_FOUND, NETWORK_NOT_FOUND, PARAMETERS_NOT_FOUND -> HttpStatus.NOT_FOUND; + case INVALID_FILTER_FORMAT, + INVALID_SORT_FORMAT, + INVALID_FILTER, + INVALID_EXPORT_PARAMS -> HttpStatus.BAD_REQUEST; + default -> HttpStatus.INTERNAL_SERVER_ERROR; }; } } diff --git a/src/main/java/org/gridsuite/shortcircuit/server/ShortCircuitException.java b/src/main/java/org/gridsuite/shortcircuit/server/ShortCircuitException.java index d55f1d4c..1d0f9c18 100644 --- a/src/main/java/org/gridsuite/shortcircuit/server/ShortCircuitException.java +++ b/src/main/java/org/gridsuite/shortcircuit/server/ShortCircuitException.java @@ -6,6 +6,8 @@ */ package org.gridsuite.shortcircuit.server; +import com.powsybl.ws.commons.error.AbstractBusinessException; +import jakarta.validation.constraints.NotNull; import lombok.Getter; import java.util.Objects; @@ -14,27 +16,18 @@ * @author David SARTORI */ @Getter -public class ShortCircuitException extends RuntimeException { +public class ShortCircuitException extends AbstractBusinessException { - public enum Type { - BUS_OUT_OF_VOLTAGE, - RESULT_NOT_FOUND, - INVALID_EXPORT_PARAMS, - FILE_EXPORT_ERROR, - MISSING_EXTENSION_DATA, - INCONSISTENT_VOLTAGE_LEVELS - } - - private final Type type; + private final ShortcircuitBusinessErrorCode errorCode; - public ShortCircuitException(Type type) { - super(Objects.requireNonNull(type.name())); - this.type = type; + public ShortCircuitException(ShortcircuitBusinessErrorCode errorCode, String message) { + super(Objects.requireNonNull(message, "message must not be null")); + this.errorCode = Objects.requireNonNull(errorCode, "errorCode must not be null"); } - public ShortCircuitException(Type type, String message) { - super(message); - this.type = type; + @NotNull + @Override + public ShortcircuitBusinessErrorCode getBusinessErrorCode() { + return errorCode; } - } diff --git a/src/main/java/org/gridsuite/shortcircuit/server/ShortcircuitBusinessErrorCode.java b/src/main/java/org/gridsuite/shortcircuit/server/ShortcircuitBusinessErrorCode.java new file mode 100644 index 00000000..b8d856c3 --- /dev/null +++ b/src/main/java/org/gridsuite/shortcircuit/server/ShortcircuitBusinessErrorCode.java @@ -0,0 +1,20 @@ +package org.gridsuite.shortcircuit.server; + +import com.powsybl.ws.commons.error.BusinessErrorCode; + +public enum ShortcircuitBusinessErrorCode implements BusinessErrorCode { + BUS_OUT_OF_VOLTAGE("shortcircuit.busOutOfVoltage"), + INVALID_EXPORT_PARAMS("shortcircuit.invalidExportParams"), + MISSING_EXTENSION_DATA("shortcircuit.missingExtensionData"), + INCONSISTENT_VOLTAGE_LEVELS("shortcircuit.inconsistentVoltageLevels"),; + + private final String code; + + ShortcircuitBusinessErrorCode(String code) { + this.code = code; + } + + public String value() { + return code; + } +} diff --git a/src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitService.java b/src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitService.java index 80ae6fb1..fd3807eb 100644 --- a/src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitService.java +++ b/src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitService.java @@ -17,6 +17,7 @@ import com.univocity.parsers.csv.CsvWriter; import com.univocity.parsers.csv.CsvWriterSettings; import org.apache.commons.lang3.StringUtils; +import org.gridsuite.computation.ComputationException; import org.gridsuite.computation.dto.GlobalFilter; import org.gridsuite.computation.dto.ResourceFilterDTO; import org.gridsuite.computation.s3.ComputationS3Service; @@ -47,8 +48,10 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import static org.gridsuite.computation.ComputationBusinessErrorCode.FILE_EXPORT_ERROR; +import static org.gridsuite.computation.ComputationBusinessErrorCode.RESULT_NOT_FOUND; import static org.gridsuite.computation.utils.FilterUtils.fromStringFiltersToDTO; -import static org.gridsuite.shortcircuit.server.ShortCircuitException.Type.*; +import static org.gridsuite.shortcircuit.server.ShortcircuitBusinessErrorCode.INVALID_EXPORT_PARAMS; /** * @author Etienne Homer @@ -94,8 +97,8 @@ public UUID runAndSaveResult(UUID networkUuid, String variantId, String receiver parameters.setWithFortescueResult(StringUtils.isNotBlank(busId)); parameters.setDetailedReport(false); return runAndSaveResult(new ShortCircuitRunContext(networkUuid, variantId, receiver, parameters, reportUuid, reporterId, reportType, userId, - "default-provider", // TODO : replace with null when fix in powsybl-ws-commons will handle null provider - busId, debug)); + "default-provider", // TODO : replace with null when fix in powsybl-ws-commons will handle null provider + busId, debug)); } @Override @@ -157,37 +160,37 @@ private static FeederResult fromEntity(FeederResultEntity feederResultEntity) { private static ShortCircuitParametersEntity toEntity(ShortCircuitParametersInfos parametersInfos) { final ShortCircuitParameters parameters = parametersInfos.parameters(); return new ShortCircuitParametersEntity( - parameters.isWithLimitViolations(), - parameters.isWithVoltageResult(), - parameters.isWithFeederResult(), - parameters.getStudyType(), - parameters.getMinVoltageDropProportionalThreshold(), - parametersInfos.predefinedParameters(), - parameters.isWithLoads(), - parameters.isWithShuntCompensators(), - parameters.isWithVSCConverterStations(), - parameters.isWithNeutralPosition(), - parameters.getInitialVoltageProfileMode() + parameters.isWithLimitViolations(), + parameters.isWithVoltageResult(), + parameters.isWithFeederResult(), + parameters.getStudyType(), + parameters.getMinVoltageDropProportionalThreshold(), + parametersInfos.predefinedParameters(), + parameters.isWithLoads(), + parameters.isWithShuntCompensators(), + parameters.isWithVSCConverterStations(), + parameters.isWithNeutralPosition(), + parameters.getInitialVoltageProfileMode() ); } private static ShortCircuitParametersInfos fromEntity(ShortCircuitParametersEntity entity) { Objects.requireNonNull(entity); return new ShortCircuitParametersInfos( - entity.getPredefinedParameters(), - new ShortCircuitParameters() - .setStudyType(entity.getStudyType()) - .setMinVoltageDropProportionalThreshold(entity.getMinVoltageDropProportionalThreshold()) - .setWithFeederResult(entity.isWithFeederResult()) - .setWithLimitViolations(entity.isWithLimitViolations()) - .setWithVoltageResult(entity.isWithVoltageResult()) - .setWithLoads(entity.isWithLoads()) - .setWithShuntCompensators(entity.isWithShuntCompensators()) - .setWithVSCConverterStations(entity.isWithVscConverterStations()) - .setWithNeutralPosition(entity.isWithNeutralPosition()) - .setInitialVoltageProfileMode(entity.getInitialVoltageProfileMode()) - // the voltageRanges is not taken into account when initialVoltageProfileMode=NOMINAL - .setVoltageRanges(InitialVoltageProfileMode.CONFIGURED.equals(entity.getInitialVoltageProfileMode()) ? CEI909_VOLTAGE_PROFILE : null) + entity.getPredefinedParameters(), + new ShortCircuitParameters() + .setStudyType(entity.getStudyType()) + .setMinVoltageDropProportionalThreshold(entity.getMinVoltageDropProportionalThreshold()) + .setWithFeederResult(entity.isWithFeederResult()) + .setWithLimitViolations(entity.isWithLimitViolations()) + .setWithVoltageResult(entity.isWithVoltageResult()) + .setWithLoads(entity.isWithLoads()) + .setWithShuntCompensators(entity.isWithShuntCompensators()) + .setWithVSCConverterStations(entity.isWithVscConverterStations()) + .setWithNeutralPosition(entity.isWithNeutralPosition()) + .setInitialVoltageProfileMode(entity.getInitialVoltageProfileMode()) + // the voltageRanges is not taken into account when initialVoltageProfileMode=NOMINAL + .setVoltageRanges(InitialVoltageProfileMode.CONFIGURED.equals(entity.getInitialVoltageProfileMode()) ? CEI909_VOLTAGE_PROFILE : null) ); } @@ -291,13 +294,13 @@ public static byte[] exportToCsv(ShortCircuitAnalysisResult result, List csvWriter.close(); return outputStream.toByteArray(); } catch (IOException e) { - throw new ShortCircuitException(FILE_EXPORT_ERROR, e.getMessage()); + throw new ComputationException(FILE_EXPORT_ERROR, e.getMessage()); } } public byte[] getZippedCsvExportResult(UUID resultUuid, ShortCircuitAnalysisResult result, CsvTranslation csvTranslation) { if (result == null) { - throw new ShortCircuitException(RESULT_NOT_FOUND, "The short circuit analysis result '" + resultUuid + "' does not exist"); + throw new ComputationException(RESULT_NOT_FOUND, "The short circuit analysis result '" + resultUuid + "' does not exist"); } if (Objects.isNull(csvTranslation) || Objects.isNull(csvTranslation.headersCsv()) || Objects.isNull(csvTranslation.enumValueTranslations())) { throw new ShortCircuitException(INVALID_EXPORT_PARAMS, "Missing information to export short-circuit result as csv: file headers and enum translation must be provided"); @@ -433,9 +436,9 @@ public boolean deleteParameters(final UUID parametersUuid) { @Transactional public Optional duplicateParameters(UUID sourceParametersUuid) { return parametersRepository.findById(sourceParametersUuid) - .map(ShortCircuitParametersEntity::new) - .map(parametersRepository::save) - .map(ShortCircuitParametersEntity::getId); + .map(ShortCircuitParametersEntity::new) + .map(parametersRepository::save) + .map(ShortCircuitParametersEntity::getId); } public UUID createParameters(@Nullable final ShortCircuitParametersInfos parameters) { diff --git a/src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitWorkerService.java b/src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitWorkerService.java index 1f49a85c..82c78b4a 100644 --- a/src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitWorkerService.java +++ b/src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitWorkerService.java @@ -30,7 +30,9 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import static org.gridsuite.shortcircuit.server.ShortCircuitException.Type.*; +import static org.gridsuite.shortcircuit.server.ShortcircuitBusinessErrorCode.BUS_OUT_OF_VOLTAGE; +import static org.gridsuite.shortcircuit.server.ShortcircuitBusinessErrorCode.INCONSISTENT_VOLTAGE_LEVELS; +import static org.gridsuite.shortcircuit.server.ShortcircuitBusinessErrorCode.MISSING_EXTENSION_DATA; import static org.gridsuite.shortcircuit.server.service.ShortCircuitResultContext.HEADER_BUS_ID; /** @@ -199,7 +201,7 @@ public void postRun(ShortCircuitRunContext runContext, AtomicReference resultContext, Exception exception, AtomicReference rootReporter) { - if (exception instanceof ShortCircuitException shortCircuitException && shortCircuitException.getType() == INCONSISTENT_VOLTAGE_LEVELS) { + if (exception instanceof ShortCircuitException shortCircuitException && shortCircuitException.getBusinessErrorCode() == INCONSISTENT_VOLTAGE_LEVELS) { postRun(resultContext.getRunContext(), rootReporter, null); sendResultMessage(resultContext, null); } diff --git a/src/test/java/org/gridsuite/shortcircuit/server/PropertyServerNameProviderTest.java b/src/test/java/org/gridsuite/shortcircuit/server/PropertyServerNameProviderTest.java new file mode 100644 index 00000000..95b93dbd --- /dev/null +++ b/src/test/java/org/gridsuite/shortcircuit/server/PropertyServerNameProviderTest.java @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.gridsuite.shortcircuit.server; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Mohamed Ben-rejeb {@literal } + */ +class PropertyServerNameProviderTest { + + @Test + void returnsProvidedName() { + PropertyServerNameProvider provider = new PropertyServerNameProvider("custom-server"); + assertThat(provider.serverName()).isEqualTo("custom-server"); + } +} diff --git a/src/test/java/org/gridsuite/shortcircuit/server/ShortCircuitParametersControllerTest.java b/src/test/java/org/gridsuite/shortcircuit/server/ShortCircuitParametersControllerTest.java index 6167aced..dc99d723 100644 --- a/src/test/java/org/gridsuite/shortcircuit/server/ShortCircuitParametersControllerTest.java +++ b/src/test/java/org/gridsuite/shortcircuit/server/ShortCircuitParametersControllerTest.java @@ -32,15 +32,20 @@ import java.util.UUID; import java.util.stream.Stream; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @ExtendWith({ MockitoExtension.class }) -@WebMvcTest(controllers = { ShortCircuitParametersController.class }) +@WebMvcTest(controllers = { ShortCircuitParametersController.class, PropertyServerNameProvider.class }) class ShortCircuitParametersControllerTest implements WithAssertions { private final String defaultParametersJson; diff --git a/src/test/java/org/gridsuite/shortcircuit/server/ShortCircuitParametersITest.java b/src/test/java/org/gridsuite/shortcircuit/server/ShortCircuitParametersITest.java index 9cbb82cb..622e73a6 100644 --- a/src/test/java/org/gridsuite/shortcircuit/server/ShortCircuitParametersITest.java +++ b/src/test/java/org/gridsuite/shortcircuit/server/ShortCircuitParametersITest.java @@ -55,9 +55,13 @@ import static org.hamcrest.Matchers.matchesPattern; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.log; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest @@ -270,21 +274,31 @@ void duplicateParameters() throws Exception { @ParameterizedTest @MethodSource("testWithInvalidParametersArgArgs") - void testWithInvalidParametersArg(final RequestBuilder requestBuilder, final ResultMatcher statusResult) throws Exception { - mockMvc.perform(requestBuilder).andDo(log()) - .andExpectAll(statusResult, content().bytes(new byte[0])); + void testWithInvalidParametersArg(final RequestBuilder requestBuilder, final ResultMatcher statusResult, final boolean throwsException, final Integer expectedStatus) throws Exception { + if (!throwsException) { + mockMvc.perform(requestBuilder).andDo(log()) + .andExpectAll(statusResult, content().bytes(new byte[0])); + } else { + mockMvc.perform(requestBuilder).andDo(log()) + .andExpectAll(statusResult, content().contentType(MediaType.APPLICATION_PROBLEM_JSON), + jsonPath("$.status").value(expectedStatus), + jsonPath("$.server").exists(), + jsonPath("$.path").exists(), + jsonPath("$.detail").exists(), + jsonPath("$.timestamp").exists()); + } } private static Stream testWithInvalidParametersArgArgs() { return Stream.of( - Arguments.of(get("/v1/parameters/{parametersUuid}", UUID.randomUUID()), status().isNotFound()), - Arguments.of(delete("/v1/parameters/{parametersUuid}", UUID.randomUUID()), status().isNotFound()), - Arguments.of(post("/v1/parameters"), status().isBadRequest()), - Arguments.of(post("/v1/parameters").content("{}"), status().isBadRequest()), - Arguments.of(post("/v1/parameters").contentType(MediaType.TEXT_PLAIN).content("{}"), status().isBadRequest()), - Arguments.of(post("/v1/parameters").queryParam(DUPLICATE_FROM, ""), status().isBadRequest()), - Arguments.of(post("/v1/parameters").queryParam(DUPLICATE_FROM, UUID.randomUUID().toString()), status().isNotFound()), - Arguments.of(put("/v1/parameters/{parametersUuid}", UUID.randomUUID()), status().isNotFound()) + Arguments.of(get("/v1/parameters/{parametersUuid}", UUID.randomUUID()), status().isNotFound(), false, null), + Arguments.of(delete("/v1/parameters/{parametersUuid}", UUID.randomUUID()), status().isNotFound(), false, null), + Arguments.of(post("/v1/parameters"), status().isInternalServerError(), true, 500), + Arguments.of(post("/v1/parameters").content("{}"), status().isInternalServerError(), true, 500), + Arguments.of(post("/v1/parameters").contentType(MediaType.TEXT_PLAIN).content("{}"), status().isInternalServerError(), true, 500), + Arguments.of(post("/v1/parameters").queryParam(DUPLICATE_FROM, ""), status().isInternalServerError(), true, 500), + Arguments.of(post("/v1/parameters").queryParam(DUPLICATE_FROM, UUID.randomUUID().toString()), status().isNotFound(), false, null), + Arguments.of(put("/v1/parameters/{parametersUuid}", UUID.randomUUID()), status().isNotFound(), false, null) ); } } From 79bfaa1e17f91ac854df077264818918fa6a05b0 Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 13 Nov 2025 17:05:51 +0100 Subject: [PATCH 2/3] Remove dep --- pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pom.xml b/pom.xml index 10f289bb..cf90e6bd 100644 --- a/pom.xml +++ b/pom.xml @@ -115,13 +115,6 @@ - - com.rte-france.powsybl - powsybl-courcirc-integration - 4.10.2 - runtime - - org.projectlombok From 7deb2a397098b137bc06da5e95fa39981e8ccb3e Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 13 Nov 2025 17:17:27 +0100 Subject: [PATCH 3/3] Add ShortcircuitBusinessErrorCodeTest --- .../ShortcircuitBusinessErrorCodeTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/java/org/gridsuite/shortcircuit/server/ShortcircuitBusinessErrorCodeTest.java diff --git a/src/test/java/org/gridsuite/shortcircuit/server/ShortcircuitBusinessErrorCodeTest.java b/src/test/java/org/gridsuite/shortcircuit/server/ShortcircuitBusinessErrorCodeTest.java new file mode 100644 index 00000000..ba4be57f --- /dev/null +++ b/src/test/java/org/gridsuite/shortcircuit/server/ShortcircuitBusinessErrorCodeTest.java @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2025, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.gridsuite.shortcircuit.server; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; + +import static org.assertj.core.api.Assertions.assertThat; +/** + * @author Hugo Marcellin + */ + +public class ShortcircuitBusinessErrorCodeTest { + @ParameterizedTest + @EnumSource(ShortcircuitBusinessErrorCode.class) + void valueMatchesEnumName(ShortcircuitBusinessErrorCode code) { + assertThat(code.value()).startsWith("shortcircuit."); + } +}