From 9176627f486fd4b74b0b62985c398e9be26ee97b Mon Sep 17 00:00:00 2001 From: Aliou DIAITE Date: Fri, 5 Jan 2024 16:36:35 +0100 Subject: [PATCH] feat(#352): Enhancement debind also extrefs when voltageLevel@name unknown Signed-off-by: Aliou DIAITE --- .../lfenergy/compas/sct/commons/ExtRefEditorService.java | 9 +++------ .../compas/sct/commons/ExtRefEditorServiceTest.java | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java index 65cdce821..266750f3e 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java @@ -420,14 +420,11 @@ public void debindCompasFlowsAndExtRefsBasedOnVoltageLevel(SCL scd) { .filter(TCompasFlow::isSetFlowSourceVoltageLevel) .filter(TCompasFlow::isSetExtRefiedName) .forEach(tCompasFlow -> { - if (flowSource == null) { - //debind all compas flow - extRefService.clearCompasFlowBinding(tCompasFlow); - } else if (!tCompasFlow.getFlowSourceVoltageLevel().equals(flowSource)) { - //debind extRef + if (!tCompasFlow.getFlowSourceVoltageLevel().equals(flowSource)) { + //debind extRefs correspondind to compas flow extRefService.getMatchingExtRefs(tlDevice, tCompasFlow) .forEach(extRefService::clearExtRefBinding); - //debind compas flow + //debind all compas flow extRefService.clearCompasFlowBinding(tCompasFlow); } }); diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java index 73b5b1747..5ad2eae78 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java @@ -774,7 +774,7 @@ private static Stream provideFlowAndExtRefForDebinding(){ return Stream.of( Arguments.of("case known voltageLevel should debind THT flow and corresponding ExtRef", scd, tupleExtRef1, tupleFlow1, tupleExtRefDebind, tupleFlowDebind), Arguments.of("case voltageLevel 0 should do nothing", scdVoltageLevel0, tupleExtRef1, tupleFlow1, tupleExtRef2, tupleFlow2), - Arguments.of("case unknown voltageLevel should debind all", scdVoltageLevelUnknown, tupleExtRef1, tupleFlowDebind, tupleExtRef2, tupleFlowDebind), + Arguments.of("case unknown voltageLevel should debind all CompasFlow and corresponding ExtRef", scdVoltageLevelUnknown, tupleExtRefDebind, tupleFlowDebind, tupleExtRefDebind, tupleFlowDebind), Arguments.of("case known voltageLevel should not debind because no ExtRefIedName", scdUnsetExtRefIedName, tupleExtRef1, tupleFlow1, tupleExtRef2, tupleFlowNoExtRefIedName), Arguments.of("case unknown voltageLevel should not debind because unset FlowSourceVoltageLevel", scdVLevelUnknownUnsetFlowSourceVoltageLevel, tupleExtRef1, tupleFlow1, tupleExtRef2, tupleFlow2) );