diff --git a/src/main/java/org/gridsuite/filter/utils/expertfilter/ExpertFilterUtils.java b/src/main/java/org/gridsuite/filter/utils/expertfilter/ExpertFilterUtils.java index b489238..563f6f7 100644 --- a/src/main/java/org/gridsuite/filter/utils/expertfilter/ExpertFilterUtils.java +++ b/src/main/java/org/gridsuite/filter/utils/expertfilter/ExpertFilterUtils.java @@ -51,6 +51,7 @@ public static > String getFieldValue(FieldType field, case SUBSTATION -> getSubstationFieldValue(field, (Substation) identifiable); case TWO_WINDINGS_TRANSFORMER -> getTwoWindingsTransformerFieldValue(field, propertyName, (TwoWindingsTransformer) identifiable); case STATIC_VAR_COMPENSATOR -> getStaticVarCompensatorFieldValue(field, propertyName, (StaticVarCompensator) identifiable); + case DANGLING_LINE -> getDanglingLinesFieldValue(field, propertyName, (DanglingLine) identifiable); case THREE_WINDINGS_TRANSFORMER -> getThreeWindingsTransformerFieldValue(field, propertyName, (ThreeWindingsTransformer) identifiable); case HVDC_LINE -> getHvdcLineFieldValue(field, propertyName, (HvdcLine) identifiable); default -> throw new PowsyblException(TYPE_NOT_IMPLEMENTED + " [" + identifiable.getType() + "]"); @@ -538,6 +539,26 @@ private static String getStaticVarCompensatorFieldValue(FieldType field, String }; } + private static String getDanglingLinesFieldValue(FieldType field, String propertyName, DanglingLine danglingLine) { + return switch (field) { + case CONNECTED -> getTerminalFieldValue(field, danglingLine.getTerminal()); + case COUNTRY, + VOLTAGE_LEVEL_ID, + NOMINAL_VOLTAGE -> getVoltageLevelFieldValue(field, null, danglingLine.getTerminal().getVoltageLevel()); + case VOLTAGE_LEVEL_PROPERTIES, + SUBSTATION_PROPERTIES -> getVoltageLevelFieldValue(field, propertyName, danglingLine.getTerminal().getVoltageLevel()); + case P0 -> String.valueOf(danglingLine.getP0()); + case Q0 -> String.valueOf(danglingLine.getQ0()); + case SERIE_RESISTANCE -> String.valueOf(danglingLine.getR()); + case SERIE_REACTANCE -> String.valueOf(danglingLine.getX()); + case SHUNT_SUSCEPTANCE -> String.valueOf(danglingLine.getB()); + case SHUNT_CONDUCTANCE -> String.valueOf(danglingLine.getG()); + case PAIRED -> String.valueOf(danglingLine.isPaired()); + default -> + throw new PowsyblException(FIELD_AND_TYPE_NOT_IMPLEMENTED + " [" + field + "," + danglingLine.getType() + "]"); + }; + } + private static String getStandbyAutomatonFieldValue(FieldType field, StaticVarCompensator svar) { StandbyAutomaton standbyAutomaton = svar.getExtension(StandbyAutomaton.class); if (standbyAutomaton == null) { diff --git a/src/main/java/org/gridsuite/filter/utils/expertfilter/FieldType.java b/src/main/java/org/gridsuite/filter/utils/expertfilter/FieldType.java index 494cb1b..8bdcbf3 100644 --- a/src/main/java/org/gridsuite/filter/utils/expertfilter/FieldType.java +++ b/src/main/java/org/gridsuite/filter/utils/expertfilter/FieldType.java @@ -65,6 +65,8 @@ public enum FieldType { SERIE_RESISTANCE_2, SERIE_RESISTANCE_3, SERIE_REACTANCE, + SHUNT_SUSCEPTANCE, + SHUNT_CONDUCTANCE, SERIE_REACTANCE_1, SERIE_REACTANCE_2, SERIE_REACTANCE_3, @@ -132,6 +134,7 @@ public enum FieldType { LOW_VOLTAGE_THRESHOLD, HIGH_VOLTAGE_THRESHOLD, SUSCEPTANCE_FIX, + PAIRED, CONVERTERS_MODE, CONVERTER_STATION_ID_1, CONVERTER_STATION_NOMINAL_VOLTAGE_1, diff --git a/src/test/java/org/gridsuite/filter/expertfilter/BooleanExpertRuleTest.java b/src/test/java/org/gridsuite/filter/expertfilter/BooleanExpertRuleTest.java index 3df7a54..b50c89b 100644 --- a/src/test/java/org/gridsuite/filter/expertfilter/BooleanExpertRuleTest.java +++ b/src/test/java/org/gridsuite/filter/expertfilter/BooleanExpertRuleTest.java @@ -64,6 +64,9 @@ static Stream provideArgumentsForTestWithException() { StaticVarCompensator svar = Mockito.mock(StaticVarCompensator.class); Mockito.when(svar.getType()).thenReturn(IdentifiableType.STATIC_VAR_COMPENSATOR); + DanglingLine dl = Mockito.mock(DanglingLine.class); + Mockito.when(dl.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + TwoWindingsTransformer twoWindingsTransformer = Mockito.mock(TwoWindingsTransformer.class); Mockito.when(twoWindingsTransformer.getType()).thenReturn(IdentifiableType.TWO_WINDINGS_TRANSFORMER); @@ -86,6 +89,7 @@ static Stream provideArgumentsForTestWithException() { Arguments.of(EQUALS, FieldType.CONNECTED, twoWindingsTransformer, PowsyblException.class), Arguments.of(EQUALS, FieldType.RATED_S, threeWindingsTransformer, PowsyblException.class), Arguments.of(EQUALS, FieldType.RATED_S, hvdcLine, PowsyblException.class), + Arguments.of(EQUALS, FieldType.RATED_S, dl, PowsyblException.class), // --- Test an unsupported operator for this rule type --- // Arguments.of(IS, FieldType.VOLTAGE_REGULATOR_ON, generator, PowsyblException.class) @@ -101,6 +105,7 @@ static Stream provideArgumentsForTestWithException() { "provideArgumentsForLoadTest", "provideArgumentsForTwoWindingTransformerTest", "provideArgumentsForStaticVarCompensatorTest", + "provideArgumentsForDanglingLineTest", "provideArgumentsForThreeWindingTransformerTest", "provideArgumentsForHvdcLinesTest", }) @@ -506,4 +511,34 @@ private static Stream provideArgumentsForStaticVarCompensatorTest() { Arguments.of(NOT_EXISTS, FieldType.AUTOMATE, null, svar1, true) ); } + + private static Stream provideArgumentsForDanglingLineTest() { + + DanglingLine danglingLine = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + //Generator fields + Mockito.when(danglingLine.isPaired()).thenReturn(true); + // Terminal fields + Terminal terminal = Mockito.mock(Terminal.class); + Mockito.when(terminal.isConnected()).thenReturn(true); + Mockito.when(danglingLine.getTerminal()).thenReturn(terminal); + + return Stream.of( + // --- EQUALS--- // + //Generator fields + Arguments.of(EQUALS, FieldType.PAIRED, true, danglingLine, true), + Arguments.of(EQUALS, FieldType.PAIRED, false, danglingLine, false), + // Terminal fields + Arguments.of(EQUALS, FieldType.CONNECTED, true, danglingLine, true), + Arguments.of(EQUALS, FieldType.CONNECTED, false, danglingLine, false), + + // --- NOT_EQUALS--- // + //Generator fields + Arguments.of(NOT_EQUALS, FieldType.PAIRED, false, danglingLine, true), + Arguments.of(NOT_EQUALS, FieldType.PAIRED, true, danglingLine, false), + // Terminal fields + Arguments.of(NOT_EQUALS, FieldType.CONNECTED, false, danglingLine, true), + Arguments.of(NOT_EQUALS, FieldType.CONNECTED, true, danglingLine, false) + ); + } } diff --git a/src/test/java/org/gridsuite/filter/expertfilter/EnumExpertRuleTest.java b/src/test/java/org/gridsuite/filter/expertfilter/EnumExpertRuleTest.java index fc46551..8803514 100644 --- a/src/test/java/org/gridsuite/filter/expertfilter/EnumExpertRuleTest.java +++ b/src/test/java/org/gridsuite/filter/expertfilter/EnumExpertRuleTest.java @@ -128,6 +128,7 @@ static Stream provideArgumentsForTestWithException() { "provideArgumentsForLinesTest", "provideArgumentsForTwoWindingTransformerTest", "provideArgumentsForStaticVarCompensatorTest", + "provideArgumentsForDanglingLineTest", "provideArgumentsForThreeWindingTransformerTest", "provideArgumentsForHvdcLineTest", }) @@ -416,6 +417,42 @@ private static Stream provideArgumentsForBatteryTest() { ); } + private static Stream provideArgumentsForDanglingLineTest() { + + DanglingLine danglingLine = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + // VoltageLevel fields + Substation substation = Mockito.mock(Substation.class); + VoltageLevel voltageLevel = Mockito.mock(VoltageLevel.class); + Mockito.when(voltageLevel.getSubstation()).thenReturn(Optional.of(substation)); + Terminal terminal = Mockito.mock(Terminal.class); + Mockito.when(terminal.getVoltageLevel()).thenReturn(voltageLevel); + Mockito.when(danglingLine.getTerminal()).thenReturn(terminal); + Mockito.when(substation.getCountry()).thenReturn(Optional.of(Country.FR)); + + return Stream.of( + // --- EQUALS --- // + // VoltageLevel fields + Arguments.of(EQUALS, FieldType.COUNTRY, Country.FR.name(), null, danglingLine, true), + Arguments.of(EQUALS, FieldType.COUNTRY, Country.DE.name(), null, danglingLine, false), + + // --- NOT_EQUALS --- // + // VoltageLevel fields + Arguments.of(NOT_EQUALS, FieldType.COUNTRY, Country.DE.name(), null, danglingLine, true), + Arguments.of(NOT_EQUALS, FieldType.COUNTRY, Country.FR.name(), null, danglingLine, false), + + // --- IN --- // + // VoltageLevel fields + Arguments.of(IN, FieldType.COUNTRY, null, Set.of(Country.FR.name(), Country.DE.name()), danglingLine, true), + Arguments.of(IN, FieldType.COUNTRY, null, Set.of(Country.BE.name(), Country.DE.name()), danglingLine, false), + + // --- NOT_IN --- // + // VoltageLevel fields + Arguments.of(NOT_IN, FieldType.COUNTRY, null, Set.of(Country.BE.name(), Country.DE.name()), danglingLine, true), + Arguments.of(NOT_IN, FieldType.COUNTRY, null, Set.of(Country.FR.name(), Country.DE.name()), danglingLine, false) + ); + } + private static Stream provideArgumentsForVoltageLevelTest() { VoltageLevel voltageLevel = Mockito.mock(VoltageLevel.class); diff --git a/src/test/java/org/gridsuite/filter/expertfilter/FilterUuidExpertRuleTest.java b/src/test/java/org/gridsuite/filter/expertfilter/FilterUuidExpertRuleTest.java index 8c47b2e..073748d 100644 --- a/src/test/java/org/gridsuite/filter/expertfilter/FilterUuidExpertRuleTest.java +++ b/src/test/java/org/gridsuite/filter/expertfilter/FilterUuidExpertRuleTest.java @@ -60,6 +60,11 @@ class FilterUuidExpertRuleTest { private static final UUID FILTER_VOLTAGE_LEVEL_1_LINE_2_UUID = UUID.fromString("49281814-7977-4592-ba19-88027e4254e4"); private static final UUID FILTER_VOLTAGE_LEVEL_2_LINE_2_UUID = UUID.fromString("49281815-7977-4592-ba19-88027e4254e4"); + private static final UUID FILTER_DANGLING_LINE_1_UUID = UUID.fromString("18273121-7977-4592-ba19-88027e4254e4"); + private static final UUID FILTER_DANGLING_LINE_2_UUID = UUID.fromString("18273122-7977-4592-ba19-88027e4254e4"); + private static final UUID FILTER_VOLTAGE_LEVEL_DANGLING_LINE_1_UUID = UUID.fromString("18273123-7977-4592-ba19-88027e4254e4"); + private static final UUID FILTER_VOLTAGE_LEVEL_DANGLING_LINE_2_UUID = UUID.fromString("18273124-7977-4592-ba19-88027e4254e4"); + private static final UUID FILTER_HVDC_LINE_1_UUID = UUID.fromString("65432936-7977-4592-ba19-88027e4254e4"); private static final UUID FILTER_HVDC_LINE_2_UUID = UUID.fromString("65432937-7977-4592-ba19-88027e4254e4"); private static final UUID FILTER_VOLTAGE_LEVEL_1_HVDC_LINE_1_UUID = UUID.fromString("65432938-7977-4592-ba19-88027e4254e4"); @@ -104,6 +109,9 @@ private static Stream provideArgumentsForTestWithException() { Line line = Mockito.mock(Line.class); Mockito.when(line.getType()).thenReturn(IdentifiableType.LINE); + DanglingLine danglingLine = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + return Stream.of( // --- Test an unsupported field for each equipment --- // Arguments.of(IS, FieldType.P0, generator, PowsyblException.class), @@ -111,6 +119,7 @@ private static Stream provideArgumentsForTestWithException() { Arguments.of(IS, FieldType.MIN_P, shuntCompensator, PowsyblException.class), Arguments.of(IS, FieldType.HIGH_VOLTAGE_LIMIT, battery, PowsyblException.class), Arguments.of(IS, FieldType.MARGINAL_COST, line, PowsyblException.class), + Arguments.of(IS, FieldType.MARGINAL_COST, danglingLine, PowsyblException.class), // --- Test an unsupported operator for this rule type --- // Arguments.of(EQUALS, FieldType.ID, generator, PowsyblException.class), @@ -156,6 +165,12 @@ private void initMockFilters(Network network, MockedStatic f mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_1_LINE_2_UUID, new IdentifiableAttributes("VL12", IdentifiableType.VOLTAGE_LEVEL, 100D)); mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_2_LINE_2_UUID, new IdentifiableAttributes("VL22", IdentifiableType.VOLTAGE_LEVEL, 100D)); + // Dangling Lines + mockGetFilterEquipments(filtersUtilsMock, network, FILTER_DANGLING_LINE_1_UUID, new IdentifiableAttributes("ID1", IdentifiableType.DANGLING_LINE, 100D)); + mockGetFilterEquipments(filtersUtilsMock, network, FILTER_DANGLING_LINE_2_UUID, new IdentifiableAttributes("ID2", IdentifiableType.DANGLING_LINE, 100D)); + mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_DANGLING_LINE_1_UUID, new IdentifiableAttributes("VL1", IdentifiableType.VOLTAGE_LEVEL, 100D)); + mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_DANGLING_LINE_2_UUID, new IdentifiableAttributes("VL2", IdentifiableType.VOLTAGE_LEVEL, 100D)); + // Hvdc Line mockGetFilterEquipments(filtersUtilsMock, network, FILTER_HVDC_LINE_1_UUID, new IdentifiableAttributes("ID1", IdentifiableType.HVDC_LINE, 100D)); mockGetFilterEquipments(filtersUtilsMock, network, FILTER_HVDC_LINE_2_UUID, new IdentifiableAttributes("ID2", IdentifiableType.HVDC_LINE, 100D)); @@ -163,6 +178,12 @@ private void initMockFilters(Network network, MockedStatic f mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_2_HVDC_LINE_1_UUID, new IdentifiableAttributes("VL21", IdentifiableType.VOLTAGE_LEVEL, 100D)); mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_1_HVDC_LINE_2_UUID, new IdentifiableAttributes("VL12", IdentifiableType.VOLTAGE_LEVEL, 100D)); mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_2_HVDC_LINE_2_UUID, new IdentifiableAttributes("VL22", IdentifiableType.VOLTAGE_LEVEL, 100D)); + + // Dangling Lines + mockGetFilterEquipments(filtersUtilsMock, network, FILTER_DANGLING_LINE_1_UUID, new IdentifiableAttributes("ID1", IdentifiableType.DANGLING_LINE, 100D)); + mockGetFilterEquipments(filtersUtilsMock, network, FILTER_DANGLING_LINE_2_UUID, new IdentifiableAttributes("ID2", IdentifiableType.DANGLING_LINE, 100D)); + mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_DANGLING_LINE_1_UUID, new IdentifiableAttributes("VL1", IdentifiableType.VOLTAGE_LEVEL, 100D)); + mockGetFilterEquipments(filtersUtilsMock, network, FILTER_VOLTAGE_LEVEL_DANGLING_LINE_2_UUID, new IdentifiableAttributes("VL2", IdentifiableType.VOLTAGE_LEVEL, 100D)); } @ParameterizedTest @@ -171,8 +192,11 @@ private void initMockFilters(Network network, MockedStatic f "provideArgumentsForLoadTest", "provideArgumentsForBatteryTest", "provideArgumentsForShuntCompensatorTest", + "provideArgumentsForDanglingLinesTest", "provideArgumentsForLineTest", - "provideArgumentsForHvdcTest" + "provideArgumentsForHvdcTest", + "provideArgumentsForLineTest", + "provideArgumentsForDanglingLinesTest", }) void testEvaluateRule(OperatorType operator, FieldType field, String value, Set values, Identifiable equipment, boolean expected) { try (MockedStatic filterServiceUtilsMockedStatic = Mockito.mockStatic(FilterServiceUtils.class)) { @@ -493,4 +517,50 @@ private static Stream provideArgumentsForHvdcTest() { Arguments.of(IS_NOT_PART_OF, FieldType.VOLTAGE_LEVEL_ID_2, null, Set.of(FILTER_VOLTAGE_LEVEL_2_HVDC_LINE_2_UUID.toString()), hvdcLine1, true) ); } + + private static Stream provideArgumentsForDanglingLinesTest() { + Network network = Mockito.mock(Network.class); + + DanglingLine danglingLine1 = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine1.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + Mockito.when(danglingLine1.getNetwork()).thenReturn(network); + DanglingLine danglingLine2 = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine2.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + Mockito.when(danglingLine2.getNetwork()).thenReturn(network); + + // Common fields + Mockito.when(danglingLine1.getId()).thenReturn("ID1"); + Mockito.when(danglingLine2.getId()).thenReturn("ID2"); + + // VoltageLevel fields + VoltageLevel voltageLevel1 = Mockito.mock(VoltageLevel.class); + Mockito.when(voltageLevel1.getId()).thenReturn("VL1"); + Terminal terminal1 = Mockito.mock(Terminal.class); + Mockito.when(terminal1.getVoltageLevel()).thenReturn(voltageLevel1); + Mockito.when(danglingLine1.getTerminal()).thenReturn(terminal1); + + VoltageLevel voltageLevel2 = Mockito.mock(VoltageLevel.class); + Mockito.when(voltageLevel2.getId()).thenReturn("VL2"); + Terminal terminal2 = Mockito.mock(Terminal.class); + Mockito.when(terminal2.getVoltageLevel()).thenReturn(voltageLevel2); + Mockito.when(danglingLine2.getTerminal()).thenReturn(terminal2); + + return Stream.of( + // --- IS_PART_OF --- // + // Common fields + Arguments.of(IS_PART_OF, FieldType.ID, null, Set.of(FILTER_DANGLING_LINE_1_UUID.toString()), danglingLine1, true), + Arguments.of(IS_PART_OF, FieldType.ID, null, Set.of(FILTER_DANGLING_LINE_2_UUID.toString()), danglingLine2, true), + // VoltageLevel fields + Arguments.of(IS_PART_OF, FieldType.VOLTAGE_LEVEL_ID, null, Set.of(FILTER_VOLTAGE_LEVEL_DANGLING_LINE_1_UUID.toString()), danglingLine1, true), + Arguments.of(IS_PART_OF, FieldType.VOLTAGE_LEVEL_ID, null, Set.of(FILTER_VOLTAGE_LEVEL_DANGLING_LINE_2_UUID.toString()), danglingLine2, true), + + // --- IS_NOT_PART_OF --- // + // Common fields + Arguments.of(IS_NOT_PART_OF, FieldType.ID, null, Set.of(FILTER_DANGLING_LINE_1_UUID.toString()), danglingLine2, true), + Arguments.of(IS_NOT_PART_OF, FieldType.ID, null, Set.of(FILTER_DANGLING_LINE_2_UUID.toString()), danglingLine1, true), + // VoltageLevel fields + Arguments.of(IS_NOT_PART_OF, FieldType.VOLTAGE_LEVEL_ID, null, Set.of(FILTER_VOLTAGE_LEVEL_1_LINE_2_UUID.toString()), danglingLine1, true), + Arguments.of(IS_NOT_PART_OF, FieldType.VOLTAGE_LEVEL_ID, null, Set.of(FILTER_VOLTAGE_LEVEL_GENERATOR_1_UUID.toString()), danglingLine2, true) + ); + } } diff --git a/src/test/java/org/gridsuite/filter/expertfilter/NumberExpertRuleTest.java b/src/test/java/org/gridsuite/filter/expertfilter/NumberExpertRuleTest.java index 06ebfaf..fc828c4 100644 --- a/src/test/java/org/gridsuite/filter/expertfilter/NumberExpertRuleTest.java +++ b/src/test/java/org/gridsuite/filter/expertfilter/NumberExpertRuleTest.java @@ -107,6 +107,7 @@ static Stream provideArgumentsForTestWithException() { "provideArgumentsForLinesTest", "provideArgumentsForTwoWindingTransformerTest", "provideArgumentsForStaticVarCompensatorTest", + "provideArgumentsForDanglingLineTest", "provideArgumentsForThreeWindingTransformerTest", "provideArgumentsForHvdcLinesTest", }) @@ -3118,6 +3119,240 @@ private static Stream provideArgumentsForStaticVarCompensatorTest() { ); } + private static Stream provideArgumentsForDanglingLineTest() { + DanglingLine danglingLine = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + Mockito.when(danglingLine.getR()).thenReturn(0.1); + Mockito.when(danglingLine.getX()).thenReturn(0.2); + Mockito.when(danglingLine.getB()).thenReturn(0.3); + Mockito.when(danglingLine.getG()).thenReturn(0.4); + Mockito.when(danglingLine.getP0()).thenReturn(100.0); + Mockito.when(danglingLine.getQ0()).thenReturn(50.0); + + // VoltageLevel fields + VoltageLevel voltageLevel = Mockito.mock(VoltageLevel.class); + Terminal terminal = Mockito.mock(Terminal.class); + Mockito.when(terminal.getVoltageLevel()).thenReturn(voltageLevel); + Mockito.when(danglingLine.getTerminal()).thenReturn(terminal); + Mockito.when(voltageLevel.getNominalV()).thenReturn(13.0); + + // for testing none EXISTS + DanglingLine danglingLine1 = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine1.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + Mockito.when(danglingLine1.getB()).thenReturn(Double.NaN); + Mockito.when(danglingLine1.getR()).thenReturn(Double.NaN); + Mockito.when(danglingLine1.getG()).thenReturn(Double.NaN); + Mockito.when(danglingLine1.getX()).thenReturn(Double.NaN); + Mockito.when(danglingLine1.getP0()).thenReturn(Double.NaN); + Mockito.when(danglingLine1.getQ0()).thenReturn(Double.NaN); + // VoltageLevel fields + VoltageLevel voltageLevel1 = Mockito.mock(VoltageLevel.class); + Terminal terminal1 = Mockito.mock(Terminal.class); + Mockito.when(terminal1.getVoltageLevel()).thenReturn(voltageLevel1); + Mockito.when(danglingLine1.getTerminal()).thenReturn(terminal1); + Mockito.when(voltageLevel1.getNominalV()).thenReturn(Double.NaN); + + return Stream.of( + // --- EQUALS --- // + // VoltageLevel fields + Arguments.of(EQUALS, FieldType.NOMINAL_VOLTAGE, 13.0, null, danglingLine, true), + Arguments.of(EQUALS, FieldType.NOMINAL_VOLTAGE, 14.0, null, danglingLine, false), + // Dangling Line fields + Arguments.of(EQUALS, FieldType.SERIE_RESISTANCE, 0.1, null, danglingLine, true), + Arguments.of(EQUALS, FieldType.SERIE_REACTANCE, 0.2, null, danglingLine, true), + Arguments.of(EQUALS, FieldType.SHUNT_SUSCEPTANCE, 0.3, null, danglingLine, true), + Arguments.of(EQUALS, FieldType.SHUNT_CONDUCTANCE, 0.4, null, danglingLine, true), + Arguments.of(EQUALS, FieldType.P0, 100.0, null, danglingLine, true), + Arguments.of(EQUALS, FieldType.Q0, 50.0, null, danglingLine, true), + + // --- GREATER_OR_EQUALS --- // + // VoltageLevel fields + Arguments.of(GREATER_OR_EQUALS, FieldType.NOMINAL_VOLTAGE, 12.0, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.NOMINAL_VOLTAGE, 13.0, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.NOMINAL_VOLTAGE, 14.0, null, danglingLine, false), + // Dangling Line fields + Arguments.of(GREATER_OR_EQUALS, FieldType.SERIE_RESISTANCE, 0.05, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.SERIE_RESISTANCE, 0.1, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.SERIE_RESISTANCE, 0.15, null, danglingLine, false), + Arguments.of(GREATER_OR_EQUALS, FieldType.SERIE_REACTANCE, 0.1, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.SERIE_REACTANCE, 0.2, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.SERIE_REACTANCE, 0.3, null, danglingLine, false), + Arguments.of(GREATER_OR_EQUALS, FieldType.SHUNT_SUSCEPTANCE, 0.2, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.SHUNT_SUSCEPTANCE, 0.3, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.SHUNT_SUSCEPTANCE, 0.4, null, danglingLine, false), + Arguments.of(GREATER_OR_EQUALS, FieldType.SHUNT_CONDUCTANCE, 0.3, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.SHUNT_CONDUCTANCE, 0.4, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.SHUNT_CONDUCTANCE, 0.5, null, danglingLine, false), + Arguments.of(GREATER_OR_EQUALS, FieldType.P0, 50.0, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.P0, 100.0, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.P0, 200.0, null, danglingLine, false), + Arguments.of(GREATER_OR_EQUALS, FieldType.Q0, 25.0, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.Q0, 50.0, null, danglingLine, true), + Arguments.of(GREATER_OR_EQUALS, FieldType.Q0, 100.0, null, danglingLine, false), + + // --- GREATER --- // + // VoltageLevel fields + Arguments.of(GREATER, FieldType.NOMINAL_VOLTAGE, 12.0, null, danglingLine, true), + Arguments.of(GREATER, FieldType.NOMINAL_VOLTAGE, 13.0, null, danglingLine, false), + Arguments.of(GREATER, FieldType.NOMINAL_VOLTAGE, 14.0, null, danglingLine, false), + // Dangling Line fields + Arguments.of(GREATER, FieldType.SERIE_RESISTANCE, 0.05, null, danglingLine, true), + Arguments.of(GREATER, FieldType.SERIE_RESISTANCE, 0.1, null, danglingLine, false), + Arguments.of(GREATER, FieldType.SERIE_RESISTANCE, 0.15, null, danglingLine, false), + Arguments.of(GREATER, FieldType.SERIE_REACTANCE, 0.1, null, danglingLine, true), + Arguments.of(GREATER, FieldType.SERIE_REACTANCE, 0.2, null, danglingLine, false), + Arguments.of(GREATER, FieldType.SERIE_REACTANCE, 0.3, null, danglingLine, false), + Arguments.of(GREATER, FieldType.SHUNT_SUSCEPTANCE, 0.2, null, danglingLine, true), + Arguments.of(GREATER, FieldType.SHUNT_SUSCEPTANCE, 0.3, null, danglingLine, false), + Arguments.of(GREATER, FieldType.SHUNT_SUSCEPTANCE, 0.4, null, danglingLine, false), + Arguments.of(GREATER, FieldType.SHUNT_CONDUCTANCE, 0.3, null, danglingLine, true), + Arguments.of(GREATER, FieldType.SHUNT_CONDUCTANCE, 0.4, null, danglingLine, false), + Arguments.of(GREATER, FieldType.SHUNT_CONDUCTANCE, 0.5, null, danglingLine, false), + Arguments.of(GREATER, FieldType.P0, 50.0, null, danglingLine, true), + Arguments.of(GREATER, FieldType.P0, 100.0, null, danglingLine, false), + Arguments.of(GREATER, FieldType.P0, 200.0, null, danglingLine, false), + Arguments.of(GREATER, FieldType.Q0, 25.0, null, danglingLine, true), + Arguments.of(GREATER, FieldType.Q0, 50.0, null, danglingLine, false), + Arguments.of(GREATER, FieldType.Q0, 100.0, null, danglingLine, false), + + // --- LOWER_OR_EQUALS --- // + // VoltageLevel fields + Arguments.of(LOWER_OR_EQUALS, FieldType.NOMINAL_VOLTAGE, 14.0, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.NOMINAL_VOLTAGE, 13.0, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.NOMINAL_VOLTAGE, 12.0, null, danglingLine, false), + // Dangling Line fields + Arguments.of(LOWER_OR_EQUALS, FieldType.SERIE_RESISTANCE, 0.05, null, danglingLine, false), + Arguments.of(LOWER_OR_EQUALS, FieldType.SERIE_RESISTANCE, 0.1, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.SERIE_RESISTANCE, 0.15, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.SERIE_REACTANCE, 0.1, null, danglingLine, false), + Arguments.of(LOWER_OR_EQUALS, FieldType.SERIE_REACTANCE, 0.2, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.SERIE_REACTANCE, 0.3, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.SHUNT_SUSCEPTANCE, 0.2, null, danglingLine, false), + Arguments.of(LOWER_OR_EQUALS, FieldType.SHUNT_SUSCEPTANCE, 0.3, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.SHUNT_SUSCEPTANCE, 0.4, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.SHUNT_CONDUCTANCE, 0.3, null, danglingLine, false), + Arguments.of(LOWER_OR_EQUALS, FieldType.SHUNT_CONDUCTANCE, 0.4, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.SHUNT_CONDUCTANCE, 0.5, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.P0, 50.0, null, danglingLine, false), + Arguments.of(LOWER_OR_EQUALS, FieldType.P0, 100.0, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.P0, 200.0, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.Q0, 25.0, null, danglingLine, false), + Arguments.of(LOWER_OR_EQUALS, FieldType.Q0, 50.0, null, danglingLine, true), + Arguments.of(LOWER_OR_EQUALS, FieldType.Q0, 100.0, null, danglingLine, true), + + // --- LOWER --- // + // VoltageLevel fields + Arguments.of(LOWER, FieldType.NOMINAL_VOLTAGE, 14.0, null, danglingLine, true), + Arguments.of(LOWER, FieldType.NOMINAL_VOLTAGE, 13.0, null, danglingLine, false), + Arguments.of(LOWER, FieldType.NOMINAL_VOLTAGE, 12.0, null, danglingLine, false), + // Dangling Line fields + Arguments.of(LOWER, FieldType.SERIE_RESISTANCE, 0.05, null, danglingLine, false), + Arguments.of(LOWER, FieldType.SERIE_RESISTANCE, 0.1, null, danglingLine, false), + Arguments.of(LOWER, FieldType.SERIE_RESISTANCE, 0.15, null, danglingLine, true), + Arguments.of(LOWER, FieldType.SERIE_REACTANCE, 0.1, null, danglingLine, false), + Arguments.of(LOWER, FieldType.SERIE_REACTANCE, 0.2, null, danglingLine, false), + Arguments.of(LOWER, FieldType.SERIE_REACTANCE, 0.3, null, danglingLine, true), + Arguments.of(LOWER, FieldType.SHUNT_SUSCEPTANCE, 0.2, null, danglingLine, false), + Arguments.of(LOWER, FieldType.SHUNT_SUSCEPTANCE, 0.3, null, danglingLine, false), + Arguments.of(LOWER, FieldType.SHUNT_SUSCEPTANCE, 0.4, null, danglingLine, true), + Arguments.of(LOWER, FieldType.SHUNT_CONDUCTANCE, 0.3, null, danglingLine, false), + Arguments.of(LOWER, FieldType.SHUNT_CONDUCTANCE, 0.4, null, danglingLine, false), + Arguments.of(LOWER, FieldType.SHUNT_CONDUCTANCE, 0.5, null, danglingLine, true), + Arguments.of(LOWER, FieldType.P0, 50.0, null, danglingLine, false), + Arguments.of(LOWER, FieldType.P0, 100.0, null, danglingLine, false), + Arguments.of(LOWER, FieldType.P0, 200.0, null, danglingLine, true), + Arguments.of(LOWER, FieldType.Q0, 25.0, null, danglingLine, false), + Arguments.of(LOWER, FieldType.Q0, 50.0, null, danglingLine, false), + Arguments.of(LOWER, FieldType.Q0, 100.0, null, danglingLine, true), + // --- BETWEEN --- // + // VoltageLevel fields + Arguments.of(BETWEEN, FieldType.NOMINAL_VOLTAGE, null, Set.of(12.0, 14.0), danglingLine, true), + Arguments.of(BETWEEN, FieldType.NOMINAL_VOLTAGE, null, Set.of(13.5, 14.0), danglingLine, false), + // Dangling Line fields + Arguments.of(BETWEEN, FieldType.SERIE_RESISTANCE, null, Set.of(0.05, 0.15), danglingLine, true), + Arguments.of(BETWEEN, FieldType.SERIE_RESISTANCE, null, Set.of(0.2, 0.3), danglingLine, false), + Arguments.of(BETWEEN, FieldType.SERIE_REACTANCE, null, Set.of(0.15, 0.25), danglingLine, true), + Arguments.of(BETWEEN, FieldType.SERIE_REACTANCE, null, Set.of(0.3, 0.4), danglingLine, false), + Arguments.of(BETWEEN, FieldType.SHUNT_SUSCEPTANCE, null, Set.of(0.25, 0.35), danglingLine, true), + Arguments.of(BETWEEN, FieldType.SHUNT_SUSCEPTANCE, null, Set.of(0.4, 0.5), danglingLine, false), + Arguments.of(BETWEEN, FieldType.SHUNT_CONDUCTANCE, null, Set.of(0.35, 0.45), danglingLine, true), + Arguments.of(BETWEEN, FieldType.SHUNT_CONDUCTANCE, null, Set.of(0.5, 0.6), danglingLine, false), + Arguments.of(BETWEEN, FieldType.P0, null, Set.of(50.0, 150.0), danglingLine, true), + Arguments.of(BETWEEN, FieldType.P0, null, Set.of(120.0, 180.0), danglingLine, false), + Arguments.of(BETWEEN, FieldType.Q0, null, Set.of(25.0, 75.0), danglingLine, true), + Arguments.of(BETWEEN, FieldType.Q0, null, Set.of(120.0, 180.0), danglingLine, false), + // --- EXISTS --- // + // VoltageLevel fields + Arguments.of(EXISTS, FieldType.NOMINAL_VOLTAGE, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.NOMINAL_VOLTAGE, null, null, danglingLine1, false), + //Battery fields + Arguments.of(EXISTS, FieldType.SERIE_RESISTANCE, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.SERIE_RESISTANCE, null, null, danglingLine1, false), + Arguments.of(EXISTS, FieldType.SERIE_REACTANCE, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.SERIE_REACTANCE, null, null, danglingLine1, false), + Arguments.of(EXISTS, FieldType.SHUNT_SUSCEPTANCE, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.SHUNT_SUSCEPTANCE, null, null, danglingLine1, false), + Arguments.of(EXISTS, FieldType.SHUNT_CONDUCTANCE, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.SHUNT_CONDUCTANCE, null, null, danglingLine1, false), + Arguments.of(EXISTS, FieldType.P0, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.P0, null, null, danglingLine1, false), + Arguments.of(EXISTS, FieldType.Q0, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.Q0, null, null, danglingLine1, false), + // --- NOT_EXISTS --- // + // VoltageLevel fields + Arguments.of(NOT_EXISTS, FieldType.NOMINAL_VOLTAGE, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.NOMINAL_VOLTAGE, null, null, danglingLine1, true), + // Dangling Line fields + Arguments.of(NOT_EXISTS, FieldType.SERIE_RESISTANCE, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.SERIE_RESISTANCE, null, null, danglingLine1, true), + Arguments.of(NOT_EXISTS, FieldType.SERIE_REACTANCE, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.SERIE_REACTANCE, null, null, danglingLine1, true), + Arguments.of(NOT_EXISTS, FieldType.SHUNT_SUSCEPTANCE, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.SHUNT_SUSCEPTANCE, null, null, danglingLine1, true), + Arguments.of(NOT_EXISTS, FieldType.SHUNT_CONDUCTANCE, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.SHUNT_CONDUCTANCE, null, null, danglingLine1, true), + Arguments.of(NOT_EXISTS, FieldType.P0, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.P0, null, null, danglingLine1, true), + Arguments.of(NOT_EXISTS, FieldType.Q0, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.Q0, null, null, danglingLine1, true), + + // --- IN --- // + // VoltageLevel fields + Arguments.of(IN, FieldType.NOMINAL_VOLTAGE, null, Set.of(12.0, 13.0, 14.0), danglingLine, true), + Arguments.of(IN, FieldType.NOMINAL_VOLTAGE, null, Set.of(12.0, 14.0), danglingLine, false), + // Dangling Line + Arguments.of(IN, FieldType.SERIE_RESISTANCE, null, Set.of(0.05, 0.1, 0.15), danglingLine, true), + Arguments.of(IN, FieldType.SERIE_RESISTANCE, null, Set.of(0.2, 0.3), danglingLine, false), + Arguments.of(IN, FieldType.SERIE_REACTANCE, null, Set.of(0.15, 0.2, 0.25), danglingLine, true), + Arguments.of(IN, FieldType.SERIE_REACTANCE, null, Set.of(0.3, 0.4), danglingLine, false), + Arguments.of(IN, FieldType.SHUNT_SUSCEPTANCE, null, Set.of(0.25, 0.3, 0.35), danglingLine, true), + Arguments.of(IN, FieldType.SHUNT_SUSCEPTANCE, null, Set.of(0.4, 0.5), danglingLine, false), + Arguments.of(IN, FieldType.SHUNT_CONDUCTANCE, null, Set.of(0.35, 0.4, 0.45), danglingLine, true), + Arguments.of(IN, FieldType.SHUNT_CONDUCTANCE, null, Set.of(0.5, 0.6), danglingLine, false), + Arguments.of(IN, FieldType.P0, null, Set.of(50.0, 100.0, 150.0), danglingLine, true), + Arguments.of(IN, FieldType.P0, null, Set.of(120.0, 180.0), danglingLine, false), + Arguments.of(IN, FieldType.Q0, null, Set.of(25.0, 50.0, 75.0), danglingLine, true), + Arguments.of(IN, FieldType.Q0, null, Set.of(120.0, 180.0), danglingLine, false), + // --- NOT_IN --- // + // VoltageLevel fields + Arguments.of(NOT_IN, FieldType.NOMINAL_VOLTAGE, null, Set.of(12.0, 14.0), danglingLine, true), + Arguments.of(NOT_IN, FieldType.NOMINAL_VOLTAGE, null, Set.of(12.0, 13.0, 14.0), danglingLine, false), + // Dangling Line + Arguments.of(NOT_IN, FieldType.SERIE_RESISTANCE, null, Set.of(0.05, 0.1, 0.15), danglingLine, false), + Arguments.of(NOT_IN, FieldType.SERIE_RESISTANCE, null, Set.of(0.2, 0.3), danglingLine, true), + Arguments.of(NOT_IN, FieldType.SERIE_REACTANCE, null, Set.of(0.15, 0.2, 0.25), danglingLine, false), + Arguments.of(NOT_IN, FieldType.SERIE_REACTANCE, null, Set.of(0.3, 0.4), danglingLine, true), + Arguments.of(NOT_IN, FieldType.SHUNT_SUSCEPTANCE, null, Set.of(0.25, 0.3, 0.35), danglingLine, false), + Arguments.of(NOT_IN, FieldType.SHUNT_SUSCEPTANCE, null, Set.of(0.4, 0.5), danglingLine, true), + Arguments.of(NOT_IN, FieldType.SHUNT_CONDUCTANCE, null, Set.of(0.35, 0.4, 0.45), danglingLine, false), + Arguments.of(NOT_IN, FieldType.SHUNT_CONDUCTANCE, null, Set.of(0.5, 0.6), danglingLine, true), + Arguments.of(NOT_IN, FieldType.P0, null, Set.of(50.0, 100.0, 150.0), danglingLine, false), + Arguments.of(NOT_IN, FieldType.P0, null, Set.of(120.0, 180.0), danglingLine, true), + Arguments.of(NOT_IN, FieldType.Q0, null, Set.of(25.0, 50.0, 75.0), danglingLine, false), + Arguments.of(NOT_IN, FieldType.Q0, null, Set.of(120.0, 180.0), danglingLine, true) + ); + } + private static Stream provideArgumentsForHvdcLinesTest() { HvdcLine hvdcLine = Mockito.mock(HvdcLine.class); Mockito.when(hvdcLine.getType()).thenReturn(IdentifiableType.HVDC_LINE); diff --git a/src/test/java/org/gridsuite/filter/expertfilter/PropertiesExpertRuleTest.java b/src/test/java/org/gridsuite/filter/expertfilter/PropertiesExpertRuleTest.java index 0fcd972..f3a12b9 100644 --- a/src/test/java/org/gridsuite/filter/expertfilter/PropertiesExpertRuleTest.java +++ b/src/test/java/org/gridsuite/filter/expertfilter/PropertiesExpertRuleTest.java @@ -111,6 +111,7 @@ private static Stream provideArgumentsForTestWithException() { "provideArgumentsForShuntCompensatorTest", "provideArgumentsForLineTest", "provideArgumentsForStaticVarCompensatorTest", + "provideArgumentsForDanglingLineTest", "provideArgumentsForThreeWindingTransformerTest", "provideArgumentsForHvdcLineTest", }) @@ -432,4 +433,29 @@ private static Stream provideArgumentsForHvdcLineTest() { ); } + private static Stream provideArgumentsForDanglingLineTest() { + DanglingLine danglingLine = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + Mockito.when(danglingLine.getProperty("propertyNameDL")).thenReturn("PropertyValueDL"); + + Substation substation = Mockito.mock(Substation.class); + VoltageLevel voltageLevel = Mockito.mock(VoltageLevel.class); + Mockito.when(voltageLevel.getProperty("CodeOI")).thenReturn("33"); + Mockito.when(voltageLevel.getNullableSubstation()).thenReturn(substation); + Terminal terminal = Mockito.mock(Terminal.class); + Mockito.when(terminal.getVoltageLevel()).thenReturn(voltageLevel); + Mockito.when(danglingLine.getTerminal()).thenReturn(terminal); + Mockito.when(substation.getProperty("propertyNameSubstation")).thenReturn("PropertyValueSubstation"); + + return Stream.of( + // --- IN --- // + Arguments.of(IN, FieldType.FREE_PROPERTIES, "propertyNameDL", List.of("propertyValueDL"), danglingLine, true), + Arguments.of(IN, FieldType.FREE_PROPERTIES, "propertyNameDL", List.of("propertyValueDL2"), danglingLine, false), + Arguments.of(IN, FieldType.SUBSTATION_PROPERTIES, "propertyNameSubstation", List.of("propertyValueSubstation"), danglingLine, true), + Arguments.of(IN, FieldType.SUBSTATION_PROPERTIES, "propertyNameSubstation", List.of("propertyValueSubstation1"), danglingLine, false), + Arguments.of(IN, FieldType.VOLTAGE_LEVEL_PROPERTIES, "CodeOI", List.of("33"), danglingLine, true), + Arguments.of(IN, FieldType.VOLTAGE_LEVEL_PROPERTIES, "CodeOI", List.of("22"), danglingLine, false) + ); + } + } diff --git a/src/test/java/org/gridsuite/filter/expertfilter/StringExpertRuleTest.java b/src/test/java/org/gridsuite/filter/expertfilter/StringExpertRuleTest.java index a18c5eb..4f9de8e 100644 --- a/src/test/java/org/gridsuite/filter/expertfilter/StringExpertRuleTest.java +++ b/src/test/java/org/gridsuite/filter/expertfilter/StringExpertRuleTest.java @@ -118,6 +118,7 @@ static Stream provideArgumentsForTestWithException() { "provideArgumentsForLinesTest", "provideArgumentsForTwoWindingsTransformerTest", "provideArgumentsForStaticVarCompensatorTest", + "provideArgumentsForDanglingLineTest", "provideArgumentsForThreeWindingsTransformerTest", "provideArgumentsForHvdcLineTest", }) @@ -1194,6 +1195,114 @@ private static Stream provideArgumentsForStaticVarCompensatorTest() { ); } + private static Stream provideArgumentsForDanglingLineTest() { + + DanglingLine danglingLine = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + // Common fields + Mockito.when(danglingLine.getId()).thenReturn("ID"); + Mockito.when(danglingLine.getOptionalName()).thenReturn(Optional.of("NAME")); + // VoltageLevel fields + VoltageLevel voltageLevel = Mockito.mock(VoltageLevel.class); + Mockito.when(voltageLevel.getId()).thenReturn("VL"); + Terminal terminal = Mockito.mock(Terminal.class); + Mockito.when(terminal.getVoltageLevel()).thenReturn(voltageLevel); + Mockito.when(danglingLine.getTerminal()).thenReturn(terminal); + + // for testing none EXISTS + DanglingLine danglingLine1 = Mockito.mock(DanglingLine.class); + Mockito.when(danglingLine1.getType()).thenReturn(IdentifiableType.DANGLING_LINE); + Mockito.when(danglingLine1.getOptionalName()).thenReturn(Optional.of("")); + // VoltageLevel fields + VoltageLevel voltageLevel1 = Mockito.mock(VoltageLevel.class); + Terminal terminal1 = Mockito.mock(Terminal.class); + Mockito.when(terminal1.getVoltageLevel()).thenReturn(voltageLevel1); + Mockito.when(danglingLine1.getTerminal()).thenReturn(terminal1); + + return Stream.of( + // --- IS --- // + // Common fields + Arguments.of(IS, FieldType.ID, "id", null, danglingLine, true), + Arguments.of(IS, FieldType.ID, "id_1", null, danglingLine, false), + Arguments.of(IS, FieldType.NAME, "name", null, danglingLine, true), + Arguments.of(IS, FieldType.NAME, "name_1", null, danglingLine, false), + // VoltageLevel fields + Arguments.of(IS, FieldType.VOLTAGE_LEVEL_ID, "vl", null, danglingLine, true), + Arguments.of(IS, FieldType.VOLTAGE_LEVEL_ID, "vl_1", null, danglingLine, false), + + // --- CONTAINS --- // + // Common fields + Arguments.of(CONTAINS, FieldType.ID, "i", null, danglingLine, true), + Arguments.of(CONTAINS, FieldType.ID, "ii", null, danglingLine, false), + Arguments.of(CONTAINS, FieldType.NAME, "nam", null, danglingLine, true), + Arguments.of(CONTAINS, FieldType.NAME, "namm", null, danglingLine, false), + // VoltageLevel fields + Arguments.of(CONTAINS, FieldType.VOLTAGE_LEVEL_ID, "v", null, danglingLine, true), + Arguments.of(CONTAINS, FieldType.VOLTAGE_LEVEL_ID, "vv", null, danglingLine, false), + + // --- BEGINS_WITH --- // + // Common fields + Arguments.of(BEGINS_WITH, FieldType.ID, "i", null, danglingLine, true), + Arguments.of(BEGINS_WITH, FieldType.ID, "j", null, danglingLine, false), + Arguments.of(BEGINS_WITH, FieldType.NAME, "n", null, danglingLine, true), + Arguments.of(BEGINS_WITH, FieldType.NAME, "m", null, danglingLine, false), + // VoltageLevel fields + Arguments.of(BEGINS_WITH, FieldType.VOLTAGE_LEVEL_ID, "v", null, danglingLine, true), + Arguments.of(BEGINS_WITH, FieldType.VOLTAGE_LEVEL_ID, "s", null, danglingLine, false), + + // --- ENDS_WITH --- // + // Common fields + Arguments.of(ENDS_WITH, FieldType.ID, "d", null, danglingLine, true), + Arguments.of(ENDS_WITH, FieldType.ID, "e", null, danglingLine, false), + Arguments.of(ENDS_WITH, FieldType.NAME, "e", null, danglingLine, true), + Arguments.of(ENDS_WITH, FieldType.NAME, "f", null, danglingLine, false), + // VoltageLevel fields + Arguments.of(ENDS_WITH, FieldType.VOLTAGE_LEVEL_ID, "l", null, danglingLine, true), + Arguments.of(ENDS_WITH, FieldType.VOLTAGE_LEVEL_ID, "m", null, danglingLine, false), + + // --- EXISTS --- // + // Common fields + Arguments.of(EXISTS, FieldType.ID, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.ID, null, null, danglingLine1, false), + Arguments.of(EXISTS, FieldType.NAME, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.NAME, null, null, danglingLine1, false), + // VoltageLevel fields + Arguments.of(EXISTS, FieldType.VOLTAGE_LEVEL_ID, null, null, danglingLine, true), + Arguments.of(EXISTS, FieldType.VOLTAGE_LEVEL_ID, null, null, danglingLine1, false), + + // --- NOT_EXISTS --- // + // Common fields + Arguments.of(NOT_EXISTS, FieldType.ID, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.ID, null, null, danglingLine1, true), + Arguments.of(NOT_EXISTS, FieldType.NAME, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.NAME, null, null, danglingLine1, true), + // VoltageLevel fields + Arguments.of(NOT_EXISTS, FieldType.VOLTAGE_LEVEL_ID, null, null, danglingLine, false), + Arguments.of(NOT_EXISTS, FieldType.VOLTAGE_LEVEL_ID, null, null, danglingLine1, true), + + // --- IN --- // + // Common fields + Arguments.of(IN, FieldType.ID, null, Set.of("Id", "ID_2"), danglingLine, true), + Arguments.of(IN, FieldType.ID, null, Set.of("Id_2", "ID_3"), danglingLine, false), + Arguments.of(IN, FieldType.NAME, null, Set.of("Name", "NAME_2"), danglingLine, true), + Arguments.of(IN, FieldType.NAME, null, Set.of("Name_2", "NAME_3"), danglingLine, false), + // VoltageLevel fields + Arguments.of(IN, FieldType.VOLTAGE_LEVEL_ID, null, Set.of("Vl", "VL_2"), danglingLine, true), + Arguments.of(IN, FieldType.VOLTAGE_LEVEL_ID, null, Set.of("Vl_2", "VL_3"), danglingLine, false), + + // --- NOT_IN --- // + // Common fields + Arguments.of(NOT_IN, FieldType.ID, null, Set.of("Id_2", "ID_3"), danglingLine, true), + Arguments.of(NOT_IN, FieldType.ID, null, Set.of("Id", "ID_2"), danglingLine, false), + Arguments.of(NOT_IN, FieldType.NAME, null, Set.of("Name_2", "NAME_3"), danglingLine, true), + Arguments.of(NOT_IN, FieldType.NAME, null, Set.of("Name", "NAME_2"), danglingLine, false), + // VoltageLevel fields + Arguments.of(NOT_IN, FieldType.VOLTAGE_LEVEL_ID, null, Set.of("Vl_2", "VL_3"), danglingLine, true), + Arguments.of(NOT_IN, FieldType.VOLTAGE_LEVEL_ID, null, Set.of("Vl", "VL_2"), danglingLine, false) + + ); + } + private static Stream provideArgumentsForThreeWindingsTransformerTest() { ThreeWindingsTransformer threeWindingsTransformer = Mockito.mock(ThreeWindingsTransformer.class); @@ -1514,5 +1623,4 @@ private static Stream provideArgumentsForHvdcLineTest() { Arguments.of(NOT_IN, FieldType.CONVERTER_STATION_ID_2, null, Set.of("STATION2", "STATION1"), hvdcLine, false) ); } - }