Skip to content

Commit 68ffe1f

Browse files
committed
fix sonar issues
Signed-off-by: Clement Philipot <clement.philipot@rte-france.com>
1 parent 87b9385 commit 68ffe1f

1 file changed

Lines changed: 59 additions & 2 deletions

File tree

iidm/iidm-serde/src/test/java/com/powsybl/iidm/serde/TopologyLevelTest.java

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void voltageLevelWithBusbarSectionAndKeepOriginalTopologyMustExportNodeBreaker()
7676
.setNode(0)
7777
.add();
7878

79-
// Export options : BUS_BRANCH topology level + keep original topology
79+
// Export options : BUS_BRANCH topology level + KEEP_ORIGINAL_TOPOLOGY export option
8080
ExportOptions options = new ExportOptions();
8181
options.setTopologyLevel(TopologyLevel.BUS_BRANCH);
8282
options.setBusBranchVoltageLevelIncompatibilityBehavior(ExportOptions.BusBranchVoltageLevelIncompatibilityBehavior.KEEP_ORIGINAL_TOPOLOGY);
@@ -91,9 +91,65 @@ void voltageLevelWithBusbarSectionAndKeepOriginalTopologyMustExportNodeBreaker()
9191
"when keepOriginalTopology is enabled");
9292
}
9393

94+
@Test
95+
void voltageLevelWithBusAndKeepOriginalTopologyMustExportBusBranch() {
96+
Network network = Network.create("n1", "test");
97+
Substation substation = network.newSubstation()
98+
.setId("S1")
99+
.add();
100+
101+
VoltageLevel vl = substation.newVoltageLevel()
102+
.setId("VL1")
103+
.setNominalV(225.0)
104+
.setTopologyKind(TopologyKind.BUS_BREAKER)
105+
.add();
106+
107+
vl.getBusBreakerView().newBus()
108+
.setId("busId")
109+
.add();
110+
111+
// Export options : BUS_BRANCH topology level + KEEP_ORIGINAL_TOPOLOGY export option
112+
ExportOptions options = new ExportOptions();
113+
options.setTopologyLevel(TopologyLevel.BUS_BRANCH);
114+
options.setBusBranchVoltageLevelIncompatibilityBehavior(ExportOptions.BusBranchVoltageLevelIncompatibilityBehavior.KEEP_ORIGINAL_TOPOLOGY);
115+
116+
NetworkSerializerContext context = new NetworkSerializerContext(new SimpleAnonymizer(), mock(TreeDataWriter.class), options, null, CURRENT_IIDM_VERSION, true);
117+
118+
TopologyLevel exportTopology =
119+
TopologyLevelUtil.determineTopologyLevel(vl, context);
120+
121+
assertEquals(TopologyLevel.BUS_BRANCH, exportTopology);
122+
}
123+
124+
@Test
125+
void voltageLevelWithoutBusSectionAndKeepOriginalTopology() {
126+
Network network = Network.create("n1", "test");
127+
Substation substation = network.newSubstation()
128+
.setId("S1")
129+
.add();
130+
131+
VoltageLevel vl = substation.newVoltageLevel()
132+
.setId("VL1")
133+
.setNominalV(225.0)
134+
.setTopologyKind(TopologyKind.NODE_BREAKER)
135+
.add();
136+
137+
// Export options : BUS_BRANCH topology level + KEEP_ORIGINAL_TOPOLOGY export option
138+
ExportOptions options = new ExportOptions();
139+
options.setTopologyLevel(TopologyLevel.BUS_BRANCH);
140+
options.setBusBranchVoltageLevelIncompatibilityBehavior(ExportOptions.BusBranchVoltageLevelIncompatibilityBehavior.KEEP_ORIGINAL_TOPOLOGY);
141+
142+
NetworkSerializerContext context = new NetworkSerializerContext(new SimpleAnonymizer(), mock(TreeDataWriter.class), options, null, CURRENT_IIDM_VERSION, true);
143+
144+
TopologyLevel exportTopology =
145+
TopologyLevelUtil.determineTopologyLevel(vl, context);
146+
147+
assertEquals(TopologyLevel.BUS_BRANCH, exportTopology);
148+
}
149+
94150
@Test
95151
void voltageLevelWithBusbarSectionWithoutKeepOriginalTopologyMustThrowException() {
96-
Network network = Network.create("n2", "test");
152+
Network network = Network.create("n1", "test");
97153

98154
Substation substation = network.newSubstation()
99155
.setId("S1")
@@ -111,6 +167,7 @@ void voltageLevelWithBusbarSectionWithoutKeepOriginalTopologyMustThrowException(
111167
.setNode(0)
112168
.add();
113169

170+
// Export options : BUS_BRANCH topology level + THROW_EXCEPTION export option
114171
ExportOptions options = new ExportOptions();
115172
options.setTopologyLevel(TopologyLevel.BUS_BRANCH);
116173
options.setBusBranchVoltageLevelIncompatibilityBehavior(ExportOptions.BusBranchVoltageLevelIncompatibilityBehavior.THROW_EXCEPTION);

0 commit comments

Comments
 (0)