powsybl / powsybl-diagram

SVG diagrams generation: single-line substation diagrams and network graph diagrams
Mozilla Public License 2.0
72 stars 13 forks source link

Improve test on voltage level detail display #621

Closed So-Fras closed 2 months ago

So-Fras commented 2 months ago

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? Bug fix

What is the current behavior? In the TextNodeTest class, the custom getLabelProvider function, defined in the TextNodeTest class returns the labelProvider variable if this variable is not null or a customized LabelProvider if the labelProvider variable is null :

    protected LabelProvider getLabelProvider(Network network) {
        if (labelProvider != null) {
            return labelProvider;
        }
        return new DefaultLabelProvider(network, getSvgParameters()) {
            @Override
            public List<String> getVoltageLevelDetails(VoltageLevelNode vlNode) {
                VoltageLevel vl = network.getVoltageLevel(vlNode.getEquipmentId());
                return List.of(
                        vl.getLoadCount() + " loads",
                        vl.getGeneratorCount() + " generators",
                        vl.getBatteryCount() + " batteries",
                        vl.getDanglingLineCount() + " dangling lines");
            }
        };
    }

In the TextNodeTest > testSubstationDescriptiontest, the labelProvider variable was instantiated with a new DefaultLabelProvider(...) and thus not null.

Because of that, the customized LabelProvider, with its customized getVoltageLevelDetails method is not used. It seems like it should be, in order to test the setVoltageLevelDetails(true) configuration.

What is the new behavior (if this is a feature change)? The instantiation of the labelProvider variable is removed so that the customized LabelProvider is used. The test resource file is modified (voltage level details now appear in the text box).

Does this PR introduce a breaking change or deprecate an API?

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud