From c8f95e477677af1fb27666a7b6e84f2f5960dd04 Mon Sep 17 00:00:00 2001 From: klesaulnier <42617371+archendel@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:15:33 +0200 Subject: [PATCH] Add a request param to target one of the 3 security-analysis-server endpoints (#454) Signed-off-by: LE SAULNIER Kevin --- .../study/server/StudyController.java | 6 ++- .../service/SecurityAnalysisService.java | 17 +++++-- .../study/server/service/StudyService.java | 19 ++++--- .../SecurityAnalysisResultType.java | 16 ++++++ .../study/server/SecurityAnalysisTest.java | 49 +++++++++++++++---- 5 files changed, 81 insertions(+), 26 deletions(-) create mode 100644 src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java diff --git a/src/main/java/org/gridsuite/study/server/StudyController.java b/src/main/java/org/gridsuite/study/server/StudyController.java index 45ff805a1..884d6b705 100644 --- a/src/main/java/org/gridsuite/study/server/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/StudyController.java @@ -32,6 +32,7 @@ import org.gridsuite.study.server.networkmodificationtree.dto.RootNode; 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.springframework.data.domain.Pageable; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType; @@ -777,9 +778,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/SecurityAnalysisService.java b/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java index 6b79ee18c..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,6 +21,7 @@ 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.securityanalysis.SecurityAnalysisResultType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.*; import org.springframework.stereotype.Service; @@ -62,14 +63,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 +79,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 +94,14 @@ public String getSecurityAnalysisResult(UUID nodeUuid, List limitTypes) return result; } + private String getPathFromResultType(SecurityAnalysisResultType resultType) { + 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, String receiver) { var uriComponentsBuilder = UriComponentsBuilder 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 75876284f..1a88e6dd3 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1461,17 +1461,16 @@ private void invalidateBuild(UUID studyUuid, UUID nodeUuid, boolean invalidateOn } 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 new file mode 100644 index 000000000..2017fd75d --- /dev/null +++ b/src/main/java/org/gridsuite/study/server/service/securityanalysis/SecurityAnalysisResultType.java @@ -0,0 +1,16 @@ +/** + * 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, + NMK_CONTINGENCIES, + NMK_LIMIT_VIOLATIONS +} diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index cc173eb65..402a0ef86 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.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.dto.ComputationType; import org.gridsuite.study.server.utils.TestUtils; @@ -85,7 +86,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\"}]}]"; @@ -191,9 +194,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-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-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-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)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_STATUS_JSON) .addHeader("Content-Type", "application/json; charset=utf-8"); @@ -210,8 +219,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-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-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-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)) { return new MockResponse().setResponseCode(200).setBody(SECURITY_ANALYSIS_STATUS_JSON) @@ -440,12 +455,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-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( + status().isOk(), + content().string(SECURITY_ANALYSIS_NMK_CONTINGENCIES_RESULT_JSON)); + + 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?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(