Skip to content

Commit

Permalink
get number of voltage levels in nad diagram (#486)
Browse files Browse the repository at this point in the history
* Get nb voltage levels for a given voltageLevelFilter
* Add unit test

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
  • Loading branch information
FranckLecuyer authored Jan 31, 2023
1 parent e61ed8e commit 897ac08
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public VoltageLevelFilter(Set<VoltageLevel> voltageLevels) {
this.voltageLevels = voltageLevels;
}

public int getNbVoltageLevels() {
return voltageLevels.size();
}

private Set<VoltageLevel> getVoltageLevels() {
return voltageLevels;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<VoltageLevel> filter = vl -> vl.getNominalV() >= 100;

Expand Down

0 comments on commit 897ac08

Please sign in to comment.