Skip to content
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

Throw a comprehensive exception when a terminal ref of a busbar section on is written in bus-breaker or bus-branch (#295) #323

Merged
merged 2 commits into from
May 31, 2021

Conversation

sebalaig
Copy link
Contributor

@sebalaig sebalaig commented May 10, 2021

Signed-off-by: Sébastien LAIGRE [email protected]

Please check if the PR fulfills these requirements (please use '[x]' to check the checkboxes, or submit the PR and then click the checkboxes)

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem ? If so, link to this issue using '#XXX' and skip the rest
#295

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change or deprecate an API? If yes, check the following:

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

(if any of the questions/checkboxes don't apply, please delete them entirely)

// make sure no error is thrown while exporting to NODE_BREAKER topology
std::stringstream ss;
Network::writeXml("network.xiidm", ss, network, converter::ExportOptions(properties));
Network::readXml("network.xiidm", ss);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should properly assert that Network::readXml and Network::writeXml don't throw any exception using BOOST_CHECK_NO_THROW. It seems to be possible to write something like that:

BOOST_CHECK_NO_THROW({
    std::stringstream ss;
    Network::writeXml("network.xiidm", ss, network, converter::ExportOptions(properties));
    Network::readXml("network.xiidm", ss);
});

@@ -57,6 +59,11 @@ void TerminalRefXml::writeTerminalRef(const Terminal& terminal, NetworkXmlWriter
if (!context.getFilter().test(c)) {
throw PowsyblException(stdcxx::format("Oups, terminal ref point to a filtered equipment %1%", c.get().getId()));
}
if (terminal.getVoltageLevel().getTopologyKind() == TopologyKind::NODE_BREAKER
&& context.getOptions().getTopologyLevel() != TopologyLevel::NODE_BREAKER
&& stdcxx::isInstanceOf<BusbarSection>(terminal.getConnectable())) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put the && operators at the end of the line instead of the beginning of the lines

sebalaig and others added 2 commits May 31, 2021 22:55
…on is written in bus-breaker or bus-branch (#295)

Signed-off-by: Sébastien LAIGRE <[email protected]>
Signed-off-by: Mathieu BAGUE <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented May 31, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

63.9% 63.9% Coverage
0.0% 0.0% Duplication

@mathbagu mathbagu merged commit ab77139 into integration/v1.5.0 May 31, 2021
@mathbagu mathbagu deleted the issue295-comprehensiveErrorMessage branch May 31, 2021 21:38
mathbagu pushed a commit that referenced this pull request Nov 30, 2021
…on on is written in bus-breaker or bus-branch (#295) (#323)

Signed-off-by: Sébastien LAIGRE <[email protected]>
Signed-off-by: Mathieu BAGUE <[email protected]>
mathbagu pushed a commit that referenced this pull request Jan 10, 2022
…on on is written in bus-breaker or bus-branch (#295) (#323)

Signed-off-by: Sébastien LAIGRE <[email protected]>
Signed-off-by: Mathieu BAGUE <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants