diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java b/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java index ff6bc2067..5d405742e 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java @@ -27,6 +27,10 @@ public VoltageLevelFilter(Set voltageLevels) { this.voltageLevels = voltageLevels; } + public int getNbVoltageLevels() { + return voltageLevels.size(); + } + private Set getVoltageLevels() { return voltageLevels; } diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/layout/LayoutWithInitialPositionsTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/layout/LayoutWithInitialPositionsTest.java index 0aa61e6ec..d76d89530 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/layout/LayoutWithInitialPositionsTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/layout/LayoutWithInitialPositionsTest.java @@ -59,6 +59,16 @@ public void testDiamond() { checkLayoutWithInitialPositions(LayoutNetworkFactory.createDiamond()); } + @Test + public void testNbVoltageLevels() { + Network network = LayoutNetworkFactory.createDiamond(); + + assertEquals(1, VoltageLevelFilter.createVoltageLevelDepthFilter(network, "A 400", 0).getNbVoltageLevels()); + assertEquals(4, VoltageLevelFilter.createVoltageLevelDepthFilter(network, "A 400", 3).getNbVoltageLevels()); + assertEquals(7, VoltageLevelFilter.createVoltageLevelDepthFilter(network, "A 400", 5).getNbVoltageLevels()); + assertEquals(1, VoltageLevelFilter.createVoltageLevelDepthFilter(network, "A 400", 0).getNbVoltageLevels()); + } + private void checkLayoutWithInitialPositions(Network network) { Predicate filter = vl -> vl.getNominalV() >= 100;