From 2964b1c9ff71bf132d238937439bd14624423fd8 Mon Sep 17 00:00:00 2001
From: Romain Courtier <romain.courtier@rte-france.com>
Date: Tue, 15 Oct 2024 17:42:45 +0200
Subject: [PATCH] Replace testing of switch without name with a simple network
 instead of a modified conformity file

Signed-off-by: Romain Courtier <romain.courtier@rte-france.com>
---
 .../CgmesConformity1ModifiedCatalog.java      | 14 --------------
 .../conversion/test/SwitchConversionTest.java |  8 +++++---
 ...gmesConformity1ModifiedConversionTest.java |  6 ------
 .../resources/issues/switches/switch_kind.xml | 19 +++++++++++++++++++
 4 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/cgmes/cgmes-conformity/src/main/java/com/powsybl/cgmes/conformity/CgmesConformity1ModifiedCatalog.java b/cgmes/cgmes-conformity/src/main/java/com/powsybl/cgmes/conformity/CgmesConformity1ModifiedCatalog.java
index 4093f1dd9be..7458e27fe15 100644
--- a/cgmes/cgmes-conformity/src/main/java/com/powsybl/cgmes/conformity/CgmesConformity1ModifiedCatalog.java
+++ b/cgmes/cgmes-conformity/src/main/java/com/powsybl/cgmes/conformity/CgmesConformity1ModifiedCatalog.java
@@ -1356,20 +1356,6 @@ public static GridModelReference microGridBaseCaseNLShuntCompensatorGP() {
                 microGridBaseCaseBoundaries());
     }
 
-    public static GridModelReference microGridBaseCaseNLSwitchWithoutName() {
-        String base = ENTSOE_CONFORMITY_1_MODIFIED
-                + "/MicroGrid/BaseCase/BC_NL_v2_switch_without_name/";
-        String baseOriginal = ENTSOE_CONFORMITY_1
-                + MICROGRID_CONFIGURATION;
-        return new GridModelReferenceResources(
-                "MicroGrid-BaseCase-NL-switch-no-name",
-                null,
-                new ResourceSet(base, MICRO_GRID_NL_EQ),
-                new ResourceSet(baseOriginal, MICRO_GRID_NL_SSH,
-                        MICRO_GRID_NL_TP),
-                microGridBaseCaseBoundaries());
-    }
-
     public static GridModelReference microGridBaseCaseNLSwitchTypePreserved() {
         String base = ENTSOE_CONFORMITY_1_MODIFIED
                 + "/MicroGrid/BaseCase/BC_NL_v2_switch_type_preserved/";
diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/SwitchConversionTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/SwitchConversionTest.java
index 1a38f439015..0ee60f1ae1d 100644
--- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/SwitchConversionTest.java
+++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/SwitchConversionTest.java
@@ -41,16 +41,18 @@ void lineWithZeroImpedanceTest() {
     @Test
     void switchKindTest() {
         // CGMES network:
-        //   One LoadBreakSwitch and one generic Switch.
+        //   A LoadBreakSwitch, a generic Switch, and a Disconnector without name.
         // IIDM network:
         //   The switch kind is preserved. A generic CGMES switch is considered of kind breaker.
         Network network = readCgmesResources(DIR, "switch_kind.xml");
         assertNotNull(network);
 
         // Check that the switch kind has been preserved.
-        assertNotNull(network.getSwitch("LBS"));
         assertEquals(SwitchKind.LOAD_BREAK_SWITCH, network.getSwitch("LBS").getKind());
-        assertNotNull(network.getSwitch("SW"));
         assertEquals(SwitchKind.BREAKER, network.getSwitch("SW").getKind());
+        assertEquals(SwitchKind.DISCONNECTOR, network.getSwitch("DIS").getKind());
+
+        // Disconnector has no name, so getNameOrId() returns its id
+        assertEquals("DIS", network.getSwitch("DIS").getNameOrId());
     }
 }
diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/modified/CgmesConformity1ModifiedConversionTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/modified/CgmesConformity1ModifiedConversionTest.java
index 774ff151b28..42801c1a760 100644
--- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/modified/CgmesConformity1ModifiedConversionTest.java
+++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/conformity/modified/CgmesConformity1ModifiedConversionTest.java
@@ -914,12 +914,6 @@ void microGridBaseCaseNLShuntCompensatorGP() {
         assertEquals(0.123, network.getShuntCompensator("fbfed7e3-3dec-4829-a286-029e73535685").getTerminal().getP(), 0.0);
     }
 
-    @Test
-    void microGridBaseCaseNLSwitchWithoutName() {
-        Network network = Importers.importData("CGMES", CgmesConformity1ModifiedCatalog.microGridBaseCaseNLSwitchWithoutName().dataSource(), importParams);
-        assertNotNull(network.getSwitch("5f5d40ae-d52d-4631-9285-b3ceefff784c"));
-    }
-
     @Test
     void microGridBaseCaseBESingleFile() {
         Network network = Importers.importData("CGMES", CgmesConformity1ModifiedCatalog.microGridBaseCaseBESingleFile().dataSource(), importParams);
diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/switches/switch_kind.xml b/cgmes/cgmes-conversion/src/test/resources/issues/switches/switch_kind.xml
index 22d7880148d..d700e61de7e 100644
--- a/cgmes/cgmes-conversion/src/test/resources/issues/switches/switch_kind.xml
+++ b/cgmes/cgmes-conversion/src/test/resources/issues/switches/switch_kind.xml
@@ -70,6 +70,25 @@
     <cim:Terminal.ConductingEquipment rdf:resource="#_SW"/>
     <cim:Terminal.ConnectivityNode rdf:resource="#_CN_2"/>
 </cim:Terminal>
+<cim:Disconnector rdf:ID="_DIS">
+    <!-- cim:IdentifiedObject.name>Disconnector</cim:IdentifiedObject.name -->
+    <cim:Equipment.EquipmentContainer rdf:resource="#_VL"/>
+    <cim:ConductingEquipment.BaseVoltage rdf:resource="#_BV"/>
+    <cim:Switch.normalOpen>false</cim:Switch.normalOpen>
+    <cim:Switch.retained>false</cim:Switch.retained>
+</cim:Disconnector>
+<cim:Terminal rdf:ID="_T_DIS_1">
+    <cim:IdentifiedObject.name>Terminal DIS 1</cim:IdentifiedObject.name>
+    <cim:ACDCTerminal.sequenceNumber>1</cim:ACDCTerminal.sequenceNumber>
+    <cim:Terminal.ConductingEquipment rdf:resource="#_DIS"/>
+    <cim:Terminal.ConnectivityNode rdf:resource="#_CN_1"/>
+</cim:Terminal>
+<cim:Terminal rdf:ID="_T_DIS_2">
+    <cim:IdentifiedObject.name>Terminal DIS 2</cim:IdentifiedObject.name>
+    <cim:ACDCTerminal.sequenceNumber>2</cim:ACDCTerminal.sequenceNumber>
+    <cim:Terminal.ConductingEquipment rdf:resource="#_DIS"/>
+    <cim:Terminal.ConnectivityNode rdf:resource="#_CN_2"/>
+</cim:Terminal>
 <cim:BaseVoltage rdf:ID="_BV">
     <cim:IdentifiedObject.name>110 kV</cim:IdentifiedObject.name>
     <cim:BaseVoltage.nominalVoltage>110</cim:BaseVoltage.nominalVoltage>