From 862997b3efc11228396e0127dcdd4ed64e26f24f Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Mon, 9 Oct 2023 17:12:53 +0200 Subject: [PATCH 01/11] feat: add a way to target one of the 3 AS-server endpoints Signed-off-by: LE SAULNIER Kevin --- .../study/server/StudyController.java | 7 ++++-- .../study/server/service/StudyService.java | 1 + .../server/service/SupervisionService.java | 1 + .../SecurityAnalysisResultType.java | 7 ++++++ .../SecurityAnalysisService.java | 22 ++++++++++++++----- .../study/server/NetworkModificationTest.java | 1 + .../server/NetworkModificationTreeTest.java | 1 + .../study/server/SecurityAnalysisTest.java | 1 + .../org/gridsuite/study/server/StudyTest.java | 1 + .../study/server/VoltageInitTest.java | 1 + 10 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java rename src/main/java/org/gridsuite/study/server/service/{ => securityanalysis}/SecurityAnalysisService.java (92%) diff --git a/src/main/java/org/gridsuite/study/server/StudyController.java b/src/main/java/org/gridsuite/study/server/StudyController.java index f7674077d..dfdc3b13f 100644 --- a/src/main/java/org/gridsuite/study/server/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/StudyController.java @@ -31,6 +31,8 @@ import org.gridsuite.study.server.networkmodificationtree.dto.NetworkModificationNode; import org.gridsuite.study.server.networkmodificationtree.dto.RootNode; import org.gridsuite.study.server.service.*; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisResultType; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.springframework.data.domain.Pageable; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType; @@ -775,9 +777,10 @@ public ResponseEntity runSecurityAnalysis(@Parameter(description = "studyU @ApiResponse(responseCode = "404", description = "The security analysis has not been found")}) public ResponseEntity getSecurityAnalysisResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid, - @Parameter(description = "Limit types") @RequestParam(name = "limitType", required = false) List limitTypes) { + @Parameter(description = "Limit types") @RequestParam(name = "limitType", required = false) List limitTypes, + @Parameter(description = "result type") @RequestParam(name = "resultType") SecurityAnalysisResultType resultType) { List nonNullLimitTypes = limitTypes != null ? limitTypes : Collections.emptyList(); - String result = securityAnalysisService.getSecurityAnalysisResult(nodeUuid, nonNullLimitTypes); + String result = securityAnalysisService.getSecurityAnalysisResult(nodeUuid, resultType, nonNullLimitTypes); return result != null ? ResponseEntity.ok().body(result) : ResponseEntity.noContent().build(); } diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index a434874c2..f4cfa3b80 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -44,6 +44,7 @@ import org.gridsuite.study.server.repository.*; import org.gridsuite.study.server.repository.sensianalysis.SensitivityAnalysisParametersEntity; import org.gridsuite.study.server.service.dynamicsimulation.DynamicSimulationService; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType; import org.gridsuite.study.server.utils.PropertyUtils; diff --git a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java index 57e34c3cd..46602c0b1 100644 --- a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java +++ b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java @@ -14,6 +14,7 @@ import org.gridsuite.study.server.repository.StudyRepository; import org.gridsuite.study.server.repository.networkmodificationtree.NetworkModificationNodeInfoRepository; import org.gridsuite.study.server.service.dynamicsimulation.DynamicSimulationService; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java new file mode 100644 index 000000000..3049a645a --- /dev/null +++ b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java @@ -0,0 +1,7 @@ +package org.gridsuite.study.server.service.securityanalysis; + +public enum SecurityAnalysisResultType { + N, + NMK_CONTINGENCIES, + NMK_CONSTRAINTS +} diff --git a/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java similarity index 92% rename from src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java rename to src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java index 6b79ee18c..310984ca3 100644 --- a/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java +++ b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package org.gridsuite.study.server.service; +package org.gridsuite.study.server.service.securityanalysis; /** * @author Kevin Le Saulnier @@ -21,6 +21,8 @@ import org.gridsuite.study.server.dto.SecurityAnalysisParametersValues; import org.gridsuite.study.server.dto.SecurityAnalysisStatus; import org.gridsuite.study.server.repository.SecurityAnalysisParametersEntity; +import org.gridsuite.study.server.service.NetworkModificationTreeService; +import org.gridsuite.study.server.service.RemoteServicesProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.*; import org.springframework.stereotype.Service; @@ -62,14 +64,14 @@ public class SecurityAnalysisService { @Autowired public SecurityAnalysisService(RemoteServicesProperties remoteServicesProperties, - NetworkModificationTreeService networkModificationTreeService, - ObjectMapper objectMapper) { + NetworkModificationTreeService networkModificationTreeService, + ObjectMapper objectMapper) { this.securityAnalysisServerBaseUri = remoteServicesProperties.getServiceUri("security-analysis-server"); this.networkModificationTreeService = networkModificationTreeService; this.objectMapper = objectMapper; } - public String getSecurityAnalysisResult(UUID nodeUuid, List limitTypes) { + public String getSecurityAnalysisResult(UUID nodeUuid, SecurityAnalysisResultType resultType, List limitTypes) { Objects.requireNonNull(limitTypes); String result; Optional resultUuidOpt = networkModificationTreeService.getSecurityAnalysisResultUuid(nodeUuid); @@ -78,7 +80,7 @@ public String getSecurityAnalysisResult(UUID nodeUuid, List limitTypes) return null; } - String path = UriComponentsBuilder.fromPath(DELIMITER + SECURITY_ANALYSIS_API_VERSION + "/results/{resultUuid}") + String path = UriComponentsBuilder.fromPath(DELIMITER + SECURITY_ANALYSIS_API_VERSION + "/results/{resultUuid}/" + getPathFromResultType(resultType)) .queryParam("limitType", limitTypes).buildAndExpand(resultUuidOpt.get()).toUriString(); try { result = restTemplate.getForObject(securityAnalysisServerBaseUri + path, String.class); @@ -93,6 +95,16 @@ public String getSecurityAnalysisResult(UUID nodeUuid, List limitTypes) return result; } + private String getPathFromResultType(SecurityAnalysisResultType resultType) { + switch (resultType) { + case N : return "n"; + case NMK_CONTINGENCIES : return "nmk-contingencies"; + case NMK_CONSTRAINTS : return "nmk-constraints"; + default: + return null; + } + } + public UUID runSecurityAnalysis(UUID networkUuid, UUID reportUuid, UUID nodeUuid, String variantId, String provider, List contingencyListNames, SecurityAnalysisParametersInfos securityAnalysisParameters, String receiver) { var uriComponentsBuilder = UriComponentsBuilder diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java index df26d8470..53800b22e 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java @@ -42,6 +42,7 @@ import org.gridsuite.study.server.repository.StudyEntity; import org.gridsuite.study.server.repository.StudyRepository; import org.gridsuite.study.server.service.*; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.utils.*; import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java index 7b670ae77..83e68d37c 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java @@ -42,6 +42,7 @@ import org.gridsuite.study.server.repository.networkmodificationtree.NodeRepository; import org.gridsuite.study.server.repository.networkmodificationtree.RootNodeInfoRepository; import org.gridsuite.study.server.service.*; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.utils.TestUtils; import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index cc173eb65..27592f40a 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -31,6 +31,7 @@ import org.gridsuite.study.server.repository.sensianalysis.SensitivityAnalysisParametersEntity; import org.gridsuite.study.server.repository.networkmodificationtree.NetworkModificationNodeInfoRepository; import org.gridsuite.study.server.service.*; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.dto.ComputationType; import org.gridsuite.study.server.utils.TestUtils; diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index 482f0b35a..43e01dcb9 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -45,6 +45,7 @@ import org.gridsuite.study.server.repository.StudyEntity; import org.gridsuite.study.server.repository.StudyRepository; import org.gridsuite.study.server.service.*; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.utils.*; import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; import org.jetbrains.annotations.NotNull; diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 30adcd9d9..03267eae1 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -32,6 +32,7 @@ import org.gridsuite.study.server.repository.networkmodificationtree.NetworkModificationNodeInfoRepository; import org.gridsuite.study.server.repository.sensianalysis.SensitivityAnalysisParametersEntity; import org.gridsuite.study.server.service.*; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.dto.ComputationType; import org.gridsuite.study.server.utils.TestUtils; From d8de1ce9abb970c23ca7c57776a33adc9969c5a6 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Tue, 10 Oct 2023 10:14:14 +0200 Subject: [PATCH 02/11] fix: fix tests to match new api calls Signed-off-by: LE SAULNIER Kevin --- .../study/server/SecurityAnalysisTest.java | 49 +++++++++++++++---- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index 27592f40a..e6faf752e 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -31,6 +31,7 @@ import org.gridsuite.study.server.repository.sensianalysis.SensitivityAnalysisParametersEntity; import org.gridsuite.study.server.repository.networkmodificationtree.NetworkModificationNodeInfoRepository; import org.gridsuite.study.server.service.*; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisResultType; import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.dto.ComputationType; @@ -86,7 +87,9 @@ public class SecurityAnalysisTest { private static final String SECURITY_ANALYSIS_ERROR_NODE_RESULT_UUID = "22222222-9594-4e55-8ec7-07ea965d24eb"; private static final String NOT_FOUND_SECURITY_ANALYSIS_UUID = "e3a85c9b-9594-4e55-8ec7-07ea965d24eb"; private static final String CONTINGENCY_LIST_NAME = "ls"; - private static final String SECURITY_ANALYSIS_RESULT_JSON = "{\"version\":\"1.0\",\"preContingencyResult\":{\"computationOk\":true,\"limitViolations\":[{\"subjectId\":\"l3\",\"limitType\":\"CURRENT\",\"acceptableDuration\":1200,\"limit\":10.0,\"limitReduction\":1.0,\"value\":11.0,\"side\":\"ONE\"}],\"actionsTaken\":[]},\"postContingencyResults\":[{\"contingency\":{\"id\":\"l1\",\"elements\":[{\"id\":\"l1\",\"type\":\"BRANCH\"}]},\"limitViolationsResult\":{\"computationOk\":true,\"limitViolations\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"acceptableDuration\":0,\"limit\":400.0,\"limitReduction\":1.0,\"value\":410.0}],\"actionsTaken\":[]}},{\"contingency\":{\"id\":\"l2\",\"elements\":[{\"id\":\"l2\",\"type\":\"BRANCH\"}]},\"limitViolationsResult\":{\"computationOk\":true,\"limitViolations\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"acceptableDuration\":0,\"limit\":400.0,\"limitReduction\":1.0,\"value\":410.0}],\"actionsTaken\":[]}}]}"; + private static final String SECURITY_ANALYSIS_N_RESULT_JSON = "{\"status\":\"CONVERGED\",\"limitViolationsResult\":{\"limitViolations\":[{\"subjectId\":\"l3\",\"limitType\":\"CURRENT\",\"acceptableDuration\":1200,\"limit\":10.0,\"limitReduction\":1.0,\"value\":11.0,\"side\":\"ONE\"}],\"actionsTaken\":[]},\"networkResult\":{\"branchResults\":[],\"busResults\":[],\"threeWindingsTransformerResults\":[]}}"; + private static final String SECURITY_ANALYSIS_NMK_CONTINGENCIES_RESULT_JSON = "[{\"id\":\"l1\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l1\",\"elementType\":\"BRANCH\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"l2\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l2\",\"elementType\":\"GENERATOR\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"l3\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l3\",\"elementType\":\"BUSBAR_SECTION\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"l4\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l4\",\"elementType\":\"LINE\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"l6\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l6\",\"elementType\":\"HVDC_LINE\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"l7\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l7\",\"elementType\":\"DANGLING_LINE\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"l8\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l8\",\"elementType\":\"SHUNT_COMPENSATOR\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"l9\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l9\",\"elementType\":\"TWO_WINDINGS_TRANSFORMER\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"la\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"l0\",\"elementType\":\"THREE_WINDINGS_TRANSFORMER\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]},{\"id\":\"lb\",\"status\":\"CONVERGED\",\"elements\":[{\"id\":\"la\",\"elementType\":\"STATIC_VAR_COMPENSATOR\"}],\"constraints\":[{\"subjectId\":\"vl1\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0}]}]"; + private static final String SECURITY_ANALYSIS_NMK_CONSTRAINTS_RESULT_JSON = "[{\"constraintId\":\"l3\",\"contingencies\":[]},{\"constraintId\":\"vl1\",\"contingencies\":[{\"contingencyId\":\"l1\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l1\",\"elementType\":\"BRANCH\"}]},{\"contingencyId\":\"l2\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l2\",\"elementType\":\"GENERATOR\"}]},{\"contingencyId\":\"l3\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l3\",\"elementType\":\"BUSBAR_SECTION\"}]},{\"contingencyId\":\"l4\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l4\",\"elementType\":\"LINE\"}]},{\"contingencyId\":\"l6\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l6\",\"elementType\":\"HVDC_LINE\"}]},{\"contingencyId\":\"l7\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l7\",\"elementType\":\"DANGLING_LINE\"}]},{\"contingencyId\":\"l8\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l8\",\"elementType\":\"SHUNT_COMPENSATOR\"}]},{\"contingencyId\":\"l9\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l9\",\"elementType\":\"TWO_WINDINGS_TRANSFORMER\"}]},{\"contingencyId\":\"la\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"l0\",\"elementType\":\"THREE_WINDINGS_TRANSFORMER\"}]},{\"contingencyId\":\"lb\",\"computationStatus\":\"CONVERGED\",\"limitType\":\"HIGH_VOLTAGE\",\"limitName\":\"\",\"side\":null,\"acceptableDuration\":0,\"limit\":400.0,\"value\":410.0,\"elements\":[{\"id\":\"la\",\"elementType\":\"STATIC_VAR_COMPENSATOR\"}]}]}]"; private static final String SECURITY_ANALYSIS_STATUS_JSON = "\"CONVERGED\""; private static final String CONTINGENCIES_JSON = "[{\"id\":\"l1\",\"elements\":[{\"id\":\"l1\",\"type\":\"BRANCH\"}]}]"; @@ -192,9 +195,15 @@ public MockResponse dispatch(RecordedRequest request) { .build(), saResultDestination); return new MockResponse().setResponseCode(200).setBody("\"" + resultUuid + "\"") .addHeader("Content-Type", "application/json; charset=utf-8"); - } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "?limitType").equals(path)) { - return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_RESULT_JSON) - .addHeader("Content-Type", "application/json; charset=utf-8"); + } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/n?limitType").equals(path)) { + return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_N_RESULT_JSON) + .addHeader("Content-Type", "application/json; charset=utf-8"); + } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/nmk-contingencies?limitType").equals(path)) { + return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_NMK_CONTINGENCIES_RESULT_JSON) + .addHeader("Content-Type", "application/json; charset=utf-8"); + } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/nmk-constraints?limitType").equals(path)) { + return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_NMK_CONSTRAINTS_RESULT_JSON) + .addHeader("Content-Type", "application/json; charset=utf-8"); } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/status").equals(path)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_STATUS_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); @@ -211,8 +220,14 @@ public MockResponse dispatch(RecordedRequest request) { || path.matches("/v1/contingency-lists/" + CONTINGENCY_LIST_NAME + "/export\\?networkUuid=" + NETWORK_UUID_STRING + "&variantId=.*")) { return new MockResponse().setResponseCode(200).setBody(CONTINGENCIES_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); - } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "?limitType").equals(path)) { - return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_RESULT_JSON) + } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/n?limitType").equals(path)) { + return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_N_RESULT_JSON) + .addHeader("Content-Type", "application/json; charset=utf-8"); + } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/nmk-contingencies?limitType").equals(path)) { + return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_NMK_CONTINGENCIES_RESULT_JSON) + .addHeader("Content-Type", "application/json; charset=utf-8"); + } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/nmk-constraints?limitType").equals(path)) { + return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_NMK_CONSTRAINTS_RESULT_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/status").equals(path)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_STATUS_JSON) @@ -441,12 +456,26 @@ private void testSecurityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, UUI assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save.*contingencyListName=" + CONTINGENCY_LIST_NAME + "&receiver=.*nodeUuid.*"))); - // get security analysis result - mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result", studyUuid, nodeUuid)).andExpectAll( + // get N security analysis result + mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result?resultType={resultType}", studyUuid, nodeUuid, SecurityAnalysisResultType.N)).andExpectAll( status().isOk(), - content().string(SECURITY_ANALYSIS_RESULT_JSON)); + content().string(SECURITY_ANALYSIS_N_RESULT_JSON)); + + assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/n?limitType", resultUuid))); + + // get NMK_CONTINGENCIES security analysis result + mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result?resultType={resultType}", studyUuid, nodeUuid, SecurityAnalysisResultType.NMK_CONTINGENCIES)).andExpectAll( + status().isOk(), + content().string(SECURITY_ANALYSIS_NMK_CONTINGENCIES_RESULT_JSON)); + + assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/nmk-contingencies?limitType", resultUuid))); + + // get NMK_CONSTRAINTS security analysis result + mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result?resultType={resultType}", studyUuid, nodeUuid, SecurityAnalysisResultType.NMK_CONSTRAINTS)).andExpectAll( + status().isOk(), + content().string(SECURITY_ANALYSIS_NMK_CONSTRAINTS_RESULT_JSON)); - assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s?limitType", resultUuid))); + assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/nmk-constraints?limitType", resultUuid))); // get security analysis status MvcResult result = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/status", studyUuid, nodeUuid)).andExpectAll( From 5b4f965b06a242553cd95360583b8f07d0820055 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Tue, 10 Oct 2023 10:40:12 +0200 Subject: [PATCH 03/11] fix: change switch to improve coverage Signed-off-by: LE SAULNIER Kevin --- .../service/securityanalysis/SecurityAnalysisService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java index 310984ca3..fcaee3bff 100644 --- a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java +++ b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java @@ -97,11 +97,9 @@ public String getSecurityAnalysisResult(UUID nodeUuid, SecurityAnalysisResultTyp private String getPathFromResultType(SecurityAnalysisResultType resultType) { switch (resultType) { - case N : return "n"; case NMK_CONTINGENCIES : return "nmk-contingencies"; case NMK_CONSTRAINTS : return "nmk-constraints"; - default: - return null; + default: return "n"; //N case } } From 311e7dadf6f7bd68e26283533c30906a3f0b58d8 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Thu, 12 Oct 2023 12:49:49 +0200 Subject: [PATCH 04/11] fix: PR remarks Signed-off-by: LE SAULNIER Kevin --- .../study/server/service/StudyService.java | 20 +++++++++---------- .../SecurityAnalysisResultType.java | 9 +++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index f4cfa3b80..fd8d55912 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1460,18 +1460,18 @@ private void invalidateBuild(UUID studyUuid, UUID nodeUuid, boolean invalidateOn networkModificationTreeService.invalidateBuild(nodeUuid, invalidateOnlyChildrenBuildStatus, invalidateNodeInfos); } + CompletableFuture executeInParallel = CompletableFuture.allOf( - studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getReportUuids().forEach(reportService::deleteReport)), // TODO delete all with one request only - studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getLoadFlowResultUuids().forEach(loadflowService::deleteLoadFlowResult)), - studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getSecurityAnalysisResultUuids().forEach(securityAnalysisService::deleteSaResult)), - studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getSensitivityAnalysisResultUuids().forEach(sensitivityAnalysisService::deleteSensitivityAnalysisResult)), - studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getShortCircuitAnalysisResultUuids().forEach(shortCircuitService::deleteShortCircuitAnalysisResult)), - studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getOneBusShortCircuitAnalysisResultUuids().forEach(shortCircuitService::deleteShortCircuitAnalysisResult)), - studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getVoltageInitResultUuids().forEach(voltageInitService::deleteVoltageInitResult)), - studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getDynamicSimulationResultUuids().forEach(dynamicSimulationService::deleteResult)), - studyServerExecutionService.runAsync(() -> networkStoreService.deleteVariants(invalidateNodeInfos.getNetworkUuid(), invalidateNodeInfos.getVariantIds())) + studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getReportUuids().forEach(reportService::deleteReport)), // TODO delete all with one request only + studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getLoadFlowResultUuids().forEach(loadflowService::deleteLoadFlowResult)), + studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getSecurityAnalysisResultUuids().forEach(securityAnalysisService::deleteSaResult)), + studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getSensitivityAnalysisResultUuids().forEach(sensitivityAnalysisService::deleteSensitivityAnalysisResult)), + studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getShortCircuitAnalysisResultUuids().forEach(shortCircuitService::deleteShortCircuitAnalysisResult)), + studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getOneBusShortCircuitAnalysisResultUuids().forEach(shortCircuitService::deleteShortCircuitAnalysisResult)), + studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getVoltageInitResultUuids().forEach(voltageInitService::deleteVoltageInitResult)), + studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getDynamicSimulationResultUuids().forEach(dynamicSimulationService::deleteResult)), + studyServerExecutionService.runAsync(() -> networkStoreService.deleteVariants(invalidateNodeInfos.getNetworkUuid(), invalidateNodeInfos.getVariantIds())) ); - try { executeInParallel.get(); } catch (Exception e) { diff --git a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java index 3049a645a..95c46ba17 100644 --- a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java +++ b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java @@ -1,4 +1,13 @@ +/** + * Copyright (c) 2023, 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.study.server.service.securityanalysis; +/** + * @author Kevin Le Saulnier + */ public enum SecurityAnalysisResultType { N, From ffab7cfbc03e7dd2714b90783835d0493da1e79e Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Thu, 12 Oct 2023 12:52:20 +0200 Subject: [PATCH 05/11] fix: match sa-server endpoint Signed-off-by: LE SAULNIER Kevin --- .../service/securityanalysis/SecurityAnalysisService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java index fcaee3bff..23758ffee 100644 --- a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java +++ b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java @@ -97,9 +97,9 @@ public String getSecurityAnalysisResult(UUID nodeUuid, SecurityAnalysisResultTyp private String getPathFromResultType(SecurityAnalysisResultType resultType) { switch (resultType) { - case NMK_CONTINGENCIES : return "nmk-contingencies"; - case NMK_CONSTRAINTS : return "nmk-constraints"; - default: return "n"; //N case + case NMK_CONTINGENCIES : return "nmk-contingencies-result"; + case NMK_CONSTRAINTS : return "nmk-constraints-result"; + default: return "n-result"; //N case } } From a2f8a51154e74969cba17b1f4337ed6534010833 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Fri, 20 Oct 2023 09:01:44 +0200 Subject: [PATCH 06/11] fix: PR remark Signed-off-by: LE SAULNIER Kevin --- .../securityanalysis/SecurityAnalysisResultType.java | 2 +- .../securityanalysis/SecurityAnalysisService.java | 10 +++++----- .../gridsuite/study/server/SecurityAnalysisTest.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java index 95c46ba17..2017fd75d 100644 --- a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java +++ b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java @@ -12,5 +12,5 @@ public enum SecurityAnalysisResultType { N, NMK_CONTINGENCIES, - NMK_CONSTRAINTS + NMK_LIMIT_VIOLATIONS } diff --git a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java index 23758ffee..f2be1a1c5 100644 --- a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java +++ b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java @@ -96,11 +96,11 @@ public String getSecurityAnalysisResult(UUID nodeUuid, SecurityAnalysisResultTyp } private String getPathFromResultType(SecurityAnalysisResultType resultType) { - switch (resultType) { - case NMK_CONTINGENCIES : return "nmk-contingencies-result"; - case NMK_CONSTRAINTS : return "nmk-constraints-result"; - default: return "n-result"; //N case - } + return switch (resultType) { + case NMK_CONTINGENCIES -> "nmk-contingencies-result"; + case NMK_LIMIT_VIOLATIONS -> "nmk-constraints-result"; + case N -> "n-result"; + }; } public UUID runSecurityAnalysis(UUID networkUuid, UUID reportUuid, UUID nodeUuid, String variantId, String provider, List contingencyListNames, SecurityAnalysisParametersInfos securityAnalysisParameters, diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index e6faf752e..787f84493 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -471,7 +471,7 @@ private void testSecurityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, UUI assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/nmk-contingencies?limitType", resultUuid))); // get NMK_CONSTRAINTS security analysis result - mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result?resultType={resultType}", studyUuid, nodeUuid, SecurityAnalysisResultType.NMK_CONSTRAINTS)).andExpectAll( + mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result?resultType={resultType}", studyUuid, nodeUuid, SecurityAnalysisResultType.NMK_LIMIT_VIOLATIONS)).andExpectAll( status().isOk(), content().string(SECURITY_ANALYSIS_NMK_CONSTRAINTS_RESULT_JSON)); From 8c40c6dcaeacd5538744b873506aba33f433678e Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Fri, 20 Oct 2023 09:05:32 +0200 Subject: [PATCH 07/11] fix: checkstyle Signed-off-by: LE SAULNIER Kevin --- .../java/org/gridsuite/study/server/service/StudyService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index fd8d55912..1a1f1f6b7 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1460,7 +1460,6 @@ private void invalidateBuild(UUID studyUuid, UUID nodeUuid, boolean invalidateOn networkModificationTreeService.invalidateBuild(nodeUuid, invalidateOnlyChildrenBuildStatus, invalidateNodeInfos); } - CompletableFuture executeInParallel = CompletableFuture.allOf( studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getReportUuids().forEach(reportService::deleteReport)), // TODO delete all with one request only studyServerExecutionService.runAsync(() -> invalidateNodeInfos.getLoadFlowResultUuids().forEach(loadflowService::deleteLoadFlowResult)), From d1e869064246bd58326c82c97d5e10b129934bc0 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Fri, 20 Oct 2023 09:21:02 +0200 Subject: [PATCH 08/11] fix: test Signed-off-by: LE SAULNIER Kevin --- .../java/org/gridsuite/study/server/SecurityAnalysisTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index 787f84493..53b9e6b81 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -461,7 +461,7 @@ private void testSecurityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, UUI status().isOk(), content().string(SECURITY_ANALYSIS_N_RESULT_JSON)); - assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/n?limitType", resultUuid))); + assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/n-result?limitType", resultUuid))); // get NMK_CONTINGENCIES security analysis result mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result?resultType={resultType}", studyUuid, nodeUuid, SecurityAnalysisResultType.NMK_CONTINGENCIES)).andExpectAll( From b415b34620cb05c3a152ea148e6cdb4e5f6fc7f2 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Fri, 20 Oct 2023 11:07:55 +0200 Subject: [PATCH 09/11] fix: tests Signed-off-by: LE SAULNIER Kevin --- .../study/server/SecurityAnalysisTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index 53b9e6b81..9cb92f52d 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -195,13 +195,13 @@ public MockResponse dispatch(RecordedRequest request) { .build(), saResultDestination); return new MockResponse().setResponseCode(200).setBody("\"" + resultUuid + "\"") .addHeader("Content-Type", "application/json; charset=utf-8"); - } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/n?limitType").equals(path)) { + } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/n-result?limitType").equals(path)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_N_RESULT_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); - } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/nmk-contingencies?limitType").equals(path)) { + } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/nmk-contingencies-result?limitType").equals(path)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_NMK_CONTINGENCIES_RESULT_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); - } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/nmk-constraints?limitType").equals(path)) { + } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/nmk-constraints-result?limitType").equals(path)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_NMK_CONSTRAINTS_RESULT_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); } else if (("/v1/results/" + SECURITY_ANALYSIS_RESULT_UUID + "/status").equals(path)) { @@ -220,13 +220,13 @@ public MockResponse dispatch(RecordedRequest request) { || path.matches("/v1/contingency-lists/" + CONTINGENCY_LIST_NAME + "/export\\?networkUuid=" + NETWORK_UUID_STRING + "&variantId=.*")) { return new MockResponse().setResponseCode(200).setBody(CONTINGENCIES_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); - } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/n?limitType").equals(path)) { + } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/n-result?limitType").equals(path)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_N_RESULT_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); - } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/nmk-contingencies?limitType").equals(path)) { + } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/nmk-contingencies-result?limitType").equals(path)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_NMK_CONTINGENCIES_RESULT_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); - } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/nmk-constraints?limitType").equals(path)) { + } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/nmk-constraints-result?limitType").equals(path)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_NMK_CONSTRAINTS_RESULT_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); } else if (("/v1/results/" + SECURITY_ANALYSIS_OTHER_NODE_RESULT_UUID + "/status").equals(path)) { @@ -468,14 +468,14 @@ private void testSecurityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, UUI status().isOk(), content().string(SECURITY_ANALYSIS_NMK_CONTINGENCIES_RESULT_JSON)); - assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/nmk-contingencies?limitType", resultUuid))); + assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/nmk-contingencies-result?limitType", resultUuid))); // get NMK_CONSTRAINTS security analysis result mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result?resultType={resultType}", studyUuid, nodeUuid, SecurityAnalysisResultType.NMK_LIMIT_VIOLATIONS)).andExpectAll( status().isOk(), content().string(SECURITY_ANALYSIS_NMK_CONSTRAINTS_RESULT_JSON)); - assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/nmk-constraints?limitType", resultUuid))); + assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/nmk-constraints-result?limitType", resultUuid))); // get security analysis status MvcResult result = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/status", studyUuid, nodeUuid)).andExpectAll( From 4d6842cf440473efd8fd7d879c49b1948dcfbac2 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Fri, 20 Oct 2023 13:53:09 +0200 Subject: [PATCH 10/11] fix: move file to prevent sonar coverage issue Signed-off-by: LE SAULNIER Kevin --- src/main/java/org/gridsuite/study/server/StudyController.java | 1 - .../{securityanalysis => }/SecurityAnalysisService.java | 3 ++- .../java/org/gridsuite/study/server/service/StudyService.java | 1 - .../org/gridsuite/study/server/service/SupervisionService.java | 1 - .../org/gridsuite/study/server/NetworkModificationTest.java | 1 - .../gridsuite/study/server/NetworkModificationTreeTest.java | 1 - .../java/org/gridsuite/study/server/SecurityAnalysisTest.java | 1 - src/test/java/org/gridsuite/study/server/StudyTest.java | 1 - src/test/java/org/gridsuite/study/server/VoltageInitTest.java | 1 - 9 files changed, 2 insertions(+), 9 deletions(-) rename src/main/java/org/gridsuite/study/server/service/{securityanalysis => }/SecurityAnalysisService.java (98%) diff --git a/src/main/java/org/gridsuite/study/server/StudyController.java b/src/main/java/org/gridsuite/study/server/StudyController.java index fcf4bd4de..884d6b705 100644 --- a/src/main/java/org/gridsuite/study/server/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/StudyController.java @@ -33,7 +33,6 @@ import org.gridsuite.study.server.dto.dynamicsimulation.event.EventInfos; import org.gridsuite.study.server.service.*; import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisResultType; -import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.springframework.data.domain.Pageable; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType; diff --git a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java b/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java similarity index 98% rename from src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java rename to src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java index f2be1a1c5..a1b282744 100644 --- a/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisService.java +++ b/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package org.gridsuite.study.server.service.securityanalysis; +package org.gridsuite.study.server.service; /** * @author Kevin Le Saulnier @@ -23,6 +23,7 @@ import org.gridsuite.study.server.repository.SecurityAnalysisParametersEntity; import org.gridsuite.study.server.service.NetworkModificationTreeService; import org.gridsuite.study.server.service.RemoteServicesProperties; +import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisResultType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.*; import org.springframework.stereotype.Service; diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index f337f821d..1a88e6dd3 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -44,7 +44,6 @@ import org.gridsuite.study.server.repository.sensianalysis.SensitivityAnalysisParametersEntity; import org.gridsuite.study.server.service.dynamicsimulation.DynamicSimulationEventService; import org.gridsuite.study.server.service.dynamicsimulation.DynamicSimulationService; -import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType; import org.gridsuite.study.server.utils.PropertyUtils; diff --git a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java index b710a05b6..22adca676 100644 --- a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java +++ b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java @@ -11,7 +11,6 @@ import org.gridsuite.study.server.networkmodificationtree.entities.NetworkModificationNodeInfoEntity; import org.gridsuite.study.server.repository.networkmodificationtree.NetworkModificationNodeInfoRepository; import org.gridsuite.study.server.service.dynamicsimulation.DynamicSimulationService; -import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java index 53800b22e..df26d8470 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java @@ -42,7 +42,6 @@ import org.gridsuite.study.server.repository.StudyEntity; import org.gridsuite.study.server.repository.StudyRepository; import org.gridsuite.study.server.service.*; -import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.utils.*; import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java index 83e68d37c..7b670ae77 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java @@ -42,7 +42,6 @@ import org.gridsuite.study.server.repository.networkmodificationtree.NodeRepository; import org.gridsuite.study.server.repository.networkmodificationtree.RootNodeInfoRepository; import org.gridsuite.study.server.service.*; -import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.utils.TestUtils; import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index 9cb92f52d..402a0ef86 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -32,7 +32,6 @@ import org.gridsuite.study.server.repository.networkmodificationtree.NetworkModificationNodeInfoRepository; import org.gridsuite.study.server.service.*; import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisResultType; -import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.dto.ComputationType; import org.gridsuite.study.server.utils.TestUtils; diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index d07100a9e..a0564d28c 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -45,7 +45,6 @@ import org.gridsuite.study.server.repository.StudyEntity; import org.gridsuite.study.server.repository.StudyRepository; import org.gridsuite.study.server.service.*; -import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.utils.*; import org.gridsuite.study.server.utils.elasticsearch.DisableElasticsearch; import org.jetbrains.annotations.NotNull; diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index bd9d2d361..7d6c46901 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -32,7 +32,6 @@ import org.gridsuite.study.server.repository.networkmodificationtree.NetworkModificationNodeInfoRepository; import org.gridsuite.study.server.repository.sensianalysis.SensitivityAnalysisParametersEntity; import org.gridsuite.study.server.service.*; -import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.dto.ComputationType; import org.gridsuite.study.server.utils.TestUtils; From ebcb5b4f676eabf956b9dd01907cf73fc489a229 Mon Sep 17 00:00:00 2001 From: LE SAULNIER Kevin Date: Fri, 20 Oct 2023 13:56:08 +0200 Subject: [PATCH 11/11] fix: checkstyle Signed-off-by: LE SAULNIER Kevin --- .../gridsuite/study/server/service/SecurityAnalysisService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java b/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java index a1b282744..850151545 100644 --- a/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java +++ b/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java @@ -21,8 +21,6 @@ import org.gridsuite.study.server.dto.SecurityAnalysisParametersValues; import org.gridsuite.study.server.dto.SecurityAnalysisStatus; import org.gridsuite.study.server.repository.SecurityAnalysisParametersEntity; -import org.gridsuite.study.server.service.NetworkModificationTreeService; -import org.gridsuite.study.server.service.RemoteServicesProperties; import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisResultType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.*;