diff --git a/src/main/java/org/gridsuite/study/server/controller/StudyController.java b/src/main/java/org/gridsuite/study/server/controller/StudyController.java index b3f4be47c..08c0a9eec 100644 --- a/src/main/java/org/gridsuite/study/server/controller/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/controller/StudyController.java @@ -22,9 +22,6 @@ import org.gridsuite.study.server.StudyApi; import org.gridsuite.study.server.dto.*; import org.gridsuite.study.server.dto.computation.LoadFlowComputationInfos; -import org.gridsuite.study.server.dto.dynamicmargincalculation.DynamicMarginCalculationStatus; -import org.gridsuite.study.server.dto.dynamicsecurityanalysis.DynamicSecurityAnalysisStatus; -import org.gridsuite.study.server.dto.dynamicsimulation.DynamicSimulationStatus; import org.gridsuite.study.server.dto.dynamicsimulation.event.EventInfos; import org.gridsuite.study.server.dto.elasticsearch.EquipmentInfos; import org.gridsuite.study.server.dto.modification.ModificationType; @@ -63,7 +60,7 @@ import java.util.*; import static org.gridsuite.study.server.StudyConstants.*; -import static org.gridsuite.study.server.dto.ComputationType.LOAD_FLOW; +import static org.gridsuite.study.server.dto.ComputationType.*; import static org.gridsuite.study.server.error.StudyBusinessErrorCode.MOVE_NETWORK_MODIFICATION_FORBIDDEN; /** @@ -804,9 +801,8 @@ public ResponseEntity getLoadflowResult(@Parameter(description = "study public ResponseEntity getLoadFlowStatus(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "rootNetworkUuid") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { - LoadFlowStatus result = rootNetworkNodeInfoService.getLoadFlowStatus(nodeUuid, rootNetworkUuid); - return result != null ? ResponseEntity.ok().body(result.name()) : - ResponseEntity.noContent().build(); + String result = rootNetworkNodeInfoService.getLoadFlowStatus(nodeUuid, rootNetworkUuid); + return result != null ? ResponseEntity.ok().body(result) : ResponseEntity.noContent().build(); } @GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/loadflow/computation-infos") @@ -1263,9 +1259,8 @@ public ResponseEntity generateNetworkAreaDiagram( public ResponseEntity getSecurityAnalysisStatus(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "rootNetworkUuid") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { - SecurityAnalysisStatus status = rootNetworkNodeInfoService.getSecurityAnalysisStatus(nodeUuid, rootNetworkUuid); - return status != null ? ResponseEntity.ok().body(status.name()) : - ResponseEntity.noContent().build(); + String status = rootNetworkNodeInfoService.getSecurityAnalysisStatus(nodeUuid, rootNetworkUuid); + return status != null ? ResponseEntity.ok().body(status) : ResponseEntity.noContent().build(); } @PutMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/security-analysis/stop") @@ -1995,9 +1990,8 @@ public ResponseEntity> getDynamicSimulationTimelineResu public ResponseEntity getDynamicSimulationStatus(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "rootNetworkUuid") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { - DynamicSimulationStatus result = rootNetworkNodeInfoService.getDynamicSimulationStatus(nodeUuid, rootNetworkUuid); - return result != null ? ResponseEntity.ok().body(result.name()) : - ResponseEntity.noContent().build(); + String result = rootNetworkNodeInfoService.getDynamicSimulationStatus(nodeUuid, rootNetworkUuid); + return result != null ? ResponseEntity.ok().body(result) : ResponseEntity.noContent().build(); } // --- Dynamic Simulation Endpoints END --- // @@ -2046,9 +2040,8 @@ public ResponseEntity runDynamicSecurityAnalysis(@Parameter(description = public ResponseEntity getDynamicSecurityAnalysisStatus(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "root network id") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { - DynamicSecurityAnalysisStatus result = rootNetworkNodeInfoService.getDynamicSecurityAnalysisStatus(nodeUuid, rootNetworkUuid); - return result != null ? ResponseEntity.ok().body(result.name()) : - ResponseEntity.noContent().build(); + String result = rootNetworkNodeInfoService.getDynamicSecurityAnalysisStatus(nodeUuid, rootNetworkUuid); + return result != null ? ResponseEntity.ok().body(result) : ResponseEntity.noContent().build(); } // --- Dynamic Security Analysis Endpoints END --- // @@ -2099,9 +2092,8 @@ public ResponseEntity runDynamicMarginCalculation(@Parameter(description = public ResponseEntity getDynamicMarginCalculationStatus(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "root network id") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { - DynamicMarginCalculationStatus result = rootNetworkNodeInfoService.getDynamicMarginCalculationStatus(nodeUuid, rootNetworkUuid); - return result != null ? ResponseEntity.ok().body(result.name()) : - ResponseEntity.noContent().build(); + String result = rootNetworkNodeInfoService.getDynamicMarginCalculationStatus(nodeUuid, rootNetworkUuid); + return result != null ? ResponseEntity.ok().body(result) : ResponseEntity.noContent().build(); } // --- Dynamic Margin Calculation Endpoints END --- // @@ -2518,4 +2510,13 @@ public ResponseEntity setPccMinParameters( @RequestHeader(HEADER_USER_ID) String userId) { return studyService.setPccMinParameters(studyUuid, pccMinParametersInfos, userId) ? ResponseEntity.noContent().build() : ResponseEntity.ok().build(); } + + @GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/computations/status") + @Operation(summary = "Get all computation status on study") + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "all status are returned")}) + public ResponseEntity> getAllComputationsStatus(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid, + @Parameter(description = "Root network UUID") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, + @Parameter(description = "Node UUID") @PathVariable("nodeUuid") UUID nodeUuid) { + return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getAllComputationsStatus(studyUuid, rootNetworkUuid, nodeUuid)); + } } diff --git a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java index e9e6d01fb..334be2d84 100644 --- a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java +++ b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java @@ -57,6 +57,8 @@ public class NotificationService { public static final String HEADER_CLIENT_ID = "clientId"; public static final String NETWORK_EXPORT_FINISHED = "networkExportFinished"; + public static final String UPDATE_TYPE_ALL_COMPUTATION_STATUS = "all_computation_status"; + public static final String UPDATE_TYPE_ALL_COMPUTATION_STATUS_WITHOUT_LOADFLOW = "all_computation_status_without_loadflow"; public static final String UPDATE_TYPE_BUILD_CANCELLED = "buildCancelled"; public static final String UPDATE_TYPE_BUILD_COMPLETED = "buildCompleted"; public static final String UPDATE_TYPE_BUILD_FAILED = "buildFailed"; diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkMapService.java b/src/main/java/org/gridsuite/study/server/service/NetworkMapService.java index 4ef0e1549..4b0a8494e 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkMapService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkMapService.java @@ -17,7 +17,10 @@ import org.gridsuite.study.server.dto.IdentifiableInfos; import org.gridsuite.study.server.dto.InfoTypeParameters; import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; diff --git a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java index 002b34baf..a6c37e148 100644 --- a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java +++ b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java @@ -792,8 +792,9 @@ public String getPccMinResult(UUID nodeUuid, UUID rootNetworkUuid, String filter * GET COMPUTATION STATUS * **************************/ @Transactional(readOnly = true) - public LoadFlowStatus getLoadFlowStatus(UUID nodeUuid, UUID rootNetworkUuid) { - return getBasicLoadFlowStatus(nodeUuid, rootNetworkUuid); + public String getLoadFlowStatus(UUID nodeUuid, UUID rootNetworkUuid) { + LoadFlowStatus status = getBasicLoadFlowStatus(nodeUuid, rootNetworkUuid); + return status == null ? null : status.name(); } @Transactional(readOnly = true) @@ -834,27 +835,31 @@ public String getLoadFlowModifications(UUID nodeUuid, UUID rootNetworkUuid) { } @Transactional(readOnly = true) - public SecurityAnalysisStatus getSecurityAnalysisStatus(UUID nodeUuid, UUID rootNetworkUuid) { + public String getSecurityAnalysisStatus(UUID nodeUuid, UUID rootNetworkUuid) { UUID resultUuid = getComputationResultUuid(nodeUuid, rootNetworkUuid, SECURITY_ANALYSIS); - return securityAnalysisService.getSecurityAnalysisStatus(resultUuid); + SecurityAnalysisStatus status = securityAnalysisService.getSecurityAnalysisStatus(resultUuid); + return status == null ? null : status.name(); } @Transactional(readOnly = true) - public DynamicSimulationStatus getDynamicSimulationStatus(UUID nodeUuid, UUID rootNetworkUuid) { + public String getDynamicSimulationStatus(UUID nodeUuid, UUID rootNetworkUuid) { UUID resultUuid = getComputationResultUuid(nodeUuid, rootNetworkUuid, DYNAMIC_SIMULATION); - return dynamicSimulationService.getStatus(resultUuid); + DynamicSimulationStatus status = dynamicSimulationService.getStatus(resultUuid); + return status == null ? null : status.name(); } @Transactional(readOnly = true) - public DynamicSecurityAnalysisStatus getDynamicSecurityAnalysisStatus(UUID nodeUuid, UUID rootNetworkUuid) { + public String getDynamicSecurityAnalysisStatus(UUID nodeUuid, UUID rootNetworkUuid) { UUID resultUuid = getComputationResultUuid(nodeUuid, rootNetworkUuid, DYNAMIC_SECURITY_ANALYSIS); - return dynamicSecurityAnalysisService.getStatus(resultUuid); + DynamicSecurityAnalysisStatus status = dynamicSecurityAnalysisService.getStatus(resultUuid); + return status == null ? null : status.name(); } @Transactional(readOnly = true) - public DynamicMarginCalculationStatus getDynamicMarginCalculationStatus(UUID nodeUuid, UUID rootNetworkUuid) { + public String getDynamicMarginCalculationStatus(UUID nodeUuid, UUID rootNetworkUuid) { UUID resultUuid = getComputationResultUuid(nodeUuid, rootNetworkUuid, DYNAMIC_MARGIN_CALCULATION); - return dynamicMarginCalculationService.getStatus(resultUuid); + DynamicMarginCalculationStatus status = dynamicMarginCalculationService.getStatus(resultUuid); + return status == null ? null : status.name(); } public String getSensitivityAnalysisStatus(UUID nodeUuid, UUID rootNetworkUuid) { 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 5c43d9282..c863fca0a 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -56,6 +56,7 @@ import org.gridsuite.study.server.service.dynamicsimulation.DynamicSimulationEventService; import org.gridsuite.study.server.service.dynamicsimulation.DynamicSimulationService; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; +import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType; import org.gridsuite.study.server.utils.ElementType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -3019,8 +3020,8 @@ private UUID handleDynamicSecurityAnalysisRequest(StudyEntity studyEntity, UUID throw new StudyException(NOT_ALLOWED, "Load flow must run successfully before running dynamic security analysis"); } - DynamicSimulationStatus dsStatus = rootNetworkNodeInfoService.getDynamicSimulationStatus(nodeUuid, rootNetworkUuid); - if (DynamicSimulationStatus.CONVERGED != dsStatus) { + String dsStatus = rootNetworkNodeInfoService.getDynamicSimulationStatus(nodeUuid, rootNetworkUuid); + if (!DynamicSimulationStatus.CONVERGED.name().equals(dsStatus)) { throw new StudyException(NOT_ALLOWED, "Dynamic simulation must run successfully before running dynamic security analysis"); } @@ -3236,19 +3237,12 @@ public void invalidateShortCircuitStatusOnAllNodes(UUID studyUuid) { } private void emitAllComputationStatusChanged(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeTreeParameters.ComputationsInvalidationMode computationsInvalidationMode) { - if (!InvalidateNodeTreeParameters.ComputationsInvalidationMode.isPreserveLoadFlowResults(computationsInvalidationMode)) { - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + if (InvalidateNodeTreeParameters.ComputationsInvalidationMode.isPreserveLoadFlowResults(computationsInvalidationMode)) { + // use for security node, when reruning loadflow, there is a modification due to the first lf and the node is unbuild when a modification is deleted and we want to keep the results + notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_ALL_COMPUTATION_STATUS_WITHOUT_LOADFLOW); + } else { + notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_ALL_COMPUTATION_STATUS); } - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SECURITY_ANALYSIS_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_DYNAMIC_MARGIN_CALCULATION_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_PCC_MIN_STATUS); } @Transactional(readOnly = true) @@ -3701,6 +3695,23 @@ private List getCurrentLimitViolations(UUID nodeUuid .toList(); } + public Map getAllComputationsStatus(@NonNull UUID studyUuid, @NonNull UUID rootNetworkUuid, @NonNull UUID nodeUuid) { + assertIsStudyExist(studyUuid); + Map allComputationStatus = new EnumMap<>(ComputationType.class); + allComputationStatus.put(LOAD_FLOW, rootNetworkNodeInfoService.getLoadFlowStatus(nodeUuid, rootNetworkUuid)); + allComputationStatus.put(SECURITY_ANALYSIS, rootNetworkNodeInfoService.getSecurityAnalysisStatus(nodeUuid, rootNetworkUuid)); + allComputationStatus.put(PCC_MIN, rootNetworkNodeInfoService.getPccMinStatus(nodeUuid, rootNetworkUuid)); + allComputationStatus.put(DYNAMIC_MARGIN_CALCULATION, rootNetworkNodeInfoService.getDynamicMarginCalculationStatus(nodeUuid, rootNetworkUuid)); + allComputationStatus.put(DYNAMIC_SECURITY_ANALYSIS, rootNetworkNodeInfoService.getDynamicSecurityAnalysisStatus(nodeUuid, rootNetworkUuid)); + allComputationStatus.put(DYNAMIC_SIMULATION, rootNetworkNodeInfoService.getDynamicSimulationStatus(nodeUuid, rootNetworkUuid)); + allComputationStatus.put(STATE_ESTIMATION, rootNetworkNodeInfoService.getStateEstimationStatus(nodeUuid, rootNetworkUuid)); + allComputationStatus.put(SENSITIVITY_ANALYSIS, rootNetworkNodeInfoService.getSensitivityAnalysisStatus(nodeUuid, rootNetworkUuid)); + allComputationStatus.put(SHORT_CIRCUIT_ONE_BUS, rootNetworkNodeInfoService.getShortCircuitAnalysisStatus(nodeUuid, rootNetworkUuid, ShortcircuitAnalysisType.ONE_BUS)); + allComputationStatus.put(SHORT_CIRCUIT, rootNetworkNodeInfoService.getShortCircuitAnalysisStatus(nodeUuid, rootNetworkUuid, ShortcircuitAnalysisType.ALL_BUSES)); + allComputationStatus.put(VOLTAGE_INITIALIZATION, rootNetworkNodeInfoService.getVoltageInitStatus(nodeUuid, rootNetworkUuid)); + return allComputationStatus; + } + public void invalidateStudyRootNetwork(UUID studyUuid, UUID rootNetworkUuid, String userId) { rootNetworkService.assertIsRootNetworkInStudy(studyUuid, rootNetworkUuid); var rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); diff --git a/src/test/java/org/gridsuite/study/server/PccMinTest.java b/src/test/java/org/gridsuite/study/server/PccMinTest.java index 80de9663b..178931954 100644 --- a/src/test/java/org/gridsuite/study/server/PccMinTest.java +++ b/src/test/java/org/gridsuite/study/server/PccMinTest.java @@ -71,11 +71,13 @@ class PccMinTest { private static final String PCC_MIN_URL_BASE = "/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/pcc-min/"; + private static final String COMPUTATION_URL_BASE = "/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/computations/"; private static final String NETWORK_UUID_STRING = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; private static final String PCC_MIN_RESULT_UUID = "cf203721-6150-4203-8960-d61d815a9d16"; private static final String PCC_MIN_ERROR_RESULT_UUID = "25222222-9994-4e55-8ec7-07ea965d24eb"; private static final UUID PCCMIN_PARAMETERS_UUID = UUID.fromString("0c0f1efd-bd22-4a75-83d3-9e530245c7f2"); private static final String PCC_MIN_STATUS_JSON = "{\"status\":\"COMPLETED\"}"; + private static final String ALL_COMPUTATION_STATUS_JSON = "{\"LOAD_FLOW\":null,\"SECURITY_ANALYSIS\":null,\"SENSITIVITY_ANALYSIS\":null,\"SHORT_CIRCUIT\":null,\"SHORT_CIRCUIT_ONE_BUS\":null,\"VOLTAGE_INITIALIZATION\":null,\"DYNAMIC_SIMULATION\":null,\"DYNAMIC_SECURITY_ANALYSIS\":null,\"DYNAMIC_MARGIN_CALCULATION\":null,\"STATE_ESTIMATION\":null,\"PCC_MIN\":\"{\\\"status\\\":\\\"COMPLETED\\\"}\"}"; private static final String ELEMENT_UPDATE_DESTINATION = "element.update"; private static final String CASE_UUID_STRING = "00000000-8cf0-11bd-b23e-10b96e4ef00d"; @@ -280,8 +282,12 @@ void testRunAndCheckStatus() throws Exception { // verify pcc min status computationServerStubs.stubGetResultStatus(PCC_MIN_RESULT_UUID, PCC_MIN_STATUS_JSON); mockMvc.perform(get(PCC_MIN_URL_BASE + "status", ids.studyId, ids.rootNetworkUuid, ids.nodeId)) - .andExpect(status().isOk()) - .andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content().string(PCC_MIN_STATUS_JSON)); + .andExpectAll(status().isOk(), content().string(PCC_MIN_STATUS_JSON)); + + computationServerStubs.verifyGetResultStatus(PCC_MIN_RESULT_UUID); + + mockMvc.perform(get(COMPUTATION_URL_BASE + "status", ids.studyId, ids.rootNetworkUuid, ids.nodeId)) + .andExpectAll(status().isOk(), content().string(ALL_COMPUTATION_STATUS_JSON)); computationServerStubs.verifyGetResultStatus(PCC_MIN_RESULT_UUID); } diff --git a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java index a7802e0b4..e8efc121e 100644 --- a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java +++ b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java @@ -102,6 +102,7 @@ class ShortCircuitTest implements WithAssertions { private static final byte[] SHORT_CIRCUIT_ANALYSIS_CSV_RESULT = {0x00, 0x11}; private static final String SHORT_CIRCUIT_ANALYSIS_STATUS_JSON = "{\"status\":\"COMPLETED\"}"; + private static final String ALL_COMPUTATIONS_STATUS_JSON = "{\"LOAD_FLOW\":null,\"SECURITY_ANALYSIS\":null,\"SENSITIVITY_ANALYSIS\":null,\"SHORT_CIRCUIT\":\"{\\\"status\\\":\\\"COMPLETED\\\"}\",\"SHORT_CIRCUIT_ONE_BUS\":null,\"VOLTAGE_INITIALIZATION\":null,\"DYNAMIC_SIMULATION\":null,\"DYNAMIC_SECURITY_ANALYSIS\":null,\"DYNAMIC_MARGIN_CALCULATION\":null,\"STATE_ESTIMATION\":null,\"PCC_MIN\":null}"; private static final String SHORT_CIRCUIT_ANALYSIS_PARAMETERS_UUID_STRING = "0c0f1efd-bd22-4a75-83d3-9e530245c7f4"; private static final UUID SHORT_CIRCUIT_ANALYSIS_PARAMETERS_UUID = UUID.fromString(SHORT_CIRCUIT_ANALYSIS_PARAMETERS_UUID_STRING); @@ -277,6 +278,12 @@ void testAllBusesShortCircuit() throws Exception { content().string(SHORT_CIRCUIT_ANALYSIS_STATUS_JSON)); computationServerStubs.verifyGetResultStatus(SHORT_CIRCUIT_ANALYSIS_RESULT_UUID); + // get all computing status and check shortcircuit status + mockMvc.perform(get("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/computations/status", studyNameUserIdUuid, firstRootNetworkUuid, modificationNode3Uuid)).andExpectAll( + status().isOk(), + content().string(ALL_COMPUTATIONS_STATUS_JSON)); + computationServerStubs.verifyGetResultStatus(SHORT_CIRCUIT_ANALYSIS_RESULT_UUID); + // stop short circuit analysis shortcircuitServerStubs.stubShortCircuitStopWithPostAction(SHORT_CIRCUIT_ANALYSIS_RESULT_UUID, shortCircuitAnalysisStoppedDestination, modificationNode3Uuid, firstRootNetworkUuid); mockMvc.perform(put("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/shortcircuit/stop", studyNameUserIdUuid, firstRootNetworkUuid, modificationNode3Uuid) diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 50e2c5e3e..8d63096ed 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -920,7 +920,7 @@ private void checkInsertVoltageInitModifications(UUID studyUuid, UUID modificati } private void checkUpdateModelsStatusMessagesReceived(UUID studyUuid, UUID rootNetworkUuid) { - TestUtils.ALL_COMPUTATION_STATUS.forEach(computationStatus -> checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, computationStatus)); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, UPDATE_TYPE_ALL_COMPUTATION_STATUS); } private void checkEquipmentMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid, NetworkImpactsInfos expectedPayload) throws Exception { diff --git a/src/test/java/org/gridsuite/study/server/loadflow/LoadFLowUnitTest.java b/src/test/java/org/gridsuite/study/server/loadflow/LoadFLowUnitTest.java index 2b1b5f937..6310ce4e1 100644 --- a/src/test/java/org/gridsuite/study/server/loadflow/LoadFLowUnitTest.java +++ b/src/test/java/org/gridsuite/study/server/loadflow/LoadFLowUnitTest.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.gridsuite.study.server.dto.ComputationType.LOAD_FLOW; -import static org.gridsuite.study.server.utils.TestUtils.ALL_COMPUTATION_STATUS; +import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_ALL_COMPUTATION_STATUS_WITHOUT_LOADFLOW; import static org.gridsuite.study.server.utils.TestUtils.synchronizeStudyServerExecutionService; import static org.mockito.Mockito.*; @@ -176,8 +176,8 @@ private void testRerunLoadFlowSecurityNode(boolean withRatioTapChangers) { // node invalidation verify(networkModificationTreeService, times(1)).invalidateNodeTree(nodeUuid, rootNetworkUuid, expectedInvalidationParameters); verify(networkModificationService, times(1)).deleteIndexedModifications(invalidateNodeInfos.getGroupUuids(), networkUuid); - verify(notificationService, times(ALL_COMPUTATION_STATUS.size() - 1 /* except loadflow which is tested in PRESERVE_LOAD_FLOW_RESULTS mode */)) - .emitStudyChanged(eq(studyUuid), eq(nodeUuid), eq(rootNetworkUuid), anyString()); + verify(notificationService, times(1 /* only all computation without lf */)) + .emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, UPDATE_TYPE_ALL_COMPUTATION_STATUS_WITHOUT_LOADFLOW); // node build ArgumentCaptor rerunLoadFlowWorkflowInfosArgumentCaptor = ArgumentCaptor.forClass(RerunLoadFlowInfos.class); diff --git a/src/test/java/org/gridsuite/study/server/loadflow/LoadFlowTest.java b/src/test/java/org/gridsuite/study/server/loadflow/LoadFlowTest.java index d6e664ce1..3a1b9b0db 100644 --- a/src/test/java/org/gridsuite/study/server/loadflow/LoadFlowTest.java +++ b/src/test/java/org/gridsuite/study/server/loadflow/LoadFlowTest.java @@ -992,7 +992,7 @@ private void checkUpdateStatusMessageReceived(UUID studyUuid, UUID nodeUuid, Str } private void checkUpdateStatusMessagesReceived(UUID studyUuid, UUID nodeUuid) { - TestUtils.ALL_COMPUTATION_STATUS.forEach(computationStatus -> checkUpdateStatusMessageReceived(studyUuid, nodeUuid, computationStatus)); + checkUpdateStatusMessageReceived(studyUuid, nodeUuid, UPDATE_TYPE_ALL_COMPUTATION_STATUS); } private void checkUpdateStatusMessagesReceived(UUID studyUuid) { diff --git a/src/test/java/org/gridsuite/study/server/service/StudyServiceDynamicSimulationTest.java b/src/test/java/org/gridsuite/study/server/service/StudyServiceDynamicSimulationTest.java index 06ce751a4..85ad63e68 100644 --- a/src/test/java/org/gridsuite/study/server/service/StudyServiceDynamicSimulationTest.java +++ b/src/test/java/org/gridsuite/study/server/service/StudyServiceDynamicSimulationTest.java @@ -162,11 +162,11 @@ void testGetDynamicSimulationStatus() { given(dynamicSimulationService.getStatus(RESULT_UUID)).willReturn(DynamicSimulationStatus.CONVERGED); // call method to be tested - DynamicSimulationStatus status = rootNetworkNodeInfoService.getDynamicSimulationStatus(NODE_UUID, ROOTNETWORK_UUID); + String status = rootNetworkNodeInfoService.getDynamicSimulationStatus(NODE_UUID, ROOTNETWORK_UUID); // --- check result --- // LOGGER.info("Status expected = {}", DynamicSimulationStatus.CONVERGED.name()); LOGGER.info("Status result = {}", status); - assertThat(status).isEqualTo(DynamicSimulationStatus.CONVERGED); + assertThat(status).isEqualTo(DynamicSimulationStatus.CONVERGED.name()); } } diff --git a/src/test/java/org/gridsuite/study/server/studycontroller/NodeControllerTest.java b/src/test/java/org/gridsuite/study/server/studycontroller/NodeControllerTest.java index 1839778c1..b0167f58f 100644 --- a/src/test/java/org/gridsuite/study/server/studycontroller/NodeControllerTest.java +++ b/src/test/java/org/gridsuite/study/server/studycontroller/NodeControllerTest.java @@ -444,28 +444,7 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, if (wasBuilt) { assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); } - //loadflow_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //securityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //sensitivityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //shortCircuitAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //oneBusShortCircuitAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicSimulation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicSecurityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicMarginCalculation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //voltageInit_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //stateEstimation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //pccMin_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + checkComputationStatusMessageReceived(); if (!nodeHasModifications) { return; @@ -479,28 +458,7 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, if (wasBuilt) { assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); } - //loadflow_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //securityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //sensitivityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //shortCircuitAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //oneBusShortCircuitAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicSimulation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicSecurityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicMarginCalculation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //voltageInit_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //stateEstimation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //pccMin_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + checkComputationStatusMessageReceived(); }); if (wasBuilt) { @@ -1063,27 +1021,7 @@ void testGetSearchTermMatchesInMultipleFilteredLogs() throws Exception { } protected void checkComputationStatusMessageReceived() { - //loadflow_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //securityAnalysis_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //sensitivityAnalysis_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //shortCircuitAnalysis_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //oneBusShortCircuitAnalysis_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //dynamicSimulation_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //dynamicSecurityAnalysis_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //dynamicMarginCalculation_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //voltageInit_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //stateEstimation_status - assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); - //pccMin_status + // all_computation_status assertNotNull(output.receive(StudyTest.TIMEOUT, studyUpdateDestination)); } diff --git a/src/test/java/org/gridsuite/study/server/studycontroller/StudyTestBase.java b/src/test/java/org/gridsuite/study/server/studycontroller/StudyTestBase.java index 7601d8940..edb723e6f 100644 --- a/src/test/java/org/gridsuite/study/server/studycontroller/StudyTestBase.java +++ b/src/test/java/org/gridsuite/study/server/studycontroller/StudyTestBase.java @@ -517,17 +517,7 @@ private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, UUID nodeUui } protected void checkUpdateModelsStatusMessagesReceived(UUID studyUuid, UUID nodeUuid) { - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SECURITY_ANALYSIS_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_DYNAMIC_MARGIN_CALCULATION_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_PCC_MIN_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_ALL_COMPUTATION_STATUS); } protected void checkElementUpdatedMessageSent(UUID elementUuid, String userId) { diff --git a/src/test/java/org/gridsuite/study/server/utils/TestUtils.java b/src/test/java/org/gridsuite/study/server/utils/TestUtils.java index 98b9e7ff1..b9a1904ff 100644 --- a/src/test/java/org/gridsuite/study/server/utils/TestUtils.java +++ b/src/test/java/org/gridsuite/study/server/utils/TestUtils.java @@ -42,6 +42,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; +import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_ALL_COMPUTATION_STATUS; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; @@ -53,20 +54,6 @@ @Service public final class TestUtils { - public static final List ALL_COMPUTATION_STATUS = List.of( - NotificationService.UPDATE_TYPE_LOADFLOW_STATUS, - NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, - NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, - NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS, - NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS, - NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS, - NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS, - NotificationService.UPDATE_TYPE_DYNAMIC_SECURITY_ANALYSIS_STATUS, - NotificationService.UPDATE_TYPE_DYNAMIC_MARGIN_CALCULATION_STATUS, - NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS, - NotificationService.UPDATE_TYPE_PCC_MIN_STATUS - ); - //output destinations public static final String STUDY_UPDATE_DESTINATION = "study.update"; public static final String ELEMENT_UPDATE_DESTINATION = "element.update"; @@ -305,6 +292,6 @@ public static void checkUpdateTypeMessageReceived(UUID studyUuid, UUID nodeUuid, } public static void checkUpdateStatusMessagesReceived(UUID studyUuid, UUID nodeUuid, OutputDestination output) { - ALL_COMPUTATION_STATUS.forEach(computationStatus -> checkUpdateTypeMessageReceived(studyUuid, nodeUuid, computationStatus, output, STUDY_UPDATE_DESTINATION)); + checkUpdateTypeMessageReceived(studyUuid, nodeUuid, UPDATE_TYPE_ALL_COMPUTATION_STATUS, output, STUDY_UPDATE_DESTINATION); } }