-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating an modification with wrong bus bar section now throws an exception #2516
Conversation
…n exception Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
@archendel Could you please add a TU illustrating your point? |
// even if this busbarSection is not included in the voltageLevel | ||
// this method returns null if the busbarSectionId does not belong to the voltageLevel | ||
private BusbarSection getBusBarSectionFromVoltageLevel(VoltageLevel voltageLevel, String busBarSectionId) { | ||
return voltageLevel.getNodeBreakerView().getBusbarSectionStream().filter(bbs -> busBarSectionId.equals(bbs.getId())).findFirst().orElse(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if there are not that many busbar sections in a voltage level, instead of looping over the bus bar sections you'd rather do network.getBusbarSection(bbsOrBusId)
and then check if busbarSection.getTerminal().getVoltageLevel()
returns the expected voltage level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below for even more simplification. This method can be deleted with this suggestion.
@@ -199,7 +206,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 = getBusBarSectionFromVoltageLevel(tappedVoltageLevel, bbsOrBusId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acutally, here you can do tappedVoltageLevel.getNodeBreakerView().getBusbarSection(bbsOrBusId)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does not seem to work as expected as stated in the comment section
"tappedVoltageLevel.getNodeBreakerView().getBusbarSection(bbsOrBusId)" will return the busBarSection from the network even if it does not belong to "tappedVoltageLevel"
// even if this busbarSection is not included in the voltageLevel | ||
// this method returns null if the busbarSectionId does not belong to the voltageLevel | ||
private BusbarSection getBusBarSectionFromVoltageLevel(VoltageLevel voltageLevel, String busBarSectionId) { | ||
return voltageLevel.getNodeBreakerView().getBusbarSectionStream().filter(bbs -> busBarSectionId.equals(bbs.getId())).findFirst().orElse(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below for even more simplification. This method can be deleted with this suggestion.
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
I've added the test illustrating this point for the NODE_BREAKER block, but I did not find any test covering the BUS_BREAKER block, is it normal ? |
...rc/main/java/com/powsybl/iidm/modification/topology/ReplaceTeePointByVoltageLevelOnLine.java
Outdated
Show resolved
Hide resolved
Can you check the coverage of this test |
// this method returns null if the busbarSectionId does not belong to the voltageLevel | ||
private BusbarSection getBusBarSectionFromVoltageLevel(Network network, VoltageLevel voltageLevel, String busBarSectionId) { | ||
BusbarSection bbs = network.getBusbarSection(busBarSectionId); | ||
if (bbs == null || !voltageLevel.equals(bbs.getTerminal().getVoltageLevel())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than equal, you should use ==
/!=
for voltage level
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
I've found the test for the BUS_BREAKER block and added a test to cover the bug fix |
@archendel Since the fix on |
…_by_voltage_level_on_line
…ow using it for this fix Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
Sorry, I've closed this PR by mistake Thank you |
Kudos, SonarCloud Quality Gate passed! |
…eption (#2516) Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com>
Please check if the PR fulfills these requirements (please use
'[x]'
to check the checkboxes, or submit the PR and then click the checkboxes)What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix
What is the current behavior? (You can also link to an open issue here)
Creating a modification "replace tee point by voltage level on line" with wrong bus bar section is not sending an exception and provoke an unexpected behaviour
What is the new behavior (if this is a feature change)?
Creating a modification "replace tee point by voltage level on line" with wrong bus bar section is throwing an exception