diff --git a/src/main/java/org/gridsuite/study/server/dto/ComputationType.java b/src/main/java/org/gridsuite/study/server/dto/ComputationType.java index 840af1476..7aa0f31ea 100644 --- a/src/main/java/org/gridsuite/study/server/dto/ComputationType.java +++ b/src/main/java/org/gridsuite/study/server/dto/ComputationType.java @@ -1,37 +1,37 @@ package org.gridsuite.study.server.dto; import lombok.Getter; -import org.gridsuite.study.server.notification.NotificationService; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; @Getter public enum ComputationType { LOAD_FLOW("Load flow", "loadFlowResultUuid", - NotificationService.UPDATE_TYPE_LOADFLOW_STATUS, NotificationService.UPDATE_TYPE_LOADFLOW_RESULT, - NotificationService.UPDATE_TYPE_LOADFLOW_FAILED), + UPDATE_TYPE_LOADFLOW_STATUS, UPDATE_TYPE_LOADFLOW_RESULT, + UPDATE_TYPE_LOADFLOW_FAILED), SECURITY_ANALYSIS("Security analysis", "securityAnalysisResultUuid", - NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, - NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_FAILED), + UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, + UPDATE_TYPE_SECURITY_ANALYSIS_FAILED), SENSITIVITY_ANALYSIS("Sensitivity analysis", "sensitivityAnalysisResultUuid", - NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_RESULT, - NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_FAILED), + UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, UPDATE_TYPE_SENSITIVITY_ANALYSIS_RESULT, + UPDATE_TYPE_SENSITIVITY_ANALYSIS_FAILED), NON_EVACUATED_ENERGY_ANALYSIS("Non evacuated energy analysis", "nonEvacuatedEnergyResultUuid", - NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_RESULT, - NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_FAILED), + UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, UPDATE_TYPE_NON_EVACUATED_ENERGY_RESULT, + UPDATE_TYPE_NON_EVACUATED_ENERGY_FAILED), SHORT_CIRCUIT("Short circuit analysis", "shortCircuitAnalysisResultUuid", - NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_RESULT, - NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_FAILED), + UPDATE_TYPE_SHORT_CIRCUIT_STATUS, UPDATE_TYPE_SHORT_CIRCUIT_RESULT, + UPDATE_TYPE_SHORT_CIRCUIT_FAILED), VOLTAGE_INITIALIZATION("Voltage init", "voltageInitResultUuid", - NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT, - NotificationService.UPDATE_TYPE_VOLTAGE_INIT_FAILED), + UPDATE_TYPE_VOLTAGE_INIT_STATUS, UPDATE_TYPE_VOLTAGE_INIT_RESULT, + UPDATE_TYPE_VOLTAGE_INIT_FAILED), DYNAMIC_SIMULATION("Dynamic simulation", "dynamicSimulationResultUuid", - NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_RESULT, - NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_FAILED), + UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS, UPDATE_TYPE_DYNAMIC_SIMULATION_RESULT, + UPDATE_TYPE_DYNAMIC_SIMULATION_FAILED), SHORT_CIRCUIT_ONE_BUS("One bus Short circuit analysis", "oneBusShortCircuitAnalysisResultUuid", - NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_RESULT, - NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_FAILED), + UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_RESULT, + UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_FAILED), STATE_ESTIMATION("State estimation", "stateEstimationResultUuid", - NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_RESULT, - NotificationService.UPDATE_TYPE_STATE_ESTIMATION_FAILED); + UPDATE_TYPE_STATE_ESTIMATION_STATUS, UPDATE_TYPE_STATE_ESTIMATION_RESULT, + UPDATE_TYPE_STATE_ESTIMATION_FAILED); private final String label; // used for logs private final String resultUuidLabel; diff --git a/src/main/java/org/gridsuite/study/server/notification/ComputationsNotificationTypes.java b/src/main/java/org/gridsuite/study/server/notification/ComputationsNotificationTypes.java new file mode 100644 index 000000000..ad5df28a5 --- /dev/null +++ b/src/main/java/org/gridsuite/study/server/notification/ComputationsNotificationTypes.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2024, 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.notification; + +/** + * @author Mathieu Deharbe @@ -718,7 +719,7 @@ public UUID runLoadFlow(UUID studyUuid, UUID nodeUuid, String userId, Float limi UUID result = loadflowService.runLoadFlow(studyUuid, nodeUuid, lfParametersUuid, lfReportUuid, userId, limitReduction); updateComputationResultUuid(nodeUuid, result, LOAD_FLOW); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_LOADFLOW_STATUS); return result; } @@ -820,8 +821,9 @@ public String getSecurityAnalysisParametersValues(UUID studyUuid) { public void setSecurityAnalysisParametersValues(UUID studyUuid, String parameters, String userId) { StudyEntity studyEntity = studyRepository.findById(studyUuid).orElseThrow(() -> new StudyException(STUDY_NOT_FOUND)); createOrUpdateSecurityAnalysisParameters(studyUuid, studyEntity, parameters); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitComputationParamsChanged(studyUuid, SECURITY_ANALYSIS); } public NonEvacuatedEnergyParametersInfos getNonEvacuatedEnergyParametersInfos(UUID studyUuid) { @@ -841,12 +843,13 @@ public boolean setLoadFlowParameters(UUID studyUuid, String parameters, String u invalidateSensitivityAnalysisStatusOnAllNodes(studyUuid); invalidateNonEvacuatedEnergyAnalysisStatusOnAllNodes(studyUuid); invalidateDynamicSimulationStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_LOADFLOW_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitComputationParamsChanged(studyUuid, LOAD_FLOW); return userProfileIssue; } @@ -876,7 +879,9 @@ public void updateLoadFlowProvider(UUID studyUuid, String provider, String userI updateProvider(studyUuid, userId, studyEntity -> { loadflowService.updateLoadFlowProvider(studyEntity.getLoadFlowParametersUuid(), provider); invalidateLoadFlowStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_LOADFLOW_STATUS); + notificationService.emitComputationParamsChanged(studyUuid, LOAD_FLOW); + }); } @@ -888,7 +893,8 @@ public void updateSecurityAnalysisProvider(UUID studyUuid, String provider, Stri updateProvider(studyUuid, userId, studyEntity -> { securityAnalysisService.updateSecurityAnalysisProvider(studyEntity.getSecurityAnalysisParametersUuid(), provider); invalidateSecurityAnalysisStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + notificationService.emitComputationParamsChanged(studyUuid, SECURITY_ANALYSIS); }); } @@ -915,7 +921,8 @@ public void updateDynamicSimulationProvider(UUID studyUuid, String provider, Str updateProvider(studyUuid, userId, studyEntity -> { studyEntity.setDynamicSimulationProvider(provider != null ? provider : defaultDynamicSimulationProvider); invalidateDynamicSimulationStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + notificationService.emitComputationParamsChanged(studyUuid, DYNAMIC_SIMULATION); }); } @@ -947,6 +954,8 @@ public void setShortCircuitParameters(UUID studyUuid, @Nullable String shortCirc studyRepository.save(studyEntity); } notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitComputationParamsChanged(studyUuid, SHORT_CIRCUIT); + } @Transactional @@ -975,7 +984,7 @@ public UUID runSecurityAnalysis(UUID studyUuid, List contingencyListName UUID result = securityAnalysisService.runSecurityAnalysis(networkUuid, variantId, runSecurityAnalysisParametersInfos, new ReportInfos(saReportUuid, nodeUuid), receiver, userId); updateComputationResultUuid(nodeUuid, result, SECURITY_ANALYSIS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); return result; } @@ -1167,7 +1176,7 @@ public void updateDynamicSimulationParameters(UUID studyUuid, DynamicSimulationP studyEntity.ifPresent(studyEntity1 -> { studyEntity1.setDynamicSimulationParameters(dynamicSimulationParametersEntity); invalidateDynamicSimulationStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); }); } @@ -1794,7 +1803,7 @@ public UUID runSensitivityAnalysis(UUID studyUuid, UUID nodeUuid, String userId) UUID result = sensitivityAnalysisService.runSensitivityAnalysis(nodeUuid, networkUuid, variantId, sensiReportUuid, userId, study.getSensitivityAnalysisParametersUuid(), study.getLoadFlowParametersUuid()); updateComputationResultUuid(nodeUuid, result, SENSITIVITY_ANALYSIS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); return result; } @@ -1808,7 +1817,7 @@ public UUID runShortCircuit(UUID studyUuid, UUID nodeUuid, Optional busI final UUID result = shortCircuitService.runShortCircuit(studyUuid, nodeUuid, busId.orElse(null), parametersUuid, scReportUuid, userId); updateComputationResultUuid(nodeUuid, result, computationType); notificationService.emitStudyChanged(studyUuid, nodeUuid, - busId.isEmpty() ? NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS : NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + busId.isEmpty() ? UPDATE_TYPE_SHORT_CIRCUIT_STATUS : UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); return result; } @@ -1824,7 +1833,7 @@ public UUID runVoltageInit(UUID studyUuid, UUID nodeUuid, String userId) { UUID result = voltageInitService.runVoltageInit(networkUuid, variantId, studyEntity.getVoltageInitParametersUuid(), reportUuid, nodeUuid, userId); updateComputationResultUuid(nodeUuid, result, VOLTAGE_INITIALIZATION); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); return result; } @@ -1839,8 +1848,10 @@ public void setVoltageInitParameters(UUID studyUuid, StudyVoltageInitParameters voltageInitParameters.setApplyModifications(parameters.isApplyModifications()); } createOrUpdateVoltageInitParameters(studyEntity, parameters.getComputationParameters()); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_VOLTAGE_INIT_STATUS); notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitComputationParamsChanged(studyUuid, VOLTAGE_INITIALIZATION); + } public StudyVoltageInitParameters getVoltageInitParameters(UUID studyUuid) { @@ -1879,6 +1890,8 @@ public List getDynamicSimulationModels(UUID studyUuid, UUID nodeUuid public void setDynamicSimulationParameters(UUID studyUuid, DynamicSimulationParametersInfos dsParameter, String userId) { updateDynamicSimulationParameters(studyUuid, DynamicSimulationService.toEntity(dsParameter != null ? dsParameter : DynamicSimulationService.getDefaultDynamicSimulationParameters(), objectMapper)); notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitComputationParamsChanged(studyUuid, DYNAMIC_SIMULATION); + } public DynamicSimulationParametersInfos getDynamicSimulationParameters(UUID studyUuid) { @@ -1900,7 +1913,7 @@ public EventInfos getDynamicSimulationEvent(UUID nodeUuid, String equipmentId) { private void postProcessEventCrud(UUID studyUuid, UUID nodeUuid) { // for delete old result and refresh dynamic simulation run button in UI invalidateDynamicSimulationStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); } @Transactional @@ -1979,7 +1992,7 @@ public UUID runDynamicSimulation(UUID studyUuid, UUID nodeUuid, DynamicSimulatio // update result uuid and notification updateComputationResultUuid(nodeUuid, resultUuid, DYNAMIC_SIMULATION); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); return resultUuid; } @@ -2036,7 +2049,7 @@ public void copyVoltageInitModifications(UUID studyUuid, UUID nodeUuid, String u // invalidate the whole subtree except the target node (we have built this node during the duplication) networkModificationResult.ifPresent(modificationResult -> emitNetworkModificationImpacts(studyUuid, nodeUuid, modificationResult)); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); // send notification voltage init result has changed + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_VOLTAGE_INIT_RESULT); // send notification voltage init result has changed updateStatuses(studyUuid, nodeUuid, true, true, false); // do not delete the voltage init results } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); @@ -2054,8 +2067,9 @@ public String getSensitivityAnalysisParameters(UUID studyUuid) { @Transactional public void setSensitivityAnalysisParameters(UUID studyUuid, String parameters, String userId) { createOrUpdateSensitivityAnalysisParameters(studyUuid, parameters); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitComputationParamsChanged(studyUuid, SENSITIVITY_ANALYSIS); } @Transactional @@ -2064,6 +2078,8 @@ public void setNonEvacuatedEnergyParametersInfos(UUID studyUuid, NonEvacuatedEne NonEvacuatedEnergyService.toEntity(parameters != null ? parameters : NonEvacuatedEnergyService.getDefaultNonEvacuatedEnergyParametersInfos())); notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitComputationParamsChanged(studyUuid, NON_EVACUATED_ENERGY_ANALYSIS); + } public void createOrUpdateSensitivityAnalysisParameters(UUID studyUuid, String parameters) { @@ -2086,7 +2102,7 @@ public void updateNonEvacuatedEnergyParameters(UUID studyUuid, NonEvacuatedEnerg @Transactional public void invalidateLoadFlowStatus(UUID studyUuid, String userId) { invalidateLoadFlowStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_LOADFLOW_STATUS); notificationService.emitElementUpdated(studyUuid, userId); } @@ -2097,8 +2113,8 @@ public void invalidateShortCircuitStatusOnAllNodes(UUID studyUuid) { @Transactional public void invalidateShortCircuitStatus(UUID studyUuid) { invalidateShortCircuitStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); } public UUID runNonEvacuatedEnergy(UUID studyUuid, UUID nodeUuid, String userId) { @@ -2149,7 +2165,7 @@ public UUID runNonEvacuatedEnergy(UUID studyUuid, UUID nodeUuid, String userId) UUID result = nonEvacuatedEnergyService.runNonEvacuatedEnergy(nodeUuid, networkUuid, variantId, reportUuid, provider, nonEvacuatedEnergyInputData, studyEntity.getLoadFlowParametersUuid(), userId); updateComputationResultUuid(nodeUuid, result, NON_EVACUATED_ENERGY_ANALYSIS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); return result; } @@ -2158,7 +2174,8 @@ public void updateNonEvacuatedEnergyProvider(UUID studyUuid, String provider, St updateProvider(studyUuid, userId, studyEntity -> { studyEntity.setNonEvacuatedEnergyProvider(provider != null ? provider : defaultNonEvacuatedEnergyProvider); invalidateNonEvacuatedEnergyAnalysisStatusOnAllNodes(studyUuid); - notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + notificationService.emitStudyChanged(studyUuid, null, UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + notificationService.emitComputationParamsChanged(studyUuid, NON_EVACUATED_ENERGY_ANALYSIS); }); } @@ -2169,15 +2186,15 @@ public String getNonEvacuatedEnergyProvider(UUID studyUuid) { } private void emitAllComputationStatusChanged(UUID studyUuid, UUID nodeUuid) { - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_LOADFLOW_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_STATE_ESTIMATION_STATUS); } public String evaluateFilter(UUID studyUuid, UUID nodeUuid, boolean inUpstreamBuiltParentNode, String filter) { @@ -2214,7 +2231,7 @@ public UUID runStateEstimation(UUID studyUuid, UUID nodeUuid, String userId) { UUID result = stateEstimationService.runStateEstimation(networkUuid, variantId, new ReportInfos(reportUuid, nodeUuid), receiver, userId); updateComputationResultUuid(nodeUuid, result, STATE_ESTIMATION); - notificationService.emitStudyChanged(studyUuid, nodeUuid, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); + notificationService.emitStudyChanged(studyUuid, nodeUuid, UPDATE_TYPE_STATE_ESTIMATION_STATUS); return result; } diff --git a/src/test/java/org/gridsuite/study/server/LoadFlowTest.java b/src/test/java/org/gridsuite/study/server/LoadFlowTest.java index fd4281baf..5a7332340 100644 --- a/src/test/java/org/gridsuite/study/server/LoadFlowTest.java +++ b/src/test/java/org/gridsuite/study/server/LoadFlowTest.java @@ -67,6 +67,8 @@ import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.dto.ComputationType.LOAD_FLOW; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; +import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; @@ -379,11 +381,11 @@ public void testLoadFlow() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); @@ -407,7 +409,7 @@ public void testLoadFlow() throws Exception { .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS, NotificationService.UPDATE_TYPE_LOADFLOW_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS, UPDATE_TYPE_LOADFLOW_RESULT); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + LOADFLOW_RESULT_UUID + "/stop\\?receiver=.*nodeUuid.*"))); @@ -416,9 +418,9 @@ public void testLoadFlow() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_FAILED); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_FAILED); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID))); } @@ -438,9 +440,9 @@ public void testGetLimitViolations() throws Exception { .andExpect(status().isOk()) .andReturn(); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2 + "&limitReduction=0.7"))); // get computing status @@ -490,15 +492,15 @@ public void testInvalidateStatus() throws Exception { .andExpect(status().isOk()) .andReturn(); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2 + "&limitReduction=0.7"))); // invalidate status mockMvc.perform(put("/v1/studies/{studyUuid}/loadflow/invalidate-status", studyNameUserIdUuid) .header("userId", "userId")).andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/invalidate-status\\?resultUuid=" + LOADFLOW_RESULT_UUID))); } @@ -525,9 +527,9 @@ public void testDeleteLoadFlowResults() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_LOADFLOW_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); //Test result count @@ -563,7 +565,7 @@ public void testResetUuidResultWhenLFFailed() { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyEntity.getId(), message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_LOADFLOW_FAILED, updateType); + assertEquals(UPDATE_TYPE_LOADFLOW_FAILED, updateType); } private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, String updateTypeToCheck, String otherUpdateTypeToCheck) { @@ -635,18 +637,21 @@ private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, Strin Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); - assertEquals(NotificationService.UPDATE_TYPE_LOADFLOW_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_LOADFLOW_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); message = output.receive(TIMEOUT, studyUpdateDestination); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); message = output.receive(TIMEOUT, studyUpdateDestination); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); message = output.receive(TIMEOUT, studyUpdateDestination); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); message = output.receive(TIMEOUT, studyUpdateDestination); - assertEquals(NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); message = output.receive(TIMEOUT, elementUpdateDestination); assertEquals(studyNameUserIdUuid, message.getHeaders().get(NotificationService.HEADER_ELEMENT_UUID)); + message = output.receive(TIMEOUT, studyUpdateDestination); + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + } @Test diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java index 8dc752a7e..acf01df01 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java @@ -81,6 +81,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; @RunWith(SpringRunner.class) @AutoConfigureMockMvc @@ -2782,15 +2783,15 @@ private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, UUID nodeUui } private 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_NON_EVACUATED_ENERGY_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_STATE_ESTIMATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_STATE_ESTIMATION_STATUS); } private void checkNodesBuildStatusUpdatedMessageReceived(UUID studyUuid, List nodesUuids) { diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java index ece2f74cb..aeae79199 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java @@ -47,6 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.*; import static org.mockito.ArgumentMatchers.eq; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; /** * @author Kevin Le Saulnier @@ -215,15 +216,15 @@ private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, UUID nodeUui } private 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_NON_EVACUATED_ENERGY_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_STATE_ESTIMATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_STATE_ESTIMATION_STATUS); } private StudyEntity insertStudy(UUID networkUuid, UUID caseUuid) { diff --git a/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java b/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java index cd6c2ec0b..cd3bf3f86 100644 --- a/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java +++ b/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java @@ -72,6 +72,7 @@ import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; +import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; @@ -79,6 +80,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; @RunWith(SpringRunner.class) @AutoConfigureMockMvc @@ -278,17 +280,17 @@ private void testNonEvacuatedEnergyWithNodeUuid(UUID studyUuid, UUID nodeUuid, U Message sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); Message sensitivityAnalysisUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisUpdateMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_RESULT, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_RESULT, updateType); sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/non-evacuated-energy.*?receiver=.*nodeUuid.*"))); @@ -313,7 +315,7 @@ private void testNonEvacuatedEnergyWithNodeUuid(UUID studyUuid, UUID nodeUuid, U sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertTrue(updateType.equals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS) || updateType.equals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_RESULT)); + assertTrue(updateType.equals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS) || updateType.equals(UPDATE_TYPE_NON_EVACUATED_ENERGY_RESULT)); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/non-evacuated-energy/results/" + resultUuid + "/stop\\?receiver=.*nodeUuid.*"))); } @@ -351,17 +353,17 @@ public void testNonEvacuatedEnergy() throws Exception { Message sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); Message sensitivityAnalysisUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, sensitivityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisUpdateMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_RESULT, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_RESULT, updateType); sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/non-evacuated-energy.*?receiver=.*nodeUuid.*"))); @@ -446,7 +448,7 @@ public void testResetUuidResultWhenNonEvacuatedEnergyFailed() { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyEntity.getId(), message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_FAILED, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_FAILED, updateType); assertTrue(networkModificationTreeService.getComputationResultUuid(modificationNode.getId(), ComputationType.NON_EVACUATED_ENERGY_ANALYSIS).isEmpty()); } @@ -474,13 +476,13 @@ public void testNonEvacuatedEnergyFailedForNotification() throws Exception { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_FAILED, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_FAILED, updateType); // message sent by run controller to notify frontend sensitivity analysis non evacuated energy is running and should update status message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) message.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_2_STRING + "/non-evacuated-energy.*?receiver=.*nodeUuid.*"))); @@ -503,7 +505,7 @@ public void testNonEvacuatedEnergyFailedForNotification() throws Exception { message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid2, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) message.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_3_STRING + "/non-evacuated-energy.*?receiver=.*nodeUuid.*"))); } @@ -658,6 +660,8 @@ public void testNonEvacuatedEnergyParameters() throws Exception { .contentType(MediaType.APPLICATION_JSON) .content(myBodyJson)).andExpect( status().isOk()); + Message message = output.receive(TIMEOUT, studyUpdateDestination); + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); mockMvc.perform(get("/v1/studies/{studyUuid}/non-evacuated-energy/parameters", studyNameUserIdUuid)).andExpectAll( status().isOk(), diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index a2bf0776f..793501f96 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -72,6 +72,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; @RunWith(SpringRunner.class) @AutoConfigureMockMvc @@ -354,17 +355,17 @@ public void testSecurityAnalysis() throws Exception { Message securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); Message securityAnalysisUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, securityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, updateType); securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save.*contingencyListName=" + CONTINGENCY_LIST_NAME + "&receiver=.*nodeUuid.*"))); //Test delete all results @@ -414,7 +415,7 @@ public void testResetUuidResultWhenSAFailed() { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyEntity.getId(), message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_FAILED, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_FAILED, updateType); } //test security analysis on network 2 will fail @@ -439,13 +440,13 @@ public void testSecurityAnalysisFailedForNotification() throws Exception { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_FAILED, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_FAILED, updateType); // message sent by run and save controller to notify frontend security analysis is running and should update SA status message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_2_STRING + "/run-and-save.*contingencyListName=" + CONTINGENCY_LIST_NAME + "&receiver=.*nodeUuid.*"))); @@ -469,7 +470,7 @@ public void testSecurityAnalysisFailedForNotification() throws Exception { message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid2, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_3_STRING + "/run-and-save.*contingencyListName=" + CONTINGENCY_LIST_NAME + "&receiver=.*nodeUuid.*"))); } @@ -494,17 +495,17 @@ private void testSecurityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, UUI Message securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); Message securityAnalysisUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, updateType); securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save.*contingencyListName=" + CONTINGENCY_LIST_NAME + "&receiver=.*nodeUuid.*"))); @@ -556,7 +557,7 @@ private void testSecurityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, UUI securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertTrue(updateType.equals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS) || updateType.equals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_RESULT)); + assertTrue(updateType.equals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS) || updateType.equals(UPDATE_TYPE_SECURITY_ANALYSIS_RESULT)); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + resultUuid + "/stop\\?receiver=.*nodeUuid.*"))); @@ -654,7 +655,8 @@ public void testSecurityAnalysisParameters() throws Exception { status().isOk()); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/parameters/" + SECURITY_ANALYSIS_PARAMETERS_UUID))); assertEquals(SECURITY_ANALYSIS_PARAMETERS_UUID, studyRepository.findById(studyNameUserIdUuid).orElseThrow().getSecurityAnalysisParametersUuid()); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); //get security analysis parameters but with an already registered securityAnalysisParametersUuid mockMvc.perform(get("/v1/studies/{studyUuid}/security-analysis/parameters", studyNameUserIdUuid)).andExpectAll( status().isOk(), @@ -668,7 +670,8 @@ public void testSecurityAnalysisParameters() throws Exception { .contentType(MediaType.APPLICATION_JSON) .content(mnBodyJson)).andExpect( status().isOk()); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/parameters/" + SECURITY_ANALYSIS_PARAMETERS_UUID))); assertEquals(SECURITY_ANALYSIS_PARAMETERS_UUID, studyRepository.findById(studyNameUserIdUuid).orElseThrow().getSecurityAnalysisParametersUuid()); } @@ -689,7 +692,8 @@ public void testCreateSecurityAnalysisParameters() throws Exception { .andExpect(status().isOk()); assertEquals(SECURITY_ANALYSIS_PARAMETERS_UUID, studyRepository.findById(studyUuid).orElseThrow().getSecurityAnalysisParametersUuid()); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); Set requests = TestUtils.getRequestsDone(1, server); assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/parameters"))); } @@ -712,17 +716,17 @@ public void getResultZippedCsv() throws Exception { Message securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); Message securityAnalysisUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, updateType); securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save.*contingencyListName=" + CONTINGENCY_LIST_NAME + "&receiver=.*nodeUuid.*"))); /** @@ -781,17 +785,17 @@ public void getResultZippedCsvNotFound() throws Exception { Message securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); Message securityAnalysisUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_RESULT, updateType); securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save.*contingencyListName=" + CONTINGENCY_LIST_NAME + "&receiver=.*nodeUuid.*"))); /** diff --git a/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java index 5cd4b2116..af1852468 100644 --- a/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java @@ -70,6 +70,7 @@ import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.dto.ComputationType.SENSITIVITY_ANALYSIS; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; +import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS; import static org.gridsuite.study.server.utils.TestUtils.getBinaryAsBuffer; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; @@ -77,6 +78,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; @RunWith(SpringRunner.class) @AutoConfigureMockMvc @@ -300,17 +302,17 @@ private void testSensitivityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, Message sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); Message sensitivityAnalysisUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisUpdateMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_RESULT, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_RESULT, updateType); sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save.*?receiver=.*nodeUuid.*"))); @@ -360,7 +362,7 @@ private void testSensitivityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertTrue(updateType.equals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS) || updateType.equals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_RESULT)); + assertTrue(updateType.equals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS) || updateType.equals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_RESULT)); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + resultUuid + "/stop\\?receiver=.*nodeUuid.*"))); } @@ -402,17 +404,17 @@ public void testSensitivityAnalysis() throws Exception { Message sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); Message sensitivityAnalysisUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, sensitivityAnalysisUpdateMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisUpdateMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_RESULT, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_RESULT, updateType); sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) sensitivityAnalysisStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save.*?receiver=.*nodeUuid.*"))); @@ -519,7 +521,7 @@ public void testResetUuidResultWhenSAFailed() { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyEntity.getId(), message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_FAILED, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_FAILED, updateType); } // test sensitivity analysis on network 2 will fail @@ -540,13 +542,13 @@ public void testSensitivityAnalysisFailedForNotification() throws Exception { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_FAILED, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_FAILED, updateType); // message sent by run and save controller to notify frontend sensitivity analysis is running and should update status message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) message.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_2_STRING + "/run-and-save.*?receiver=.*nodeUuid.*"))); @@ -569,7 +571,7 @@ public void testSensitivityAnalysisFailedForNotification() throws Exception { message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid2, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); updateType = (String) message.getHeaders().get(HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, updateType); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_3_STRING + "/run-and-save.*?receiver=.*nodeUuid.*"))); } @@ -719,9 +721,13 @@ private void setParametersAndDoChecks(UUID studyNameUserIdUuid, String parameter .content(parameters)).andExpect( status().isOk()); - Message sensiStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); - assertEquals(studyNameUserIdUuid, sensiStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); - assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, sensiStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + Message message = output.receive(TIMEOUT, studyUpdateDestination); + assertEquals(studyNameUserIdUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); + assertEquals(UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + + message = output.receive(TIMEOUT, studyUpdateDestination); + assertEquals(studyNameUserIdUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); Message elementUpdateMessage = output.receive(TIMEOUT, elementUpdateDestination); assertEquals(studyNameUserIdUuid, elementUpdateMessage.getHeaders().get(NotificationService.HEADER_ELEMENT_UUID)); diff --git a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java index 14eb04f06..624bfc9f0 100644 --- a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java +++ b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java @@ -61,6 +61,7 @@ import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; +import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS; import static org.gridsuite.study.server.utils.TestUtils.getBinaryAsBuffer; import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.any; @@ -68,6 +69,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; @RunWith(SpringRunner.class) @AutoConfigureMockMvc @@ -282,6 +284,7 @@ public void testShortCircuitAnalysisParameters() throws Exception { .header(HEADER_USER_ID, "testUserId") .content("{\"dumb\": \"json\"}").contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.equals("/v1/parameters/" + SHORT_CIRCUIT_ANALYSIS_PARAMETERS_UUID))); } @@ -320,11 +323,11 @@ public void testAllBusesShortCircuit() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); @@ -360,7 +363,7 @@ public void testAllBusesShortCircuit() throws Exception { .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS, UPDATE_TYPE_SHORT_CIRCUIT_RESULT); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/stop\\?receiver=.*nodeUuid.*"))); @@ -369,9 +372,9 @@ public void testAllBusesShortCircuit() throws Exception { .header(HEADER_USER_ID, "testUserId")) .andExpect(status().isOk()).andReturn(); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_FAILED); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_FAILED); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID))); @@ -424,11 +427,11 @@ public void testGetShortCircuitAnalysisCsvResultNotFound() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING_NOT_FOUND + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_4))); @@ -457,11 +460,11 @@ public void testPagedShortCircuit() throws Exception { .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); @@ -497,7 +500,7 @@ public void testPagedShortCircuit() throws Exception { .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS, UPDATE_TYPE_SHORT_CIRCUIT_RESULT); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/stop\\?receiver=.*nodeUuid.*"))); } @@ -535,11 +538,11 @@ public void testOneBusShortCircuit() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); @@ -619,7 +622,7 @@ public void testResetUuidResultWhenSCFailed() throws Exception { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyEntity.getId(), message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_FAILED, updateType); + assertEquals(UPDATE_TYPE_SHORT_CIRCUIT_FAILED, updateType); } private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, String updateTypeToCheck) { @@ -695,11 +698,11 @@ public void testInvalidateShortCircuitStatus() throws Exception { .andExpect(status().isOk()) .andReturn(); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); //run a one bus short circuit analysis @@ -709,19 +712,19 @@ public void testInvalidateShortCircuitStatus() throws Exception { .andExpect(status().isOk()) .andReturn(); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_RESULT); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); // invalidate status mockMvc.perform(put("/v1/studies/{studyUuid}/short-circuit/invalidate-status", studyNameUserIdUuid) .header("userId", "userId")).andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/invalidate-status\\?resultUuid=" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "&resultUuid=" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID))); } diff --git a/src/test/java/org/gridsuite/study/server/StateEstimationTest.java b/src/test/java/org/gridsuite/study/server/StateEstimationTest.java index 4501cdf13..263cbe2ae 100644 --- a/src/test/java/org/gridsuite/study/server/StateEstimationTest.java +++ b/src/test/java/org/gridsuite/study/server/StateEstimationTest.java @@ -60,6 +60,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; /** * @author David Braquart @@ -248,9 +249,9 @@ private void runEstim(StudyNodeIds ids) throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(ids.studyId, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); - checkUpdateModelStatusMessagesReceived(ids.studyId, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_RESULT); - checkUpdateModelStatusMessagesReceived(ids.studyId, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); + checkUpdateModelStatusMessagesReceived(ids.studyId, UPDATE_TYPE_STATE_ESTIMATION_STATUS); + checkUpdateModelStatusMessagesReceived(ids.studyId, UPDATE_TYPE_STATE_ESTIMATION_RESULT); + checkUpdateModelStatusMessagesReceived(ids.studyId, UPDATE_TYPE_STATE_ESTIMATION_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?reportUuid=.*&reporterId=.*&reportType=StateEstimation&variantId=" + VARIANT_ID + "&receiver=.*"))); } @@ -350,7 +351,7 @@ public void testStop() { // stop running estim mockMvc.perform(put(STATE_ESTIMATION_URL_BASE + "stop", ids.studyId, ids.nodeId)).andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(ids.studyId, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_RESULT); + checkUpdateModelStatusMessagesReceived(ids.studyId, UPDATE_TYPE_STATE_ESTIMATION_STATUS, UPDATE_TYPE_STATE_ESTIMATION_RESULT); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + STATE_ESTIMATION_RESULT_UUID + "/stop\\?receiver=.*nodeUuid.*"))); } @@ -362,8 +363,8 @@ public void testFailure() { mockMvc.perform(post(STATE_ESTIMATION_URL_BASE + "run", ids.studyId, ids.nodeId) .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(ids.studyId, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_FAILED); - checkUpdateModelStatusMessagesReceived(ids.studyId, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); + checkUpdateModelStatusMessagesReceived(ids.studyId, UPDATE_TYPE_STATE_ESTIMATION_FAILED); + checkUpdateModelStatusMessagesReceived(ids.studyId, UPDATE_TYPE_STATE_ESTIMATION_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?reportUuid=.*&reporterId=.*&reportType=StateEstimation&variantId=" + VARIANT_ID_2 + "&receiver=.*"))); } } diff --git a/src/test/java/org/gridsuite/study/server/StudyControllerDynamicSimulationTest.java b/src/test/java/org/gridsuite/study/server/StudyControllerDynamicSimulationTest.java index 92bc417d1..cb285b57c 100644 --- a/src/test/java/org/gridsuite/study/server/StudyControllerDynamicSimulationTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyControllerDynamicSimulationTest.java @@ -65,11 +65,13 @@ import java.util.*; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; import static org.mockito.BDDMockito.any; import static org.mockito.BDDMockito.eq; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; /** * @author Thang PHAM @@ -280,7 +282,7 @@ public void testRunDynamicSimulationGivenRegularNodeAndFailed() throws Exception Message dynamicSimulationStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertThat(dynamicSimulationStatusMessage.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); // resultUuid must be present in database at this moment UUID actualResultUuid = networkModificationTreeService.getComputationResultUuid(modificationNode1Uuid, ComputationType.DYNAMIC_SIMULATION).get(); getLogger().info("Actual result uuid in the database = " + actualResultUuid); @@ -300,7 +302,7 @@ public void testRunDynamicSimulationGivenRegularNodeAndFailed() throws Exception dynamicSimulationStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertThat(dynamicSimulationStatusMessage.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_FAILED); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_FAILED); // resultUuid must be empty in database at this moment assertThat(networkModificationTreeService.getComputationResultUuid(modificationNode1Uuid, ComputationType.DYNAMIC_SIMULATION)).isEmpty(); } @@ -348,7 +350,7 @@ public void testRunDynamicSimulationGivenRegularNode() throws Exception { Message dynamicSimulationStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertThat(dynamicSimulationStatusMessage.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); // resultUuid must be present in database at this moment UUID actualResultUuid = networkModificationTreeService.getComputationResultUuid(modificationNode1Uuid, ComputationType.DYNAMIC_SIMULATION).get(); getLogger().info("Actual result uuid in the database = " + actualResultUuid); @@ -368,13 +370,13 @@ public void testRunDynamicSimulationGivenRegularNode() throws Exception { dynamicSimulationStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertThat(dynamicSimulationStatusMessage.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); // must have message UPDATE_TYPE_DYNAMIC_SIMULATION_RESULT from channel : studyUpdateDestination Message dynamicSimulationResultMessage = output.receive(TIMEOUT, studyUpdateDestination); assertThat(dynamicSimulationResultMessage.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_RESULT); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_RESULT); //Test result count Mockito.doAnswer(invocation -> 1).when(dynamicSimulationService).getResultsCount(); @@ -423,7 +425,7 @@ public void testRunDynamicSimulationGivenRegularNodeAndStopped() throws Exceptio Message dynamicSimulationStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertThat(dynamicSimulationStatusMessage.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); // resultUuid must be present in database at this moment UUID actualResultUuid = networkModificationTreeService.getComputationResultUuid(modificationNode1Uuid, ComputationType.DYNAMIC_SIMULATION).get(); getLogger().info("Actual result uuid in the database = " + actualResultUuid); @@ -443,7 +445,7 @@ public void testRunDynamicSimulationGivenRegularNodeAndStopped() throws Exceptio dynamicSimulationStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertThat(dynamicSimulationStatusMessage.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); } @Test @@ -725,11 +727,13 @@ public void testGetDynamicSimulationModelsGivenEmptyMapping() throws Exception { } private void checkNotificationsAfterInjectingDynamicSimulationParameters(UUID studyUuid) { - // must have message UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS from channel : studyUpdateDestination + // must have message UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS and UPDATE_TYPE_COMPUTATION_PARAMETERS from channel : studyUpdateDestination Message studyUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); assertThat(studyUpdateMessage.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + studyUpdateMessage = output.receive(TIMEOUT, studyUpdateDestination); + assertEquals(NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS, studyUpdateMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); // must have message HEADER_USER_ID_VALUE from channel : elementUpdateDestination Message elementUpdateMessage = output.receive(TIMEOUT, elementUpdateDestination); @@ -757,7 +761,7 @@ private void checkNotificationsAfterInjectingDynamicSimulationEvent(UUID studyUu Message studyUpdateMessageStatus = output.receive(TIMEOUT, studyUpdateDestination); assertThat(studyUpdateMessageStatus.getHeaders()) .containsEntry(NotificationService.HEADER_STUDY_UUID, studyUuid) - .containsEntry(NotificationService.HEADER_UPDATE_TYPE, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + .containsEntry(NotificationService.HEADER_UPDATE_TYPE, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); } @Test diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index b9e543be8..2a15dfd6a 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -91,6 +91,7 @@ import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.StudyException.Type.STUDY_NOT_FOUND; import static org.gridsuite.study.server.notification.NotificationService.DEFAULT_ERROR_MESSAGE; +import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS; import static org.gridsuite.study.server.utils.MatcherBasicStudyInfos.createMatcherStudyBasicInfos; import static org.gridsuite.study.server.utils.MatcherCreatedStudyBasicInfos.createMatcherCreatedStudyBasicInfos; import static org.gridsuite.study.server.utils.MatcherStudyInfos.createMatcherStudyInfos; @@ -100,6 +101,7 @@ import static org.mockito.Mockito.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; /** * @author Abdelsalem Hedhili @@ -1423,15 +1425,15 @@ private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, UUID nodeUui } private 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_NON_EVACUATED_ENERGY_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_STATE_ESTIMATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, nodeUuid, UPDATE_TYPE_STATE_ESTIMATION_STATUS); } private void checkNodeBuildStatusUpdatedMessageReceived(UUID studyUuid, List nodesUuids) { @@ -2583,7 +2585,12 @@ public void providerTest() throws Exception { .andExpect(status().isOk()); Message message = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(message); - assertEquals(NotificationService.UPDATE_TYPE_LOADFLOW_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_LOADFLOW_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); + message = output.receive(TIMEOUT, studyUpdateDestination); + assertNotNull(message); + + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertNotNull(output.receive(TIMEOUT, elementUpdateDestination)); mockMvc.perform(post("/v1/studies/{studyUuid}/security-analysis/provider", studyUuid) @@ -2593,7 +2600,12 @@ public void providerTest() throws Exception { .andExpect(status().isOk()); message = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(message); - assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); + + message = output.receive(TIMEOUT, studyUpdateDestination); + assertNotNull(message); + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertNotNull(output.receive(TIMEOUT, elementUpdateDestination)); mockMvc.perform(post("/v1/studies/{studyUuid}/non-evacuated-energy/provider", studyUuid) @@ -2603,7 +2615,11 @@ public void providerTest() throws Exception { .andExpect(status().isOk()); message = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(message); - assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); + message = output.receive(TIMEOUT, studyUpdateDestination); + assertNotNull(message); + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertNotNull(output.receive(TIMEOUT, elementUpdateDestination)); mockMvc.perform(get("/v1/studies/{studyUuid}/non-evacuated-energy/provider", studyUuid)) diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 1d9a253cd..189561aa3 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -80,6 +80,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; /** * @author Etienne Homer @@ -358,7 +359,10 @@ private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, Study Message voltageInitStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyNameUserIdUuid, voltageInitStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); - assertEquals(NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS, voltageInitStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + assertEquals(UPDATE_TYPE_VOLTAGE_INIT_STATUS, voltageInitStatusMessage.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + Message message = output.receive(TIMEOUT, studyUpdateDestination); + + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); Message elementUpdateMessage = output.receive(TIMEOUT, elementUpdateDestination); assertEquals(studyNameUserIdUuid, elementUpdateMessage.getHeaders().get(NotificationService.HEADER_ELEMENT_UUID)); @@ -424,6 +428,8 @@ public void testUpdatingParametersWithSameComputationParametersDoesNotInvalidate // STUDY_CHANGED event output.receive(1000, studyUpdateDestination); + assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); + } @Test @@ -486,13 +492,13 @@ public void testVoltageInit() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_RESULT); checkReactiveSlacksAlertMessagesReceived(studyNameUserIdUuid, 10.); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); @@ -529,7 +535,7 @@ public void testVoltageInit() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS, UPDATE_TYPE_VOLTAGE_INIT_RESULT); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/stop\\?receiver=.*nodeUuid.*"))); @@ -537,9 +543,9 @@ public void testVoltageInit() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_FAILED); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_FAILED); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID))); @@ -577,13 +583,13 @@ public void testVoltageInitCancelFail() throws Exception { .andExpect(status().isOk()); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_3))); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_RESULT); checkReactiveSlacksAlertMessagesReceived(studyNameUserIdUuid, 10.); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); // stop voltage init analysis fail mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/stop", studyNameUserIdUuid, modificationNode4Uuid) @@ -611,10 +617,10 @@ public void testCopyVoltageInitModifications() throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_RESULT); checkReactiveSlacksAlertMessagesReceived(studyNameUserIdUuid, 10.); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2))); // just retrieve modifications list from modificationNode3Uuid @@ -637,7 +643,7 @@ public void testCopyVoltageInitModifications() throws Exception { checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode3Uuid); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNode3Uuid)); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_STUDY); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, UPDATE_TYPE_VOLTAGE_INIT_RESULT); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.NODE_BUILD_STATUS_UPDATED); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode3Uuid); @@ -645,15 +651,15 @@ public void testCopyVoltageInitModifications() throws Exception { } private void checkUpdateModelsStatusMessagesReceived(UUID studyUuid) { - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, UPDATE_TYPE_STATE_ESTIMATION_STATUS); } private void checkElementUpdatedMessageSent(UUID elementUuid, String userId) { @@ -722,7 +728,7 @@ public void testNotResetedUuidResultWhenVoltageInitFailed() { Message message = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyEntity.getId(), message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); String updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE); - assertEquals(NotificationService.UPDATE_TYPE_VOLTAGE_INIT_FAILED, updateType); + assertEquals(UPDATE_TYPE_VOLTAGE_INIT_FAILED, updateType); } private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, String updateTypeToCheck) { 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 7f572f294..923737516 100644 --- a/src/test/java/org/gridsuite/study/server/service/StudyServiceDynamicSimulationTest.java +++ b/src/test/java/org/gridsuite/study/server/service/StudyServiceDynamicSimulationTest.java @@ -36,11 +36,11 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.gridsuite.study.server.dto.ComputationType.DYNAMIC_SIMULATION; -import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willDoNothing; +import static org.gridsuite.study.server.notification.ComputationsNotificationTypes.*; /** * @author Thang PHAM