Skip to content

Commit

Permalink
Creating an modification with wrong bus bar section now throws an exc…
Browse files Browse the repository at this point in the history
…eption (#2516)

Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
  • Loading branch information
klesaulnier authored and miovd committed Mar 30, 2023
1 parent 56dc5e0 commit 95367ad
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void apply(Network network, boolean throwException,

TopologyKind topologyKind = tappedVoltageLevel.getTopologyKind();
if (topologyKind == TopologyKind.BUS_BREAKER) {
Bus bus = network.getBusBreakerView().getBus(bbsOrBusId);
Bus bus = tappedVoltageLevel.getBusBreakerView().getBus(bbsOrBusId);
if (bus == null) {
notFoundBusInVoltageLevelReport(reporter, bbsOrBusId, tappedVoltageLevel.getId());
if (throwException) {
Expand All @@ -199,7 +199,7 @@ public void apply(Network network, boolean throwException,
newLine2Adder.setBus1(bus2.getId());
newLine2Adder.setConnectableBus1(bus2.getId());
} else if (topologyKind == TopologyKind.NODE_BREAKER) {
BusbarSection bbs = network.getBusbarSection(bbsOrBusId);
BusbarSection bbs = tappedVoltageLevel.getNodeBreakerView().getBusbarSection(bbsOrBusId);
if (bbs == null) {
notFoundBusbarSectionInVoltageLevelReport(reporter, bbsOrBusId, tappedVoltageLevel.getId());
if (throwException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ void replaceTeePointByVoltageLevelOnLineNbTest() throws IOException {
.withNewLine2Id("NEW LINE2").build();
assertTrue(assertThrows(PowsyblException.class, () -> modificationWithError6.apply(network, true, Reporter.NO_OP)).getMessage().contains("Unable to find the tee point and the tapped voltage level from lines CJ_1, CJ_2 and LINE34"));

NetworkModification modificationWithError7 = new ReplaceTeePointByVoltageLevelOnLineBuilder()
.withTeePointLine1("CJ_1")
.withTeePointLine2("CJ_2")
.withTeePointLineToRemove("testLine")
.withBbsOrBusId("bbs3")
.withNewLine1Id("NEW LINE1")
.withNewLine2Id("NEW LINE2").build();
assertTrue(assertThrows(PowsyblException.class, () -> modificationWithError7.apply(network, true, Reporter.NO_OP)).getMessage().contains("Busbar section bbs3 is not found in voltage level VLTEST"));

modification = new ReplaceTeePointByVoltageLevelOnLineBuilder()
.withTeePointLine1("CJ_1")
.withTeePointLine2("CJ_2")
Expand Down Expand Up @@ -137,14 +146,26 @@ void replaceTeePointByVoltageLevelOnLineBbTest() throws IOException {
NetworkModification modification = new CreateLineOnLineBuilder().withBusbarSectionOrBusId("bus").withLine(line).withLineAdder(adder).build();
modification.apply(network);

NetworkModification modificationWithError = new ReplaceTeePointByVoltageLevelOnLineBuilder()
VoltageLevel vl = network.newVoltageLevel().setId("VL3").setNominalV(380).setTopologyKind(TopologyKind.BUS_BREAKER).add();
vl.getBusBreakerView().newBus().setId("bus3").add();

NetworkModification modificationWithError1 = new ReplaceTeePointByVoltageLevelOnLineBuilder()
.withTeePointLine1("NHV1_NHV2_1_1")
.withTeePointLine2("NHV1_NHV2_1_2")
.withTeePointLineToRemove("testLine")
.withBbsOrBusId("busNotFound")
.withNewLine1Id("NEW LINE1")
.withNewLine2Id("NEW LINE2").build();
assertTrue(assertThrows(PowsyblException.class, () -> modificationWithError.apply(network, true, Reporter.NO_OP)).getMessage().contains("Bus busNotFound is not found in voltage level " + VOLTAGE_LEVEL_ID));
assertTrue(assertThrows(PowsyblException.class, () -> modificationWithError1.apply(network, true, Reporter.NO_OP)).getMessage().contains("Bus busNotFound is not found in voltage level " + VOLTAGE_LEVEL_ID));

NetworkModification modificationWithError2 = new ReplaceTeePointByVoltageLevelOnLineBuilder()
.withTeePointLine1("NHV1_NHV2_1_1")
.withTeePointLine2("NHV1_NHV2_1_2")
.withTeePointLineToRemove("testLine")
.withBbsOrBusId("bus3")
.withNewLine1Id("NEW LINE1")
.withNewLine2Id("NEW LINE2").build();
assertTrue(assertThrows(PowsyblException.class, () -> modificationWithError2.apply(network, true, Reporter.NO_OP)).getMessage().contains("Bus bus3 is not found in voltage level " + VOLTAGE_LEVEL_ID));

modification = new ReplaceTeePointByVoltageLevelOnLineBuilder()
.withTeePointLine1("NHV1_NHV2_1_1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<iidm:switch id="bus_SW_2" kind="BREAKER" retained="true" open="false" bus1="bus" bus2="NEW LINE2_BUS_2"/>
</iidm:busBreakerTopology>
</iidm:voltageLevel>
<iidm:voltageLevel id="VL3" nominalV="380.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
<iidm:bus id="bus3"/>
</iidm:busBreakerTopology>
</iidm:voltageLevel>
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A">
<iidm:voltageLevel id="VLGEN" nominalV="24.0" topologyKind="BUS_BREAKER">
<iidm:busBreakerTopology>
Expand Down

0 comments on commit 95367ad

Please sign in to comment.