diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 998cbbd92..f283bdc4f 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -19,8 +19,6 @@ import org.gridsuite.study.server.StudyConstants; import org.gridsuite.study.server.StudyException; import org.gridsuite.study.server.dto.*; -import org.gridsuite.study.server.dto.InvalidateNodeTreeParameters.ComputationsInvalidationMode; -import org.gridsuite.study.server.dto.InvalidateNodeTreeParameters.InvalidationMode; import org.gridsuite.study.server.dto.caseimport.CaseImportAction; import org.gridsuite.study.server.dto.dynamicmapping.MappingInfos; import org.gridsuite.study.server.dto.dynamicmapping.ModelInfos; @@ -1901,9 +1899,7 @@ public void deleteNetworkModifications(UUID studyUuid, UUID nodeUuid, List UUID groupId = networkModificationTreeService.getModificationGroupUuid(nodeUuid); networkModificationService.deleteModifications(groupId, modificationsUuids); // for each root network, remove modifications from excluded ones - studyEntity.getRootNetworks().forEach(rootNetworkEntity -> { - rootNetworkNodeInfoService.updateModificationsToExclude(nodeUuid, rootNetworkEntity.getId(), new HashSet<>(modificationsUuids), true); - }); + studyEntity.getRootNetworks().forEach(rootNetworkEntity -> rootNetworkNodeInfoService.updateModificationsToExclude(nodeUuid, rootNetworkEntity.getId(), new HashSet<>(modificationsUuids), true)); } finally { notificationService.emitEndDeletionEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -2850,6 +2846,9 @@ public String getNetworkElementsIds(UUID nodeUuid, UUID rootNetworkUuid, List childrenUuids = networkModificationTreeService.getChildrenUuids(nodeUuid); notificationService.emitStartModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids, NotificationService.MODIFICATIONS_UPDATING_IN_PROGRESS); try { checkStudyContainsNode(studyUuid, nodeUuid); + // voltageInit modification should apply only on the root network where the computation has been made: + // - application context will point to the computation root network only + // - after creation, we deactivate the new modification for all other root networks List studyRootNetworkEntities = getStudyRootNetworks(studyUuid); - List modificationApplicationContexts = studyRootNetworkEntities.stream() - .map(rootNetworkEntity -> rootNetworkNodeInfoService.getNetworkModificationApplicationContext(rootNetworkEntity.getId(), nodeUuid, rootNetworkEntity.getNetworkUuid())) - .toList(); + List modificationApplicationContexts = new ArrayList<>(); + List rootNetworkToDeactivateUuids = new ArrayList<>(); + studyRootNetworkEntities.forEach(rootNetworkEntity -> { + if (rootNetworkUuid.equals(rootNetworkEntity.getId())) { + modificationApplicationContexts.add(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(rootNetworkEntity.getId(), nodeUuid, rootNetworkEntity.getNetworkUuid())); + } else { + rootNetworkToDeactivateUuids.add(rootNetworkEntity.getId()); + } + }); + // duplicate the modification created by voltageInit server into the current node NetworkModificationsResult networkModificationResults = networkModificationService.duplicateModificationsFromGroup(networkModificationTreeService.getModificationGroupUuid(nodeUuid), voltageInitModificationsGroupUuid, Pair.of(List.of(), modificationApplicationContexts)); - if (networkModificationResults != null) { + // We expect a single voltageInit modification in the result list + if (networkModificationResults != null && networkModificationResults.modificationUuids().size() == 1) { + for (UUID otherRootNetwork : rootNetworkToDeactivateUuids) { + rootNetworkNodeInfoService.updateModificationsToExclude(nodeUuid, otherRootNetwork, Set.of(networkModificationResults.modificationUuids().getFirst()), false); + } int index = 0; // for each NetworkModificationResult, send an impact notification - studyRootNetworkEntities are ordered in the same way as networkModificationResults for (Optional modificationResultOpt : networkModificationResults.modificationResults()) { @@ -2885,7 +2898,7 @@ public void insertVoltageInitModifications(UUID studyUuid, UUID nodeUuid, UUID r } } - voltageInitService.resetModificationsGroupUuid(nodeUuid, resultUuid); + voltageInitService.resetModificationsGroupUuid(resultUuid); // invalidate the whole subtree except the target node (we have built this node during the duplication) notificationService.emitStudyChanged(studyUuid, nodeUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); // send notification voltage init result has changed diff --git a/src/main/java/org/gridsuite/study/server/service/VoltageInitService.java b/src/main/java/org/gridsuite/study/server/service/VoltageInitService.java index dca0690f7..43a95bcda 100644 --- a/src/main/java/org/gridsuite/study/server/service/VoltageInitService.java +++ b/src/main/java/org/gridsuite/study/server/service/VoltageInitService.java @@ -255,10 +255,6 @@ public void assertVoltageInitNotRunning(UUID resultUuid) { } public UUID getModificationsGroupUuid(UUID nodeUuid, UUID resultUuid) { - if (resultUuid == null) { - throw new StudyException(NO_VOLTAGE_INIT_RESULTS_FOR_NODE, THE_NODE + nodeUuid + " has no voltage init results"); - } - UUID modificationsGroupUuid; String path = UriComponentsBuilder.fromPath(DELIMITER + VOLTAGE_INIT_API_VERSION + "/results/{resultUuid}/modifications-group-uuid") .buildAndExpand(resultUuid).toUriString(); @@ -283,10 +279,7 @@ public void invalidateVoltageInitStatus(List uuids) { } } - public void resetModificationsGroupUuid(UUID nodeUuid, UUID resultUuid) { - if (resultUuid == null) { - throw new StudyException(NO_VOLTAGE_INIT_RESULTS_FOR_NODE, THE_NODE + nodeUuid + " has no voltage init results"); - } + public void resetModificationsGroupUuid(UUID resultUuid) { String path = UriComponentsBuilder.fromPath(DELIMITER + VOLTAGE_INIT_API_VERSION + "/results/{resultUuid}/modifications-group-uuid") .buildAndExpand(resultUuid).toUriString(); diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 7146e120c..797643df2 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -25,20 +25,33 @@ import okhttp3.HttpUrl; import org.gridsuite.study.server.dto.LoadFlowStatus; import org.gridsuite.study.server.dto.NodeReceiver; +import org.gridsuite.study.server.dto.RootNetworkIndexationStatus; import org.gridsuite.study.server.dto.RootNetworkNodeInfo; import org.gridsuite.study.server.dto.impacts.SimpleElementImpact.SimpleImpactType; +import org.gridsuite.study.server.dto.modification.ModificationApplicationContext; import org.gridsuite.study.server.dto.modification.NetworkModificationResult; import org.gridsuite.study.server.dto.modification.NetworkModificationsResult; import org.gridsuite.study.server.dto.voltageinit.parameters.*; import org.gridsuite.study.server.networkmodificationtree.dto.*; +import org.gridsuite.study.server.networkmodificationtree.entities.NetworkModificationNodeInfoEntity; +import org.gridsuite.study.server.networkmodificationtree.entities.NodeEntity; +import org.gridsuite.study.server.networkmodificationtree.entities.NodeType; +import org.gridsuite.study.server.networkmodificationtree.entities.RootNetworkNodeInfoEntity; +import org.gridsuite.study.server.networkmodificationtree.entities.RootNodeInfoEntity; import org.gridsuite.study.server.notification.NotificationService; import org.gridsuite.study.server.notification.dto.AlertLevel; import org.gridsuite.study.server.notification.dto.NetworkImpactsInfos; import org.gridsuite.study.server.notification.dto.StudyAlert; import org.gridsuite.study.server.repository.StudyEntity; import org.gridsuite.study.server.repository.StudyRepository; +import org.gridsuite.study.server.repository.networkmodificationtree.NetworkModificationNodeInfoRepository; +import org.gridsuite.study.server.repository.networkmodificationtree.NodeRepository; +import org.gridsuite.study.server.repository.networkmodificationtree.RootNodeInfoRepository; import org.gridsuite.study.server.repository.nonevacuatedenergy.NonEvacuatedEnergyParametersEntity; +import org.gridsuite.study.server.repository.rootnetwork.RootNetworkEntity; import org.gridsuite.study.server.repository.rootnetwork.RootNetworkNodeInfoRepository; +import org.gridsuite.study.server.repository.rootnetwork.RootNetworkRepository; +import org.gridsuite.study.server.repository.voltageinit.StudyVoltageInitParametersEntity; import org.gridsuite.study.server.service.*; import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService; import org.gridsuite.study.server.utils.MatcherJson; @@ -105,8 +118,16 @@ class VoltageInitTest { private static final String NETWORK_UUID_STRING = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; + private static final UUID NETWORK_UUID = UUID.fromString(NETWORK_UUID_STRING); + + private static final String SECOND_NETWORK_UUID_STRING = "bb435e0d-5242-408c-b845-c36418ec9ef2"; + + private static final UUID SECOND_NETWORK_UUID = UUID.fromString(SECOND_NETWORK_UUID_STRING); + private static final String VOLTAGE_INIT_RESULT_UUID = "1b6cc22c-3f33-11ed-b878-0242ac120002"; + private static final UUID VOLTAGE_INIT_MODIFICATION_UUID = UUID.fromString("10d2dd27-c1c8-486a-a588-8fc119733c75"); + private static final String VOLTAGE_INIT_ERROR_RESULT_UUID = "25222222-9994-4e55-8ec7-07ea965d24eb"; private static final String VOLTAGE_INIT_CANCEL_FAILED_UUID = "1b6cc22c-3f33-11ed-b878-0242ac120003"; @@ -228,6 +249,24 @@ class VoltageInitTest { @Autowired private RootNetworkNodeInfoRepository rootNetworkNodeInfoRepository; + @Autowired + private RootNetworkNodeInfoService rootNetworkNodeInfoService; + + @Autowired + private TestUtils studyTestUtils; + + @Autowired + private NodeRepository nodeRepository; + + @Autowired + private NetworkModificationNodeInfoRepository networkModificationNodeInfoRepository; + + @Autowired + private RootNodeInfoRepository rootNodeInfoRepository; + + @Autowired + private RootNetworkRepository rootNetworkRepository; + //output destinations private final String studyUpdateDestination = "study.update"; private final String voltageInitResultDestination = "voltageinit.result"; @@ -235,10 +274,6 @@ class VoltageInitTest { private final String voltageInitFailedDestination = "voltageinit.run.dlx"; private final String voltageInitCancelFailedDestination = "voltageinit.cancelfailed"; private final String elementUpdateDestination = "element.update"; - @Autowired - private RootNetworkNodeInfoService rootNetworkNodeInfoService; - @Autowired - private TestUtils studyTestUtils; @BeforeEach void setup(final MockWebServer server) throws Exception { @@ -310,7 +345,7 @@ public MockResponse dispatch(RecordedRequest request) { Optional networkModificationResult = createModificationResultWithElementImpact(SimpleImpactType.MODIFICATION, IdentifiableType.GENERATOR, "genId", Set.of("s1")); - return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(new NetworkModificationsResult(List.of(), List.of(networkModificationResult)))); + return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(new NetworkModificationsResult(List.of(VOLTAGE_INIT_MODIFICATION_UUID), List.of(networkModificationResult)))); } else if (path.matches("/v1/groups/" + MODIFICATIONS_GROUP_UUID + "/network-modifications\\?errorOnGroupNotFound=false&onlyStashed=false&onlyMetadata=.*")) { return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(VOLTAGE_INIT_PREVIEW_MODIFICATION_LIST)); } else if (path.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/stop.*") @@ -385,7 +420,8 @@ public MockResponse dispatch(RecordedRequest request) { } private void initMockBeans(Network network) { - when(networkStoreService.getNetwork(UUID.fromString(NETWORK_UUID_STRING))).thenReturn(network); + when(networkStoreService.getNetwork(NETWORK_UUID)).thenReturn(network); + when(networkStoreService.getNetwork(SECOND_NETWORK_UUID)).thenReturn(network); } private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, StudyVoltageInitParameters parameters, String userId, HttpStatusCode status) throws Exception { @@ -412,7 +448,7 @@ private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, Study @Test void testVoltageInitParameters(final MockWebServer server) throws Exception { //insert a study - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, null, false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, null, false); UUID studyNameUserIdUuid = studyEntity.getId(); //get initial voltage init parameters @@ -439,7 +475,7 @@ void testVoltageInitParameters(final MockWebServer server) throws Exception { assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/parameters/" + VOLTAGE_INIT_PARAMETERS_UUID_STRING))); // insert a study with a wrong voltage init parameters uuid - StudyEntity studyEntity2 = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, UUID.fromString(WRONG_VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); + StudyEntity studyEntity2 = insertDummyStudy(NETWORK_UUID, CASE_UUID, UUID.fromString(WRONG_VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); // get voltage init parameters mockMvc.perform(get("/v1/studies/{studyUuid}/voltage-init/parameters", studyEntity2.getId())).andExpect( @@ -451,7 +487,7 @@ void testVoltageInitParameters(final MockWebServer server) throws Exception { @Test void testUpdatingParametersWithSameComputationParametersDoesNotInvalidate(final MockWebServer server) throws Exception { - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); // Just changing applyModifications value but keeping the same computing parameters StudyVoltageInitParameters studyVoltageInitParameters = StudyVoltageInitParameters.builder() .applyModifications(false) @@ -476,7 +512,7 @@ void testUpdatingParametersWithSameComputationParametersDoesNotInvalidate(final @Test void testApplyModificationsWhenParameterIsActivated(final MockWebServer server) throws Exception { StudyEntity studyEntity = insertDummyStudy( - UUID.fromString(NETWORK_UUID_STRING), + NETWORK_UUID, CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), true); @@ -509,7 +545,7 @@ void testApplyModificationsWhenParameterIsActivated(final MockWebServer server) @Test void testVoltageInit(final MockWebServer server) throws Exception { //insert a study - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); UUID studyNameUserIdUuid = studyEntity.getId(); UUID firstRootNetworkUuid = studyTestUtils.getOneRootNetworkUuid(studyNameUserIdUuid); UUID rootNodeUuid = getRootNode(studyNameUserIdUuid).getId(); @@ -535,14 +571,14 @@ void testVoltageInit(final MockWebServer server) throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); checkReactiveSlacksAlertMessagesReceived(studyNameUserIdUuid, 10.); checkVoltageLevelLimitsOutOfRangeAlertMessagesReceived(studyNameUserIdUuid); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.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))); @@ -579,7 +615,7 @@ void testVoltageInit(final MockWebServer server) throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/stop\\?receiver=.*nodeUuid.*"))); @@ -587,9 +623,9 @@ void testVoltageInit(final MockWebServer server) throws Exception { .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_FAILED); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_FAILED); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.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))); @@ -600,7 +636,7 @@ void testVoltageInit(final MockWebServer server) throws Exception { @Test void testVoltageInitCancelFail(final MockWebServer server) throws Exception { //insert a study - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); UUID studyNameUserIdUuid = studyEntity.getId(); UUID firstRootNetworkUuid = studyTestUtils.getOneRootNetworkUuid(studyNameUserIdUuid); UUID rootNodeUuid = getRootNode(studyNameUserIdUuid).getId(); @@ -626,14 +662,14 @@ void testVoltageInitCancelFail(final MockWebServer server) 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, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); checkReactiveSlacksAlertMessagesReceived(studyNameUserIdUuid, 10.); checkVoltageLevelLimitsOutOfRangeAlertMessagesReceived(studyNameUserIdUuid); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); // stop voltage init analysis fail mockMvc.perform(put("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/voltage-init/stop", studyNameUserIdUuid, firstRootNetworkUuid, modificationNode4Uuid) @@ -645,7 +681,7 @@ void testVoltageInitCancelFail(final MockWebServer server) throws Exception { @Test void testInsertVoltageInitModifications(final MockWebServer server) throws Exception { - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); UUID studyNameUserIdUuid = studyEntity.getId(); UUID firstRootNetworkUuid = studyTestUtils.getOneRootNetworkUuid(studyNameUserIdUuid); UUID rootNodeUuid = getRootNode(studyNameUserIdUuid).getId(); @@ -662,11 +698,11 @@ void testInsertVoltageInitModifications(final MockWebServer server) throws Excep .header("userId", "userId")) .andExpect(status().isOk()); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); checkReactiveSlacksAlertMessagesReceived(studyNameUserIdUuid, 10.); checkVoltageLevelLimitsOutOfRangeAlertMessagesReceived(studyNameUserIdUuid); - checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, firstRootNetworkUuid, NotificationService.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 @@ -679,7 +715,7 @@ void testInsertVoltageInitModifications(final MockWebServer server) throws Excep assertTrue(networkModificationTreeService.getNodeBuildStatus(modificationNode3Uuid, firstRootNetworkUuid).isBuilt()); - // clone and copy modifications to modificationNode3Uuid + // clone and insert voltage-init modification to modificationNode3Uuid mockMvc.perform(post("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/network-modifications/voltage-init", studyNameUserIdUuid, firstRootNetworkUuid, modificationNode3Uuid) .header("userId", "userId")).andExpect(status().isOk()); assertTrue(TestUtils.getRequestsDone(4, server).stream().allMatch(r -> @@ -690,7 +726,7 @@ void testInsertVoltageInitModifications(final MockWebServer server) throws Excep checkInsertVoltageInitModifications(studyNameUserIdUuid, modificationNode3Uuid, firstRootNetworkUuid, true); - // clone and copy modifications to modificationNode3Uuid with LF result -> node is invalidated + // insert again voltage-init modification to modificationNode3Uuid, with LF result -> node is invalidated when(loadFlowService.getLoadFlowStatus(any())).thenReturn(LoadFlowStatus.CONVERGED); mockMvc.perform(post("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/network-modifications/voltage-init", studyNameUserIdUuid, firstRootNetworkUuid, modificationNode3Uuid) .header("userId", "userId")).andExpect(status().isOk()); @@ -706,31 +742,137 @@ void testInsertVoltageInitModifications(final MockWebServer server) throws Excep checkInsertVoltageInitModifications(studyNameUserIdUuid, modificationNode3Uuid, firstRootNetworkUuid, false); } + @Test + void testInsertVoltageInitModificationsWithTwoRootNetworks(final MockWebServer server) throws Exception { + StudyEntity study = StudyEntity.builder() + .id(UUID.randomUUID()) + .voltageInitParametersUuid(UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING)) + .voltageInitParameters(new StudyVoltageInitParametersEntity(false)) + .build(); + UUID firstRootNetworkUuid = UUID.fromString("3468163e-4a3e-479d-a665-a1b2fde0505d"); + UUID secondRootNetworkUuid = UUID.fromString("fb21f8ba-8025-41e0-a168-db1af1799896"); + RootNetworkEntity firstRootNetworkEntity = RootNetworkEntity.builder() + .id(firstRootNetworkUuid) + .name("rootNetworkName") + .tag("rn1") + .networkUuid(NETWORK_UUID) + .networkId("netId") + .caseUuid(CASE_UUID) + .caseFormat("caseFormat") + .caseName("caseName") + .indexationStatus(RootNetworkIndexationStatus.INDEXED) + .build(); + RootNetworkEntity secondRootNetworkEntity = RootNetworkEntity.builder() + .id(secondRootNetworkUuid) + .name("rootNetworkName2") + .tag("rn2") + .networkUuid(SECOND_NETWORK_UUID) + .networkId("netId2") + .caseUuid(CASE_UUID) + .caseFormat("caseFormat") + .caseName("caseName") + .indexationStatus(RootNetworkIndexationStatus.INDEXED) + .build(); + study.addRootNetwork(firstRootNetworkEntity); + study.addRootNetwork(secondRootNetworkEntity); + studyRepository.save(study); + NodeEntity rootNode = insertRootNode(study, UUID.randomUUID()); + NodeEntity node = insertNode(study, rootNode, VARIANT_ID_2, VARIANT_ID_3, firstRootNetworkEntity, secondRootNetworkEntity); + UUID nodeUuid = node.getIdNode(); + UUID studyUuid = study.getId(); + + // run a voltage init analysis on 1st root network + mockMvc.perform(put("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/voltage-init/run", studyUuid, firstRootNetworkUuid, nodeUuid) + .header("userId", "userId")) + .andExpect(status().isOk()); + checkUpdateModelStatusMessagesReceived(studyUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkReactiveSlacksAlertMessagesReceived(studyUuid, 10.); + checkVoltageLevelLimitsOutOfRangeAlertMessagesReceived(studyUuid); + checkUpdateModelStatusMessagesReceived(studyUuid, firstRootNetworkUuid, NotificationService.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))); + + // clone and insert voltage-init modification + mockMvc.perform(post("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/network-modifications/voltage-init", studyUuid, firstRootNetworkUuid, nodeUuid) + .header("userId", "userId")).andExpect(status().isOk()); + assertTrue(TestUtils.getRequestsDone(4, server).stream().allMatch(r -> + r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/modifications-group-uuid") || + r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/status") || + r.matches("/v1/groups/.*\\?action=COPY&originGroupUuid=.*") + )); + checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid); + checkEquipmentMessagesReceived(studyUuid, nodeUuid, NetworkImpactsInfos.builder().impactedSubstationsIds(ImmutableSet.of("s1")).build()); + checkUpdateModelStatusMessagesReceived(studyUuid, firstRootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); // results only for 1st root network + checkElementUpdatedMessageSent(studyUuid, "userId"); + checkUpdateModelsStatusMessagesReceived(studyUuid, firstRootNetworkUuid); + checkUpdateModelsStatusMessagesReceived(studyUuid, secondRootNetworkUuid); + checkEquipmentUpdatingFinishedMessagesReceived(studyUuid, nodeUuid); + + ModificationApplicationContext ctx1 = rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, nodeUuid, NETWORK_UUID); + ModificationApplicationContext ctx2 = rootNetworkNodeInfoService.getNetworkModificationApplicationContext(secondRootNetworkUuid, nodeUuid, SECOND_NETWORK_UUID); + assertEquals(0, ctx1.excludedModifications().size()); + assertEquals(1, ctx2.excludedModifications().size()); + assertTrue(ctx2.excludedModifications().contains(VOLTAGE_INIT_MODIFICATION_UUID)); // voltage-init modification not activated on 2nd root network + + // Error case: try to generate the voltageInit modification on the second root network (where no computation has been made) + mockMvc.perform(post("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/network-modifications/voltage-init", studyUuid, secondRootNetworkUuid, nodeUuid) + .header("userId", "userId")).andExpect(status().isNotFound()); + assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/status"))); + } + + private NodeEntity insertRootNode(StudyEntity study, UUID nodeId) { + NodeEntity node = nodeRepository.save(new NodeEntity(nodeId, null, NodeType.ROOT, study, false, null)); + RootNodeInfoEntity rootNodeInfo = new RootNodeInfoEntity(); + rootNodeInfo.setIdNode(node.getIdNode()); + rootNodeInfoRepository.save(rootNodeInfo); + return node; + } + + private NodeEntity insertNode(StudyEntity study, NodeEntity parentNode, String firstVariantId, String secondVariantId, + RootNetworkEntity firstRootNetworkEntity, RootNetworkEntity secondRootNetworkEntity) { + NodeEntity nodeEntity = nodeRepository.save(new NodeEntity(null, parentNode, NodeType.NETWORK_MODIFICATION, study, false, null)); + NetworkModificationNodeInfoEntity modificationNodeInfoEntity = networkModificationNodeInfoRepository.save(NetworkModificationNodeInfoEntity.builder().idNode(nodeEntity.getIdNode()).modificationGroupUuid(UUID.randomUUID()).build()); + createNodeLinks(firstRootNetworkEntity, modificationNodeInfoEntity, firstVariantId, UUID.randomUUID(), BuildStatus.BUILT); + createNodeLinks(secondRootNetworkEntity, modificationNodeInfoEntity, secondVariantId, UUID.randomUUID(), BuildStatus.NOT_BUILT); + rootNetworkRepository.save(firstRootNetworkEntity); + rootNetworkRepository.save(secondRootNetworkEntity); + return nodeEntity; + } + + // We can't use the method RootNetworkNodeInfoService::createNodeLinks because there is no transaction in a session + private void createNodeLinks(RootNetworkEntity rootNetworkEntity, NetworkModificationNodeInfoEntity modificationNodeInfoEntity, + String variantId, UUID reportUuid, BuildStatus buildStatus) { + RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = RootNetworkNodeInfoEntity.builder().variantId(variantId).modificationReports(Map.of(modificationNodeInfoEntity.getId(), reportUuid)).nodeBuildStatus(NodeBuildStatus.from(buildStatus).toEntity()).build(); + modificationNodeInfoEntity.addRootNetworkNodeInfo(rootNetworkNodeInfoEntity); + rootNetworkEntity.addRootNetworkNodeInfo(rootNetworkNodeInfoEntity); + rootNetworkNodeInfoRepository.save(rootNetworkNodeInfoEntity); + } + private void checkInsertVoltageInitModifications(UUID studyUuid, UUID modificationNodeUuid, UUID rootNetworkUuid, boolean isBuildNode) throws Exception { NodeBuildStatus nodeBuildStatus = networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, rootNetworkUuid); assertTrue(isBuildNode ? nodeBuildStatus.isBuilt() : nodeBuildStatus.isNotBuilt()); checkEquipmentUpdatingMessagesReceived(studyUuid, modificationNodeUuid); checkEquipmentMessagesReceived(studyUuid, modificationNodeUuid, NetworkImpactsInfos.builder().impactedSubstationsIds(ImmutableSet.of("s1")).build()); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_RESULT); if (!isBuildNode) { - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.NODE_BUILD_STATUS_UPDATED); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.NODE_BUILD_STATUS_UPDATED); } - checkUpdateModelsStatusMessagesReceived(studyUuid); + checkUpdateModelsStatusMessagesReceived(studyUuid, rootNetworkUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyUuid, "userId"); } - 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_DYNAMIC_SECURITY_ANALYSIS_STATUS); - checkUpdateModelStatusMessagesReceived(studyUuid, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); + private void checkUpdateModelsStatusMessagesReceived(UUID studyUuid, UUID rootNetworkUuid) { + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_DYNAMIC_SECURITY_ANALYSIS_STATUS); + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, NotificationService.UPDATE_TYPE_STATE_ESTIMATION_STATUS); } private void checkEquipmentMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid, NetworkImpactsInfos expectedPayload) throws Exception { @@ -781,10 +923,10 @@ void testNotResetedUuidResultWhenVoltageInitFailed() throws Exception { // Set an uuid result in the database rootNetworkNodeInfoService.updateComputationResultUuid(modificationNode.getId(), rootNetworkUuid, resultUuid, VOLTAGE_INITIALIZATION); - assertTrue(rootNetworkNodeInfoService.getComputationResultUuid(modificationNode.getId(), rootNetworkUuid, VOLTAGE_INITIALIZATION) != null); + assertNotNull(rootNetworkNodeInfoService.getComputationResultUuid(modificationNode.getId(), rootNetworkUuid, VOLTAGE_INITIALIZATION)); assertEquals(resultUuid, rootNetworkNodeInfoService.getComputationResultUuid(modificationNode.getId(), rootNetworkUuid, VOLTAGE_INITIALIZATION)); - StudyService studyService = Mockito.mock(StudyService.class); + StudyService mockStudyService = Mockito.mock(StudyService.class); doAnswer(invocation -> { input.send( MessageBuilder.withPayload("") @@ -792,8 +934,8 @@ void testNotResetedUuidResultWhenVoltageInitFailed() throws Exception { .setHeader("resultUuid", VOLTAGE_INIT_ERROR_RESULT_UUID) .build(), voltageInitFailedDestination); return resultUuid; - }).when(studyService).runVoltageInit(any(), any(), any(), any()); - studyService.runVoltageInit(studyEntity.getId(), modificationNode.getId(), rootNetworkUuid, ""); + }).when(mockStudyService).runVoltageInit(any(), any(), any(), any()); + mockStudyService.runVoltageInit(studyEntity.getId(), modificationNode.getId(), rootNetworkUuid, ""); // Test doesn't reset uuid result in the database assertEquals(VOLTAGE_INIT_ERROR_RESULT_UUID, rootNetworkNodeInfoService.getComputationResultUuid(modificationNode.getId(), rootNetworkUuid, VOLTAGE_INITIALIZATION).toString()); @@ -804,14 +946,15 @@ void testNotResetedUuidResultWhenVoltageInitFailed() throws Exception { assertEquals(NotificationService.UPDATE_TYPE_VOLTAGE_INIT_FAILED, updateType); } - private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, String updateTypeToCheck) { - checkUpdateModelStatusMessagesReceived(studyUuid, updateTypeToCheck, null); + private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, UUID rootNetworkUuid, String updateTypeToCheck) { + checkUpdateModelStatusMessagesReceived(studyUuid, rootNetworkUuid, updateTypeToCheck, null); } - private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, String updateTypeToCheck, String otherUpdateTypeToCheck) { - Message voltageInitStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); - assertEquals(studyUuid, voltageInitStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); - String updateType = (String) voltageInitStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE); + private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, UUID rootNetworkUuid, String updateTypeToCheck, String otherUpdateTypeToCheck) { + Message message = output.receive(TIMEOUT, studyUpdateDestination); + assertEquals(studyUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); + assertEquals(rootNetworkUuid, message.getHeaders().get(HEADER_ROOT_NETWORK_UUID)); + String updateType = (String) message.getHeaders().get(HEADER_UPDATE_TYPE); if (otherUpdateTypeToCheck == null) { assertEquals(updateTypeToCheck, updateType); } else { @@ -852,7 +995,7 @@ private void testDeleteResults(final MockWebServer server, int expectedInitialRe @Test void testNoResult() throws Exception { //insert a study - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, UUID.fromString(VOLTAGE_INIT_PARAMETERS_UUID_STRING), false); UUID studyNameUserIdUuid = studyEntity.getId(); UUID firstRootNetworkUuid = studyTestUtils.getOneRootNetworkUuid(studyNameUserIdUuid); UUID rootNodeUuid = getRootNode(studyNameUserIdUuid).getId(); @@ -875,7 +1018,7 @@ void testNoResult() throws Exception { @Test void testResetVoltageInitParametersUserHasNoProfile(final MockWebServer server) throws Exception { - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, VOLTAGE_INIT_PARAMETERS_UUID, false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, VOLTAGE_INIT_PARAMETERS_UUID, false); UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, null, NO_PROFILE_USER_ID, HttpStatus.OK); @@ -886,7 +1029,7 @@ void testResetVoltageInitParametersUserHasNoProfile(final MockWebServer server) @Test void testResetVoltageInitParametersUserHasNoParamsInProfile(final MockWebServer server) throws Exception { - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, VOLTAGE_INIT_PARAMETERS_UUID, false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, VOLTAGE_INIT_PARAMETERS_UUID, false); UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, null, NO_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); @@ -897,7 +1040,7 @@ void testResetVoltageInitParametersUserHasNoParamsInProfile(final MockWebServer @Test void testResetVoltageInitParametersUserHasInvalidParamsInProfile(final MockWebServer server) throws Exception { - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, VOLTAGE_INIT_PARAMETERS_UUID, false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, VOLTAGE_INIT_PARAMETERS_UUID, false); UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, null, INVALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.NO_CONTENT); @@ -909,7 +1052,7 @@ void testResetVoltageInitParametersUserHasInvalidParamsInProfile(final MockWebSe @Test void testResetVoltageInitParametersUserHasValidParamsInProfile(final MockWebServer server) throws Exception { - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, VOLTAGE_INIT_PARAMETERS_UUID, false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, VOLTAGE_INIT_PARAMETERS_UUID, false); UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, null, VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); @@ -921,7 +1064,7 @@ void testResetVoltageInitParametersUserHasValidParamsInProfile(final MockWebServ @Test void testResetVoltageInitParametersUserHasValidParamsInProfileButNoExistingVoltageInitParams(final MockWebServer server) throws Exception { - StudyEntity studyEntity = insertDummyStudy(UUID.fromString(NETWORK_UUID_STRING), CASE_UUID, null, false); + StudyEntity studyEntity = insertDummyStudy(NETWORK_UUID, CASE_UUID, null, false); UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, null, VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); @@ -985,6 +1128,11 @@ private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UU void tearDown(final MockWebServer server) { studyRepository.findAll().forEach(s -> networkModificationTreeService.doDeleteTree(s.getId())); studyRepository.deleteAll(); + rootNodeInfoRepository.deleteAll(); + networkModificationNodeInfoRepository.deleteAll(); + nodeRepository.deleteAll(); + rootNetworkRepository.deleteAll(); + studyRepository.deleteAll(); List destinations = List.of(studyUpdateDestination, voltageInitResultDestination, voltageInitStoppedDestination, voltageInitFailedDestination, voltageInitCancelFailedDestination); TestUtils.assertQueuesEmptyThenClear(destinations, output);