diff --git a/src/main/java/org/gridsuite/study/server/controller/StudyController.java b/src/main/java/org/gridsuite/study/server/controller/StudyController.java index 0714bc3aa..6866ce67b 100644 --- a/src/main/java/org/gridsuite/study/server/controller/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/controller/StudyController.java @@ -1379,7 +1379,7 @@ public ResponseEntity deleteNode(@Parameter(description = "study uuid") @P @ApiResponse(responseCode = "404", description = "The study or the node not found")}) public ResponseEntity stashNode(@Parameter(description = "study uuid") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "id of child to delete (move to trash)") @PathVariable("id") UUID nodeId, - @Parameter(description = "stashChildren") @RequestParam(value = "stashChildren", defaultValue = "false") boolean stashChildren, + @Parameter(description = "to stash a node with its children") @RequestParam(value = "stashChildren", defaultValue = "false") boolean stashChildren, @RequestHeader(HEADER_USER_ID) String userId) { studyService.stashNode(studyUuid, nodeId, stashChildren, userId); return ResponseEntity.ok().build(); @@ -1513,7 +1513,7 @@ public ResponseEntity buildNode(@Parameter(description = "Study uuid") @Pa public ResponseEntity unbuildNode(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "rootNetworkUuid") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { - studyService.unbuildNode(studyUuid, nodeUuid, rootNetworkUuid); + studyService.unbuildStudyNode(studyUuid, nodeUuid, rootNetworkUuid); return ResponseEntity.ok().build(); } diff --git a/src/main/java/org/gridsuite/study/server/controller/SupervisionController.java b/src/main/java/org/gridsuite/study/server/controller/SupervisionController.java index 0f55b436b..ed445d8b2 100644 --- a/src/main/java/org/gridsuite/study/server/controller/SupervisionController.java +++ b/src/main/java/org/gridsuite/study/server/controller/SupervisionController.java @@ -150,7 +150,7 @@ public ResponseEntity reindexStudy(@Parameter(description = "study uuid") @Operation(summary = "Invalidate node builds for the given study") @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "all built nodes for the given study have been invalidated")}) public ResponseEntity invalidateAllNodesBuilds(@PathVariable("studyUuid") UUID studyUuid) { - supervisionService.invalidateAllNodesBuilds(studyUuid); + supervisionService.unbuildAllNodes(studyUuid); return ResponseEntity.ok().build(); } diff --git a/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java b/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java index aca6b1b5e..0b58c6be4 100644 --- a/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java +++ b/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java @@ -10,42 +10,93 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.UUID; /** * @author Nicolas Noir */ - @NoArgsConstructor -@Getter -@Setter public class InvalidateNodeInfos { + @Getter + @Setter private UUID networkUuid; - private List reportUuids = new ArrayList<>(); + private Set nodeUuids = new HashSet<>(); + private Set groupUuids = new HashSet<>(); + + private Set reportUuids = new HashSet<>(); + private Set variantIds = new HashSet<>(); + + private Set loadFlowResultUuids = new HashSet<>(); + private Set securityAnalysisResultUuids = new HashSet<>(); + private Set sensitivityAnalysisResultUuids = new HashSet<>(); + private Set nonEvacuatedEnergyResultUuids = new HashSet<>(); + private Set shortCircuitAnalysisResultUuids = new HashSet<>(); + private Set oneBusShortCircuitAnalysisResultUuids = new HashSet<>(); + private Set voltageInitResultUuids = new HashSet<>(); + private Set stateEstimationResultUuids = new HashSet<>(); + + private Set dynamicSimulationResultUuids = new HashSet<>(); + private Set dynamicSecurityAnalysisResultUuids = new HashSet<>(); + + public List getNodeUuids() { + return nodeUuids.stream().toList(); + } + + public List getGroupUuids() { + return groupUuids.stream().toList(); + } - private List variantIds = new ArrayList<>(); + public List getReportUuids() { + return reportUuids.stream().toList(); + } + + public List getVariantIds() { + return variantIds.stream().toList(); + } + + public List getLoadFlowResultUuids() { + return loadFlowResultUuids.stream().toList(); + } + + public List getSecurityAnalysisResultUuids() { + return securityAnalysisResultUuids.stream().toList(); + } - private List loadFlowResultUuids = new ArrayList<>(); + public List getSensitivityAnalysisResultUuids() { + return sensitivityAnalysisResultUuids.stream().toList(); + } - private List securityAnalysisResultUuids = new ArrayList<>(); + public List getNonEvacuatedEnergyResultUuids() { + return nonEvacuatedEnergyResultUuids.stream().toList(); + } - private List sensitivityAnalysisResultUuids = new ArrayList<>(); - private List nonEvacuatedEnergyResultUuids = new ArrayList<>(); + public List getShortCircuitAnalysisResultUuids() { + return shortCircuitAnalysisResultUuids.stream().toList(); + } - private List shortCircuitAnalysisResultUuids = new ArrayList<>(); - private List oneBusShortCircuitAnalysisResultUuids = new ArrayList<>(); + public List getOneBusShortCircuitAnalysisResultUuids() { + return oneBusShortCircuitAnalysisResultUuids.stream().toList(); + } - private List voltageInitResultUuids = new ArrayList<>(); + public List getVoltageInitResultUuids() { + return voltageInitResultUuids.stream().toList(); + } - private List dynamicSimulationResultUuids = new ArrayList<>(); - private List dynamicSecurityAnalysisResultUuids = new ArrayList<>(); + public List getStateEstimationResultUuids() { + return stateEstimationResultUuids.stream().toList(); + } - private List stateEstimationResultUuids = new ArrayList<>(); + public List getDynamicSimulationResultUuids() { + return dynamicSimulationResultUuids.stream().toList(); + } - private List groupUuids = new ArrayList<>(); + public List getDynamicSecurityAnalysisResultUuids() { + return dynamicSecurityAnalysisResultUuids.stream().toList(); + } public void addReportUuid(UUID reportUuid) { reportUuids.add(reportUuid); @@ -56,7 +107,7 @@ public void addVariantId(String variantId) { } public void addLoadFlowResultUuid(UUID loadFlowResultUuid) { - getLoadFlowResultUuids().add(loadFlowResultUuid); + loadFlowResultUuids.add(loadFlowResultUuid); } public void addSecurityAnalysisResultUuid(UUID securityAnalysisResultUuid) { @@ -95,7 +146,31 @@ public void addStateEstimationResultUuid(UUID stateEstimationResultUuid) { stateEstimationResultUuids.add(stateEstimationResultUuid); } - public void addGroupUuid(List groupUuids) { + public void addGroupUuids(List groupUuids) { this.groupUuids.addAll(groupUuids); } + + public void addNodeUuid(UUID nodeUuid) { + this.nodeUuids.add(nodeUuid); + } + + public void add(InvalidateNodeInfos invalidateNodeInfos) { + nodeUuids.addAll(invalidateNodeInfos.getNodeUuids()); + groupUuids.addAll(invalidateNodeInfos.getGroupUuids()); + + reportUuids.addAll(invalidateNodeInfos.getReportUuids()); + variantIds.addAll(invalidateNodeInfos.getVariantIds()); + + loadFlowResultUuids.addAll(invalidateNodeInfos.getLoadFlowResultUuids()); + securityAnalysisResultUuids.addAll(invalidateNodeInfos.getSecurityAnalysisResultUuids()); + sensitivityAnalysisResultUuids.addAll(invalidateNodeInfos.getSensitivityAnalysisResultUuids()); + nonEvacuatedEnergyResultUuids.addAll(invalidateNodeInfos.getNonEvacuatedEnergyResultUuids()); + shortCircuitAnalysisResultUuids.addAll(invalidateNodeInfos.getShortCircuitAnalysisResultUuids()); + oneBusShortCircuitAnalysisResultUuids.addAll(invalidateNodeInfos.getOneBusShortCircuitAnalysisResultUuids()); + voltageInitResultUuids.addAll(invalidateNodeInfos.getVoltageInitResultUuids()); + stateEstimationResultUuids.addAll(invalidateNodeInfos.getStateEstimationResultUuids()); + + dynamicSimulationResultUuids.addAll(invalidateNodeInfos.getDynamicSimulationResultUuids()); + dynamicSecurityAnalysisResultUuids.addAll(invalidateNodeInfos.getDynamicSecurityAnalysisResultUuids()); + } } diff --git a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java index 042b27933..115175d63 100644 --- a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java +++ b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java @@ -326,7 +326,7 @@ public void emitSubtreeInserted(UUID studyUuid, UUID parentNodeSubtreeInserted, } @PostCompletion - public void emitNodeBuildStatusUpdated(UUID studyUuid, Collection nodes, UUID rootNetworkUuid) { + public void emitNodeBuildStatusUpdated(UUID studyUuid, List nodes, UUID rootNetworkUuid) { sendStudyUpdateMessage(studyUuid, NODE_BUILD_STATUS_UPDATED, MessageBuilder.withPayload("") .setHeader(HEADER_NODES, nodes) .setHeader(HEADER_ROOT_NETWORK_UUID, rootNetworkUuid) diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index 519c785f3..db97cc085 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -793,7 +793,7 @@ public void invalidateBuild(UUID nodeUuid, UUID rootNetworkUuid, boolean invalid changedNodes.add(nodeUuid); UUID studyId = self.getStudyUuidForNodeId(nodeUuid); nodesRepository.findById(nodeUuid).ifPresent(nodeEntity -> { - fillIndexedModificationsInfosToInvalidate(invalidateNodeInfos, nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus); + fillIndexedNodeInfosToInvalidate(invalidateNodeInfos, nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus); if (rootNetworkService.exists(rootNetworkUuid)) { if (nodeEntity.getType().equals(NodeType.NETWORK_MODIFICATION)) { rootNetworkNodeInfoService.invalidateRootNetworkNodeInfoProper(nodeUuid, rootNetworkUuid, invalidateNodeInfos, invalidateOnlyChildrenBuildStatus, changedNodes, deleteVoltageInitResults); @@ -802,10 +802,10 @@ public void invalidateBuild(UUID nodeUuid, UUID rootNetworkUuid, boolean invalid } }); - notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().collect(Collectors.toList()), rootNetworkUuid); + notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().toList(), rootNetworkUuid); } - private void fillIndexedModificationsInfosToInvalidate(InvalidateNodeInfos invalidateNodeInfos, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { + private void fillIndexedNodeInfosToInvalidate(InvalidateNodeInfos invalidateNodeInfos, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { // when invalidating node // we need to invalidate indexed modifications up to it's last built parent, not included boolean isNodeBuilt = self.getNodeBuildStatus(nodeUuid, rootNetworkUuid).isBuilt(); @@ -814,13 +814,47 @@ private void fillIndexedModificationsInfosToInvalidate(InvalidateNodeInfos inval } if (isNodeBuilt && invalidateOnlyChildrenBuildStatus) { - fillIndexedModificationsInfosToInvalidate(nodeUuid, false, invalidateNodeInfos); + fillIndexedNodeInfosToInvalidate(nodeUuid, false, invalidateNodeInfos); } else { NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeUuid, rootNetworkUuid); - fillIndexedModificationsInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); } } + @Transactional + public InvalidateNodeInfos invalidateNode(UUID nodeUuid, UUID rootNetworkUuid) { + NodeEntity nodeEntity = getNodeEntity(nodeUuid); + + InvalidateNodeInfos invalidateNodeInfos = rootNetworkNodeInfoService.invalidateRootNetworkNode(nodeUuid, rootNetworkUuid, true); + + fillIndexedNodeInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); + + notificationService.emitNodeBuildStatusUpdated(nodeEntity.getStudy().getId(), List.of(nodeUuid), rootNetworkUuid); + + return invalidateNodeInfos; + } + + @Transactional + public InvalidateNodeInfos invalidateNodeTree(UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { + NodeEntity nodeEntity = getNodeEntity(nodeUuid); + + InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); + + // First node + if (nodeEntity.getType().equals(NodeType.NETWORK_MODIFICATION)) { + invalidateNodeInfos = rootNetworkNodeInfoService.invalidateRootNetworkNode(nodeUuid, rootNetworkUuid, !invalidateOnlyChildrenBuildStatus); + fillIndexedNodeTreeInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); + } + + invalidateNodeInfos.add(invalidateChildrenNodes(nodeUuid, rootNetworkUuid)); + + if (!invalidateNodeInfos.getNodeUuids().isEmpty()) { + notificationService.emitNodeBuildStatusUpdated(nodeEntity.getStudy().getId(), invalidateNodeInfos.getNodeUuids().stream().toList(), rootNetworkUuid); + } + + return invalidateNodeInfos; + } + @Transactional // method used when moving a node to invalidate it without impacting other nodes public void invalidateBuildOfNodeOnly(UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus, InvalidateNodeInfos invalidateNodeInfos, boolean deleteVoltageInitResults) { @@ -840,10 +874,10 @@ public void invalidateBuildOfNodeOnly(UUID nodeUuid, UUID rootNetworkUuid, boole if (!hasAnyBuiltChildren(getNodeEntity(nodeUuid), rootNetworkUuid)) { // when invalidating nodes, we need to get last built parent to invalidate all its children modifications in elasticsearch NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeUuid, rootNetworkUuid); - fillIndexedModificationsInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); } - notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().collect(Collectors.toList()), rootNetworkUuid); + notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().toList(), rootNetworkUuid); } /** @@ -895,6 +929,46 @@ && hasAnyBuiltChildren(child, rootNetworkUuid, checkedChildren)) { return false; } + private void fillIndexedNodeInfosToInvalidate(NodeEntity nodeEntity, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { + // when manually invalidating a single node, if this node does not have any built children + // we need to invalidate indexed modifications up to it's last built parent, not included + if (hasAnyBuiltChildren(nodeEntity, rootNetworkUuid)) { + return; + } + + // when invalidating nodes, we need to get last built parent to invalidate all its children modifications in elasticsearch + NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeEntity.getIdNode(), rootNetworkUuid); + fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + } + + // For subTree + private void fillIndexedNodeTreeInfosToInvalidate(NodeEntity nodeEntity, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { + // when invalidating node + // we need to invalidate indexed modifications up to it's last built parent, not included + boolean isNodeBuilt = self.getNodeBuildStatus(nodeEntity.getIdNode(), rootNetworkUuid).isBuilt(); + if (!isNodeBuilt && !hasAnyBuiltChildren(getNodeEntity(nodeEntity.getIdNode()), rootNetworkUuid)) { + return; + } + + // TODO check invalidateOnlyChildrenBuildStatus + if (isNodeBuilt) { + fillIndexedNodeInfosToInvalidate(nodeEntity.getIdNode(), false, invalidateNodeInfos); + } else { + NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeEntity.getIdNode(), rootNetworkUuid); + fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + } + } + + private InvalidateNodeInfos invalidateChildrenNodes(UUID nodeUuid, UUID rootNetworkUuid) { + InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); + nodesRepository.findAllByParentNodeIdNode(nodeUuid) + .forEach(child -> { + invalidateNodeInfos.add(rootNetworkNodeInfoService.invalidateRootNetworkNode(child.getIdNode(), rootNetworkUuid, true)); + invalidateNodeInfos.add(invalidateChildrenNodes(child.getIdNode(), rootNetworkUuid)); + }); + return invalidateNodeInfos; + } + private void invalidateChildrenBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, List changedNodes, InvalidateNodeInfos invalidateNodeInfos, boolean deleteVoltageInitResults) { nodesRepository.findAllByParentNodeIdNode(nodeUuid) @@ -906,7 +980,6 @@ private void invalidateChildrenBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, @Transactional public void updateNodeBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, NodeBuildStatus nodeBuildStatus) { - List changedNodes = new ArrayList<>(); UUID studyId = self.getStudyUuidForNodeId(nodeUuid); RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoService.getRootNetworkNodeInfo(nodeUuid, rootNetworkUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); NodeEntity nodeEntity = getNodeEntity(nodeUuid); @@ -932,8 +1005,7 @@ public void updateNodeBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, NodeBuild } rootNetworkNodeInfoEntity.setNodeBuildStatus(newNodeStatus); - changedNodes.add(nodeUuid); - notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes, rootNetworkUuid); + notificationService.emitNodeBuildStatusUpdated(studyId, List.of(nodeUuid), rootNetworkUuid); } @Transactional(readOnly = true) @@ -1034,13 +1106,13 @@ public long countBuiltNodes(UUID studyUuid, UUID rootNetworkUuid) { return nodes.stream().filter(n -> self.getNodeBuildStatus(n.getIdNode(), rootNetworkUuid).isBuilt()).count(); } - private void fillIndexedModificationsInfosToInvalidate(UUID parentNodeUuid, boolean includeParentNode, InvalidateNodeInfos invalidateNodeInfos) { + private void fillIndexedNodeInfosToInvalidate(UUID parentNodeUuid, boolean includeParentNode, InvalidateNodeInfos invalidateNodeInfos) { List nodesToInvalidate = new ArrayList<>(); if (includeParentNode) { nodesToInvalidate.add(parentNodeUuid); } nodesToInvalidate.addAll(getChildren(parentNodeUuid)); - invalidateNodeInfos.addGroupUuid( + invalidateNodeInfos.addGroupUuids( networkModificationNodeInfoRepository.findAllById(nodesToInvalidate).stream() .map(NetworkModificationNodeInfoEntity::getModificationGroupUuid).toList() ); diff --git a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java index 0f2733506..f87d57163 100644 --- a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java +++ b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java @@ -224,6 +224,45 @@ public void fillDeleteNodeInfo(UUID nodeUuid, DeleteNodeInfos deleteNodeInfos) { }); } + public InvalidateNodeInfos invalidateRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid, boolean withInvalidationBuildStatus) { + RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); + + // No need to invalidate a node with a status different of "BUILT" + if (!rootNetworkNodeInfoEntity.getNodeBuildStatus().toDto().isBuilt()) { + return new InvalidateNodeInfos(); + } + + InvalidateNodeInfos invalidateNodeInfos = getInvalidationComputationInfos(rootNetworkNodeInfoEntity); + + if (withInvalidationBuildStatus) { + rootNetworkNodeInfoEntity.getModificationReports().forEach((key, value) -> invalidateNodeInfos.addReportUuid(value)); + invalidateNodeInfos.addVariantId(rootNetworkNodeInfoEntity.getVariantId()); + invalidateBuildStatus(rootNetworkNodeInfoEntity, invalidateNodeInfos); + } + + invalidateComputationResults(rootNetworkNodeInfoEntity); + + return invalidateNodeInfos; + } + + private static void invalidateComputationResults(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { + rootNetworkNodeInfoEntity.setLoadFlowResultUuid(null); + rootNetworkNodeInfoEntity.setSecurityAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setSensitivityAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setNonEvacuatedEnergyResultUuid(null); + rootNetworkNodeInfoEntity.setShortCircuitAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setOneBusShortCircuitAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setDynamicSimulationResultUuid(null); + rootNetworkNodeInfoEntity.setDynamicSecurityAnalysisResultUuid(null); + //TODO: add more checks for Voltage init + rootNetworkNodeInfoEntity.setVoltageInitResultUuid(null); + rootNetworkNodeInfoEntity.setStateEstimationResultUuid(null); + + // Update the computation reports in the repository + //TODO: add more checks for Voltage init + rootNetworkNodeInfoEntity.setComputationReports(new HashMap<>()); + } + public void invalidateRootNetworkNodeInfoProper(UUID nodeUuid, UUID rootNetworUuid, InvalidateNodeInfos invalidateNodeInfos, boolean invalidateOnlyChildrenBuildStatus, List changedNodes, boolean deleteVoltageInitResults) { RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); @@ -259,6 +298,18 @@ public void invalidateRootNetworkNodeInfoProper(UUID nodeUuid, UUID rootNetworUu } } + private InvalidateNodeInfos getInvalidationComputationInfos(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { + InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); + + rootNetworkNodeInfoEntity.getComputationReports().forEach((key, value) -> + invalidateNodeInfos.addReportUuid(value) + ); + + fillComputationResultUuids(rootNetworkNodeInfoEntity, invalidateNodeInfos); + + return invalidateNodeInfos; + } + private void fillInvalidateNodeInfos(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos, boolean invalidateOnlyChildrenBuildStatus, boolean deleteVoltageInitResults) { RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = getRootNetworkNodeInfo(nodeUuid, rootNetworkUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); @@ -298,6 +349,31 @@ private void fillInvalidateNodeInfos(UUID nodeUuid, UUID rootNetworkUuid, Invali .ifPresent(invalidateNodeInfos::addStateEstimationResultUuid); } + private void fillComputationResultUuids(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, InvalidateNodeInfos invalidateNodeInfos) { + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, LOAD_FLOW)) + .ifPresent(invalidateNodeInfos::addLoadFlowResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SECURITY_ANALYSIS)) + .ifPresent(invalidateNodeInfos::addSecurityAnalysisResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SENSITIVITY_ANALYSIS)) + .ifPresent(invalidateNodeInfos::addSensitivityAnalysisResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, NON_EVACUATED_ENERGY_ANALYSIS)) + .ifPresent(invalidateNodeInfos::addNonEvacuatedEnergyResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SHORT_CIRCUIT)) + .ifPresent(invalidateNodeInfos::addShortCircuitAnalysisResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SHORT_CIRCUIT_ONE_BUS)) + .ifPresent(invalidateNodeInfos::addOneBusShortCircuitAnalysisResultUuid); + //TODO: add more checks later for voltage init + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, VOLTAGE_INITIALIZATION)) + .ifPresent(invalidateNodeInfos::addVoltageInitResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, DYNAMIC_SIMULATION)) + .ifPresent(invalidateNodeInfos::addDynamicSimulationResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, DYNAMIC_SECURITY_ANALYSIS)) + .ifPresent(invalidateNodeInfos::addDynamicSecurityAnalysisResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, STATE_ESTIMATION)) + .ifPresent(invalidateNodeInfos::addStateEstimationResultUuid); + } + + // TODO : Remove optionnal and throws ROOT_NETWORK_NOT_FOUND exception public Optional getRootNetworkNodeInfo(UUID nodeUuid, UUID rootNetworkUuid) { return rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworkUuid); } @@ -348,6 +424,14 @@ private void addLink(NetworkModificationNodeInfoEntity nodeInfoEntity, RootNetwo rootNetworkNodeInfoRepository.save(rootNetworkNodeInfoEntity); } + private static void invalidateBuildStatus(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, InvalidateNodeInfos invalidateNodeInfos) { + rootNetworkNodeInfoEntity.setNodeBuildStatus(NodeBuildStatusEmbeddable.from(BuildStatus.NOT_BUILT)); + rootNetworkNodeInfoEntity.setVariantId(UUID.randomUUID().toString()); + rootNetworkNodeInfoEntity.setModificationReports(new HashMap<>(Map.of(rootNetworkNodeInfoEntity.getNodeInfo().getId(), UUID.randomUUID()))); + + invalidateNodeInfos.addNodeUuid(rootNetworkNodeInfoEntity.getNodeInfo().getIdNode()); + } + private static void invalidateRootNetworkNodeInfoBuildStatus(UUID nodeUuid, RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, List changedNodes) { if (!rootNetworkNodeInfoEntity.getNodeBuildStatus().toDto().isBuilt()) { return; 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 b5b0c0bfd..116e7f2bb 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -388,11 +388,10 @@ public void modifyRootNetwork(UUID studyUuid, RootNetworkInfos rootNetworkInfos, private void postRootNetworkUpdate(UUID studyUuid, UUID rootNetworkUuid, boolean updateCase) { if (updateCase) { Optional rootNetworkModificationRequestEntityOpt = rootNetworkService.getRootNetworkRequest(rootNetworkUuid); - if (rootNetworkModificationRequestEntityOpt.isPresent()) { - rootNetworkService.deleteRootNetworkRequest(rootNetworkModificationRequestEntityOpt.get()); - } + rootNetworkModificationRequestEntityOpt.ifPresent(rootNetworkService::deleteRootNetworkRequest); UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); - invalidateBuild(studyUuid, rootNodeUuid, rootNetworkUuid, false, false, true); + + invalidateNodeTree(studyUuid, rootNodeUuid, rootNetworkUuid); notificationService.emitRootNetworkUpdated(studyUuid, rootNetworkUuid); } else { notificationService.emitRootNetworksUpdated(studyUuid); @@ -1531,7 +1530,7 @@ public void createNetworkModification(UUID studyUuid, String createModificationA } } // invalidate all nodeUuid children - updateStatuses(studyUuid, nodeUuid); + invalidateNodeTree(studyUuid, nodeUuid, true); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1544,7 +1543,7 @@ public void updateNetworkModification(UUID studyUuid, String updateModificationA notificationService.emitStartModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids, NotificationService.MODIFICATIONS_UPDATING_IN_PROGRESS); try { networkModificationService.updateModification(updateModificationAttributes, modificationUuid); - updateStatuses(studyUuid, nodeUuid, false); + invalidateNodeTree(studyUuid, nodeUuid); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1618,9 +1617,8 @@ private void assertCanBuildNode(@NonNull UUID studyUuid, @NonNull UUID rootNetwo } @Transactional - public void unbuildNode(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid) { - invalidateBuild(studyUuid, nodeUuid, rootNetworkUuid, false, true, true); - emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); + public void unbuildStudyNode(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid) { + invalidateNode(studyUuid, nodeUuid, rootNetworkUuid); } public void stopBuild(@NonNull UUID nodeUuid, UUID rootNetworkUuid) { @@ -1633,7 +1631,9 @@ public void duplicateStudyNode(UUID sourceStudyUuid, UUID targetStudyUuid, UUID checkStudyContainsNode(targetStudyUuid, referenceNodeUuid); UUID duplicatedNodeUuid = networkModificationTreeService.duplicateStudyNode(nodeToCopyUuid, referenceNodeUuid, insertMode); boolean invalidateBuild = networkModificationTreeService.hasModifications(nodeToCopyUuid, false); - updateStatuses(targetStudyUuid, duplicatedNodeUuid, true, invalidateBuild, true); + if (invalidateBuild) { + invalidateNodeTree(targetStudyUuid, duplicatedNodeUuid, true); + } notificationService.emitElementUpdated(targetStudyUuid, userId); } @@ -1642,23 +1642,21 @@ public void moveStudyNode(UUID studyUuid, UUID nodeToMoveUuid, UUID referenceNod List oldChildren = null; checkStudyContainsNode(studyUuid, nodeToMoveUuid); checkStudyContainsNode(studyUuid, referenceNodeUuid); - boolean shouldInvalidateChildren = networkModificationTreeService.hasModifications(nodeToMoveUuid, false); + boolean shouldUnbuildChildren = networkModificationTreeService.hasModifications(nodeToMoveUuid, false); - //Invalidating previous children if necessary - if (shouldInvalidateChildren) { + //Unbuild previous children if necessary + if (shouldUnbuildChildren) { oldChildren = networkModificationTreeService.getChildrenByParentUuid(nodeToMoveUuid); } networkModificationTreeService.moveStudyNode(nodeToMoveUuid, referenceNodeUuid, insertMode); - //Invalidating moved node or new children if necessary - if (shouldInvalidateChildren) { - updateStatuses(studyUuid, nodeToMoveUuid, false, true, true); - oldChildren.forEach(child -> updateStatuses(studyUuid, child.getIdNode(), false, true, true)); + //Unbuilding moved node or new children if necessary + if (shouldUnbuildChildren) { + invalidateNodeTree(studyUuid, nodeToMoveUuid); + oldChildren.forEach(child -> invalidateNodeTree(studyUuid, child.getIdNode())); } else { - getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - invalidateBuild(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId(), false, true, true) - ); + invalidateNode(studyUuid, nodeToMoveUuid); } notificationService.emitElementUpdated(studyUuid, userId); } @@ -1690,12 +1688,11 @@ public void moveStudySubtree(UUID studyUuid, UUID parentNodeToMoveUuid, UUID ref getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> { UUID rootNetworkUuid = rootNetworkEntity.getId(); if (networkModificationTreeService.getNodeBuildStatus(parentNodeToMoveUuid, rootNetworkUuid).isBuilt()) { - updateStatuses(studyUuid, parentNodeToMoveUuid, false, true, true); + invalidateNodeTree(studyUuid, parentNodeToMoveUuid); } allChildren.stream() .filter(childUuid -> networkModificationTreeService.getNodeBuildStatus(childUuid, rootNetworkUuid).isBuilt()) - .forEach(childUuid -> updateStatuses(studyUuid, childUuid, false, true, true)); - + .forEach(childUuid -> invalidateNodeTree(studyUuid, childUuid)); }); notificationService.emitSubtreeMoved(studyUuid, parentNodeToMoveUuid, referenceNodeUuid); @@ -1744,12 +1741,85 @@ public void invalidateBuild(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, } } - private void updateStatuses(UUID studyUuid, UUID nodeUuid) { - updateStatuses(studyUuid, nodeUuid, true); + // Invalidate only one node + private void invalidateNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + AtomicReference startTime = new AtomicReference<>(null); + startTime.set(System.nanoTime()); + + InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.invalidateNode(nodeUuid, rootNetworkUuid); + invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); + + deleteInvalidationInfos(invalidateNodeInfos); + + emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); + + if (startTime.get() != null) { + LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, + TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); + } + } + + private void invalidateNode(UUID studyUuid, UUID nodeUuid) { + getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> + invalidateNode(studyUuid, nodeUuid, rootNetworkEntity.getId())); } - private void updateStatuses(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { - updateStatuses(studyUuid, nodeUuid, invalidateOnlyChildrenBuildStatus, true, true); + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid) { + invalidateNodeTree(studyUuid, nodeUuid, false); + } + + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { + getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> + invalidateNodeTree(studyUuid, nodeUuid, rootNetworkEntity.getId(), invalidateOnlyChildrenBuildStatus)); + } + + // Invalidate the node and its children + public void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + invalidateNodeTree(studyUuid, nodeUuid, rootNetworkUuid, false); + } + + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { + AtomicReference startTime = new AtomicReference<>(null); + startTime.set(System.nanoTime()); + + InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.invalidateNodeTree(nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus); + invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); + + deleteInvalidationInfos(invalidateNodeInfos); + + emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); + + if (startTime.get() != null) { + LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, + TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); + } + } + + public void deleteInvalidationInfos(InvalidateNodeInfos invalidateNodeInfos) { + CompletableFuture executeInParallel = CompletableFuture.allOf( + studyServerExecutionService.runAsync(() -> networkModificationService.deleteIndexedModifications(invalidateNodeInfos.getGroupUuids(), invalidateNodeInfos.getNetworkUuid())), + studyServerExecutionService.runAsync(() -> networkStoreService.deleteVariants(invalidateNodeInfos.getNetworkUuid(), invalidateNodeInfos.getVariantIds())), + studyServerExecutionService.runAsync(() -> reportService.deleteReports(invalidateNodeInfos.getReportUuids())), + studyServerExecutionService.runAsync(() -> loadflowService.deleteLoadFlowResults(invalidateNodeInfos.getLoadFlowResultUuids())), + studyServerExecutionService.runAsync(() -> securityAnalysisService.deleteSecurityAnalysisResults(invalidateNodeInfos.getSecurityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> sensitivityAnalysisService.deleteSensitivityAnalysisResults(invalidateNodeInfos.getSensitivityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> nonEvacuatedEnergyService.deleteNonEvacuatedEnergyResults(invalidateNodeInfos.getNonEvacuatedEnergyResultUuids())), + studyServerExecutionService.runAsync(() -> shortCircuitService.deleteShortCircuitAnalysisResults(invalidateNodeInfos.getShortCircuitAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> shortCircuitService.deleteShortCircuitAnalysisResults(invalidateNodeInfos.getOneBusShortCircuitAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> voltageInitService.deleteVoltageInitResults(invalidateNodeInfos.getVoltageInitResultUuids())), + studyServerExecutionService.runAsync(() -> dynamicSimulationService.deleteResults(invalidateNodeInfos.getDynamicSimulationResultUuids())), + studyServerExecutionService.runAsync(() -> dynamicSecurityAnalysisService.deleteResults(invalidateNodeInfos.getDynamicSecurityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> stateEstimationService.deleteStateEstimationResults(invalidateNodeInfos.getStateEstimationResultUuids())) + ); + try { + executeInParallel.get(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new StudyException(INVALIDATE_BUILD_FAILED, e.getMessage()); + } catch (Exception e) { + throw new StudyException(INVALIDATE_BUILD_FAILED, e.getMessage()); + } + } private void updateStatuses(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus, boolean invalidateBuild, boolean deleteVoltageInitResults) { @@ -1760,9 +1830,7 @@ private void updateStatuses(UUID studyUuid, UUID nodeUuid, boolean invalidateOnl } private void updateStatuses(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus, boolean invalidateBuild, boolean deleteVoltageInitResults) { - if (invalidateBuild) { - invalidateBuild(studyUuid, nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus, false, deleteVoltageInitResults); - } + invalidateBuild(studyUuid, nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus, false, deleteVoltageInitResults); emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); } @@ -1781,7 +1849,6 @@ public void deleteNetworkModifications(UUID studyUuid, UUID nodeUuid, List studyEntity.getRootNetworks().forEach(rootNetworkEntity -> { rootNetworkNodeInfoService.updateModificationsToExclude(nodeUuid, rootNetworkEntity.getId(), new HashSet<>(modificationsUuids), true); }); - updateStatuses(studyUuid, nodeUuid, false, false, false); } finally { notificationService.emitEndDeletionEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1798,7 +1865,7 @@ public void stashNetworkModifications(UUID studyUuid, UUID nodeUuid, List } UUID groupId = networkModificationTreeService.getModificationGroupUuid(nodeUuid); networkModificationService.stashModifications(groupId, modificationsUuids); - updateStatuses(studyUuid, nodeUuid, false); + invalidateNodeTree(studyUuid, nodeUuid); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1815,7 +1882,7 @@ public void updateNetworkModificationsActivation(UUID studyUuid, UUID nodeUuid, } UUID groupId = networkModificationTreeService.getModificationGroupUuid(nodeUuid); networkModificationService.updateModificationsActivation(groupId, modificationsUuids, activated); - updateStatuses(studyUuid, nodeUuid, false); + invalidateNodeTree(studyUuid, nodeUuid); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1832,7 +1899,7 @@ public void updateNetworkModificationsActivationInRootNetwork(UUID studyUuid, UU throw new StudyException(NOT_ALLOWED); } rootNetworkNodeInfoService.updateModificationsToExclude(nodeUuid, rootNetworkUuid, modificationsUuids, activated); - updateStatuses(studyUuid, nodeUuid, rootNetworkUuid, false, true, true); + invalidateNodeTree(studyUuid, nodeUuid, rootNetworkUuid); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, Optional.of(rootNetworkUuid), childrenUuids); } @@ -1849,7 +1916,7 @@ public void restoreNetworkModifications(UUID studyUuid, UUID nodeUuid, List nodeIds, boolean deleteChildr } if (invalidateChildrenBuild) { - childrenNodes.forEach(nodeEntity -> updateStatuses(studyUuid, nodeEntity.getIdNode(), false, true, true)); + childrenNodes.forEach(nodeEntity -> invalidateNodeTree(studyUuid, nodeEntity.getIdNode())); } } @@ -1929,10 +1996,21 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); - boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); - getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - invalidateBuild(studyUuid, nodeId, rootNetworkEntity.getId(), false, !invalidateChildrenBuild, true) - ); + + boolean unbuildChildren = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); + List rootNetworkUuids = getStudyRootNetworks(studyUuid).stream() + .map(RootNetworkEntity::getId) + .toList(); + + if (unbuildChildren) { + rootNetworkUuids.forEach(rootNetworkId -> + invalidateNodeTree(studyUuid, nodeId, rootNetworkId)); + } else { + rootNetworkUuids.forEach(rootNetworkId -> + invalidateNode(studyUuid, nodeId, rootNetworkId) + ); + } + networkModificationTreeService.doStashNode(nodeId, stashChildren); if (startTime.get() != null) { @@ -2047,7 +2125,7 @@ private void emitNetworkModificationImpactsForAllRootNetworks(List startTime = new AtomicReference<>(); startTime.set(System.nanoTime()); UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); //TODO: to parallelize ? studyService.getExistingBasicRootNetworkInfos(studyUuid).forEach(rootNetwork -> - studyService.invalidateBuild(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid(), false, false, true) + studyService.invalidateNodeTree(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid()) ); LOGGER.trace("Nodes builds deletion for study {} in : {} seconds", studyUuid, TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java index a81d176d8..ea4f3d91e 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java @@ -636,7 +636,6 @@ void testLocalBuildValue() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNodeUuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); assertEquals(BuildStatus.BUILT_WITH_ERROR, networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, rootNetworkUuid).getGlobalBuildStatus()); @@ -655,7 +654,6 @@ void testLocalBuildValue() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); assertEquals(BuildStatus.BUILT_WITH_ERROR, networkModificationTreeService.getNodeBuildStatus(modificationNode2Uuid, rootNetworkUuid).getGlobalBuildStatus()); @@ -707,7 +705,6 @@ void testNetworkModificationSwitch(final MockWebServer server) throws Exception .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -729,7 +726,6 @@ void testNetworkModificationSwitch(final MockWebServer server) throws Exception .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -757,7 +753,9 @@ void testNetworkModificationSwitch(final MockWebServer server) throws Exception NetworkImpactsInfos expectedPayload = NetworkImpactsInfos.builder().impactedSubstationsIds(substationsSet).build(); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); - checkSwitchModificationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid, modificationNode2Uuid), expectedPayload); + checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid, expectedPayload); + checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); + checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); modificationBody = Pair.of(bodyJson, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNode1Uuid, NETWORK_UUID))); wireMockUtils.verifyNetworkModificationPostWithVariant(stubPostId, getModificationContextJsonString(mapper, modificationBody)); @@ -807,7 +805,6 @@ void testNetworkModificationEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); Pair> modificationBody = Pair.of(bodyJson, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNodeUuid, NETWORK_UUID))); @@ -828,7 +825,6 @@ void testNetworkModificationEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -879,7 +875,6 @@ void testCreateGenerator() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -892,7 +887,6 @@ void testCreateGenerator() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -957,7 +951,6 @@ void testCreateShuntsCompensator() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1022,7 +1015,6 @@ void testCreateLine() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1035,7 +1027,6 @@ void testCreateLine() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); modificationBody = Pair.of(createLineAttributes, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNode2Uuid, NETWORK_UUID))); @@ -1107,7 +1098,6 @@ void testCreateTwoWindingsTransformer() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1120,7 +1110,6 @@ void testCreateTwoWindingsTransformer() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1184,7 +1173,6 @@ void deleteModificationRequest() throws Exception { .andExpect(status().isOk()); wireMockUtils.verifyDeleteRequest(stubId, "/v1/network-modifications", false, Map.of("uuids", WireMock.equalTo(modificationUuid.toString()))); checkEquipmentDeletingMessagesReceived(studyUuid, modificationNode.getId()); - checkUpdateModelsStatusMessagesReceived(studyUuid, modificationNode.getId()); checkEquipmentDeletingFinishedMessagesReceived(studyUuid, modificationNode.getId()); stubId = wireMockServer.stubFor(WireMock.delete(WireMock.urlPathMatching("/v1/network-modifications.*")) @@ -1232,7 +1220,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1261,7 +1248,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1290,7 +1276,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1319,7 +1304,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1346,7 +1330,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1386,7 +1369,6 @@ void testCreateLoad() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1399,7 +1381,6 @@ void testCreateLoad() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1461,7 +1442,6 @@ void testModifyLoad() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1474,7 +1454,6 @@ void testModifyLoad() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1521,7 +1500,6 @@ void testModifyEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1534,7 +1512,6 @@ void testModifyEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1584,7 +1561,6 @@ void testCreateSubstation() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1597,7 +1573,6 @@ void testCreateSubstation() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1658,7 +1633,6 @@ void testCreateVoltageLevel() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1671,7 +1645,6 @@ void testCreateVoltageLevel() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1734,7 +1707,6 @@ void testLineSplitWithVoltageLevel() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1798,7 +1770,6 @@ void testLineAttachToVoltageLevel() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1834,7 +1805,6 @@ void testLinesAttachToSplitLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1892,7 +1862,6 @@ void testScaling(ModificationType scalingType) throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1948,7 +1917,6 @@ void testDeleteVoltageLevelOnline() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); Pair> modificationBody = Pair.of(createDeleteVoltageLevelOnlineAttributes, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNodeUuid, NETWORK_UUID))); @@ -2001,7 +1969,6 @@ void testDeleteAttachingline() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); Pair> modificationBody = Pair.of(createDeleteAttachingLineAttributes, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNodeUuid, NETWORK_UUID))); @@ -2063,7 +2030,6 @@ void testReorderModification() throws Exception { studyNameUserIdUuid, modificationNodeUuid, modification1).header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2082,7 +2048,6 @@ void testReorderModification() throws Exception { studyNameUserIdUuid, modificationNodeUuid, modification1, modification2).header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2147,7 +2112,6 @@ void testDuplicateModification() throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid1); - checkNodesBuildStatusUpdatedMessageReceived(studyUuid, List.of(nodeUuid1)); checkUpdateModelsStatusMessagesReceived(studyUuid, nodeUuid1); checkEquipmentUpdatingFinishedMessagesReceived(studyUuid, nodeUuid1); checkElementUpdatedMessageSent(studyUuid, userId); @@ -2181,7 +2145,6 @@ void testDuplicateModification() throws Exception { checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid1); checkElementUpdatedMessageSent(studyUuid, userId); checkEquipmentMessagesReceived(studyUuid, List.of(nodeUuid1), expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyUuid, List.of(nodeUuid1)); checkUpdateModelsStatusMessagesReceived(studyUuid, nodeUuid1); checkEquipmentUpdatingFinishedMessagesReceived(studyUuid, nodeUuid1); @@ -2250,7 +2213,6 @@ void testCutAndPasteModification() throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid1); - checkNodesBuildStatusUpdatedMessageReceived(studyUuid, List.of(nodeUuid1)); checkUpdateModelsStatusMessagesReceived(studyUuid, nodeUuid1); checkEquipmentUpdatingFinishedMessagesReceived(studyUuid, nodeUuid1); @@ -2272,9 +2234,7 @@ void testCutAndPasteModification() throws Exception { .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid2); checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid1); - checkNodesBuildStatusUpdatedMessageReceived(studyUuid, List.of(nodeUuid2)); checkUpdateModelsStatusMessagesReceived(studyUuid, nodeUuid2); - checkNodesBuildStatusUpdatedMessageReceived(studyUuid, List.of(nodeUuid1)); checkUpdateModelsStatusMessagesReceived(studyUuid, nodeUuid1); checkEquipmentUpdatingFinishedMessagesReceived(studyUuid, nodeUuid2); checkEquipmentUpdatingFinishedMessagesReceived(studyUuid, nodeUuid1); @@ -2362,7 +2322,6 @@ void testDeleteEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2375,7 +2334,6 @@ void testDeleteEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2467,7 +2425,7 @@ void testNodesInvalidation(final MockWebServer server) throws Exception { .andExpect(status().isOk()); wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid, modificationNode3Uuid)); + checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode3Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2531,7 +2489,6 @@ void testRemoveLoadFlowComputationReport(final MockWebServer server) throws Exce .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2579,7 +2536,6 @@ void testUpdateOfBuildStatus() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2604,7 +2560,6 @@ void testUpdateOfBuildStatus() throws Exception { checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNodeUuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, firstRootNetworkUuid).getGlobalBuildStatus()); @@ -2622,7 +2577,6 @@ void testUpdateOfBuildStatus() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNodeUuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); assertEquals(BuildStatus.BUILT_WITH_WARNING, networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, firstRootNetworkUuid).getGlobalBuildStatus()); @@ -2640,7 +2594,6 @@ void testUpdateOfBuildStatus() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNodeUuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); assertEquals(BuildStatus.BUILT_WITH_ERROR, networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, firstRootNetworkUuid).getGlobalBuildStatus()); @@ -2815,12 +2768,11 @@ private void checkNodesBuildStatusUpdatedMessageReceived(UUID studyUuid, List(nodesUuids), new TreeSet<>((List) headersStatus.get(NotificationService.HEADER_NODES))); assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, headersStatus.get(NotificationService.HEADER_UPDATE_TYPE)); } private void checkUpdateEquipmentModificationMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid) { - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(nodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, nodeUuid); } @@ -2850,16 +2802,6 @@ private void checkEquipmentDeletingMessagesReceived(UUID studyNameUserIdUuid, UU assertEquals(NotificationService.MODIFICATIONS_DELETING_IN_PROGRESS, headersStudyUpdate.get(NotificationService.HEADER_UPDATE_TYPE)); } - private void checkSwitchModificationMessagesReceived(UUID studyNameUserIdUuid, List nodeUuids, - NetworkImpactsInfos expectedPayload) throws Exception { - assertFalse(nodeUuids.isEmpty()); - - checkEquipmentMessagesReceived(studyNameUserIdUuid, nodeUuids, expectedPayload); - - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, nodeUuids); - checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, nodeUuids.get(0)); - } - private void checkEquipmentUpdatingMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid) { // assert that the broker message has been sent for updating study type Message messageStudyUpdate = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); @@ -2871,7 +2813,6 @@ private void checkEquipmentUpdatingMessagesReceived(UUID studyNameUserIdUuid, UU } private void checkUpdateEquipmentCreationMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid) { - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(nodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, nodeUuid); } @@ -2989,7 +2930,6 @@ void testCreateModificationWithErrors() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java index 07cb830bf..c48c7c1fc 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java @@ -768,14 +768,26 @@ private void deleteNode(UUID studyUuid, List child, boolean delete } private void stashNode(UUID studyUuid, AbstractNode child, boolean stashChildren, Set expectedStash, String userId) throws Exception { + NetworkModificationNode networkModificationNode = (NetworkModificationNode) child; + boolean nodeIsBuilt = networkModificationNode.getNodeBuildStatus().isBuilt(); + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}/stash?stashChildren={stash}", studyUuid, child.getId(), stashChildren).header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); - //first message is node build status being reset and then is the node deleted - var message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - assertEquals(NODE_BUILD_STATUS_UPDATED, message.getHeaders().get(HEADER_UPDATE_TYPE)); + Message message; + + // first message is node build status being reset + if (nodeIsBuilt) { + message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); + assertEquals(NODE_BUILD_STATUS_UPDATED, message.getHeaders().get(HEADER_UPDATE_TYPE)); + } + + // computing status + checkUpdateModelsStatusMessagesReceived(); + + // node deleted message message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); Collection stashedId = (Collection) message.getHeaders().get(NotificationService.HEADER_NODES); assertNotNull(stashedId); @@ -1649,4 +1661,27 @@ private void checkNodeAliasUpdateMessageReceived(UUID studyUuid) { assertEquals(studyUuid, headersStudyUpdate.get(NotificationService.HEADER_STUDY_UUID)); assertEquals(NotificationService.UPDATE_SPREADSHEET_NODE_ALIASES, headersStudyUpdate.get(NotificationService.HEADER_UPDATE_TYPE)); } + + private void checkUpdateModelsStatusMessagesReceived() { + //loadflow_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //securityAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //sensitivityAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //sensitivityAnalysisonEvacuated_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //shortCircuitAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //oneBusShortCircuitAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //dynamicSimulation_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //dynamicSecurityAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //voltageInit_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //stateEstimation_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + } } diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java index 98c2cf885..ff47d4145 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java @@ -40,6 +40,7 @@ import java.util.List; import java.util.Map; +import java.util.TreeSet; import java.util.UUID; import java.util.stream.Collectors; @@ -217,7 +218,7 @@ private void checkUpdateBuildStateMessageReceived(UUID studyUuid, List nod MessageHeaders headersStatus = messageStatus.getHeaders(); assertEquals(studyUuid, headersStatus.get(NotificationService.HEADER_STUDY_UUID)); - assertEquals(nodeUuids, headersStatus.get(NotificationService.HEADER_NODES)); + assertEquals(new TreeSet<>(nodeUuids), new TreeSet<>((List) headersStatus.get(NotificationService.HEADER_NODES))); assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, headersStatus.get(NotificationService.HEADER_UPDATE_TYPE)); } diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index bf557961d..d742c267d 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -1503,7 +1503,7 @@ private void checkNodeBuildStatusUpdatedMessageReceived(UUID studyUuid, List(nodesUuids), new TreeSet<>((List) headersStatus.get(NotificationService.HEADER_NODES))); assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, headersStatus.get(NotificationService.HEADER_UPDATE_TYPE)); } @@ -1642,7 +1642,6 @@ private void testDuplicateStudy(final MockWebServer mockWebServer, UUID study1Uu .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -1659,7 +1658,6 @@ private void testDuplicateStudy(final MockWebServer mockWebServer, UUID study1Uu .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -1948,7 +1946,6 @@ void testCutAndPasteNode(final MockWebServer mockWebServer) throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -1964,7 +1961,6 @@ void testCutAndPasteNode(final MockWebServer mockWebServer) throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2281,7 +2277,6 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2297,7 +2292,6 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2317,7 +2311,7 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { assertEquals(0, allNodes.stream().filter(nodeEntity -> nodeEntity.getParentNode() != null && nodeEntity.getParentNode().getIdNode().equals(node2.getId())).count()); // duplicate the node1 after node2 - UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study1Uuid, node1, node2.getId(), InsertMode.AFTER, userId); + UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study1Uuid, node1, node2.getId(), InsertMode.AFTER, true, userId); //node2 should now have 1 child allNodes = networkModificationTreeService.getAllNodes(study1Uuid); @@ -2328,7 +2322,7 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { .count()); // duplicate the node2 before node1 - UUID duplicatedNodeUuid2 = duplicateNode(study1Uuid, study1Uuid, node2, node1.getId(), InsertMode.BEFORE, userId); + UUID duplicatedNodeUuid2 = duplicateNode(study1Uuid, study1Uuid, node2, node1.getId(), InsertMode.BEFORE, true, userId); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); assertEquals(1, allNodes.stream() .filter(nodeEntity -> nodeEntity.getParentNode() != null @@ -2338,7 +2332,7 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { //now the tree looks like root -> modificationNode -> duplicatedNode2 -> node1 -> node2 -> duplicatedNode1 //duplicate node1 in a new branch starting from duplicatedNode2 - UUID duplicatedNodeUuid3 = duplicateNode(study1Uuid, study1Uuid, node1, duplicatedNodeUuid2, InsertMode.CHILD, userId); + UUID duplicatedNodeUuid3 = duplicateNode(study1Uuid, study1Uuid, node1, duplicatedNodeUuid2, InsertMode.CHILD, true, userId); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); //expect to have modificationNode as a parent assertEquals(1, allNodes.stream() @@ -2373,7 +2367,7 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { // Test Built status when duplicating an empty node UUID rootNetworkUuid = studyTestUtils.getOneRootNetworkUuid(study1Uuid); assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(node3.getId(), rootNetworkUuid).getGlobalBuildStatus()); - duplicateNode(study1Uuid, study1Uuid, emptyNode, node3.getId(), InsertMode.BEFORE, userId); + duplicateNode(study1Uuid, study1Uuid, emptyNode, node3.getId(), InsertMode.BEFORE, false, userId); assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(node3.getId(), rootNetworkUuid).getGlobalBuildStatus()); } @@ -2408,7 +2402,7 @@ void testDuplicateSubtree(final MockWebServer server) throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId(), node3.getId())); + checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node3.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2430,7 +2424,6 @@ void testDuplicateSubtree(final MockWebServer server) throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2550,7 +2543,6 @@ void testDuplicateNodeBetweenStudies(final MockWebServer mockWebServer) throws E .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2566,7 +2558,6 @@ void testDuplicateNodeBetweenStudies(final MockWebServer mockWebServer) throws E .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2578,7 +2569,7 @@ void testDuplicateNodeBetweenStudies(final MockWebServer mockWebServer) throws E assertEquals(0, allNodes.stream().filter(nodeEntity -> nodeEntity.getParentNode() != null && nodeEntity.getParentNode().getIdNode().equals(study2Node2.getId())).count()); // duplicate the node1 from study 1 after node2 from study 2 - UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study2Uuid, node1, study2Node2.getId(), InsertMode.AFTER, userId); + UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study2Uuid, node1, study2Node2.getId(), InsertMode.AFTER, true, userId); //node2 should now have 1 child allNodes = networkModificationTreeService.getAllNodes(study2Uuid); @@ -2616,47 +2607,53 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, assertEquals(nodeToCopy.getId(), message.getHeaders().get(NotificationService.HEADER_MOVED_NODE)); assertEquals(insertMode.name(), message.getHeaders().get(NotificationService.HEADER_INSERT_MODE)); - if (nodeHasModifications) { - /* - * invalidating old children - */ - IntStream.rangeClosed(1, childCount).forEach(i -> { - //nodeUpdated - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //loadflow_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //securityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //sensitivityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //nonEvacuatedEnergy_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //shortCircuitAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //oneBusShortCircuitAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicSimulation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicSecurityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //voltageInit_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //stateEstimation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - }); + /* + * invalidating moving node + */ + //nodeUpdated + if (wasBuilt) { + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + } + //loadflow_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //securityAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //sensitivityAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //sensitivityAnalysisonEvacuated_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //shortCircuitAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //oneBusShortCircuitAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //dynamicSimulation_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //dynamicSecurityAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //voltageInit_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //stateEstimation_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + + if (!nodeHasModifications) { + return; + } - /* - * invalidating new children - */ + /* + * invalidating old children + */ + IntStream.rangeClosed(1, childCount).forEach(i -> { //nodeUpdated - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + if (wasBuilt) { + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + } //loadflow_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //securityAnalysis_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //sensitivityAnalysis_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //sensitivityAnalysisonEvacuated_status + //nonEvacuatedEnergy_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //shortCircuitAnalysis_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); @@ -2670,21 +2667,14 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //stateEstimation_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + }); - if (wasBuilt) { - // 1 request for cut node and its children, 1 request for paste node and its children - wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub, 2); - } - } else { - /* - * Invalidating moved node - */ - //nodeUpdated - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + if (wasBuilt) { + wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub, 1); } } - private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkModificationNode nodeToCopy, UUID referenceNodeUuid, InsertMode insertMode, String userId) throws Exception { + private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkModificationNode nodeToCopy, UUID referenceNodeUuid, InsertMode insertMode, boolean checkMessagesForStatusModels, String userId) throws Exception { List allNodesBeforeDuplication = networkModificationTreeService.getAllNodes(targetStudyUuid).stream().map(NodeEntity::getIdNode).collect(Collectors.toList()); UUID stubGetCountUuid = wireMockUtils.stubNetworkModificationCountGet(nodeToCopy.getModificationGroupUuid().toString(), EMPTY_MODIFICATION_GROUP_UUID.equals(nodeToCopy.getModificationGroupUuid()) ? 0 : 1); @@ -2709,10 +2699,10 @@ private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkMo assertEquals(1, nodesAfterDuplication.size()); output.receive(TIMEOUT, studyUpdateDestination); // nodeCreated - if (!EMPTY_MODIFICATION_GROUP_UUID.equals(nodeToCopy.getModificationGroupUuid())) { - output.receive(TIMEOUT, studyUpdateDestination); // nodeUpdated + + if (checkMessagesForStatusModels) { + checkUpdateModelsStatusMessagesReceived(targetStudyUuid, nodesAfterDuplication.get(0)); } - checkUpdateModelsStatusMessagesReceived(targetStudyUuid, nodesAfterDuplication.get(0)); checkElementUpdatedMessageSent(targetStudyUuid, userId); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, nodeToCopy.getModificationGroupUuid().toString()); diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 5b30c7dc2..27f9b2e26 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -737,7 +737,7 @@ private void checkNodesBuildStatusUpdatedMessageReceived(UUID studyUuid, List(nodesUuids), new TreeSet<>((List) headersStatus.get(NotificationService.HEADER_NODES))); assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, headersStatus.get(NotificationService.HEADER_UPDATE_TYPE)); } diff --git a/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java b/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java index 13925b9ee..65b2a85fd 100644 --- a/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java +++ b/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java @@ -713,9 +713,7 @@ void testUpdateRootNetworkConsumer() throws Exception { // send message to consumer Mockito.doNothing().when(caseService).disableCaseExpiration(NEW_CASE_UUID); - Mockito.doNothing().when(studyService).invalidateBuild(studyUuid, rootNode.getIdNode(), rootNetworkUuid, false, - false, - true); + Mockito.doNothing().when(studyService).invalidateNodeTree(studyUuid, rootNode.getIdNode(), rootNetworkUuid); messageConsumer.accept(new GenericMessage<>("", headers)); // get study from database and check new root network has been updated with new case @@ -737,9 +735,7 @@ void testUpdateRootNetworkConsumer() throws Exception { // check that old case has been deleted successfully assertFalse(caseService.caseExists(oldCaseUuid)); //assert invalidate Build node has been called on root node - Mockito.verify(studyService, Mockito.times(1)).invalidateBuild(studyUuid, rootNode.getIdNode(), rootNetworkUuid, false, - false, - true); + Mockito.verify(studyService, Mockito.times(1)).invalidateNodeTree(studyUuid, rootNode.getIdNode(), rootNetworkUuid); } @Test