OnlineUtils { public static LinkedHashMap<String, Double> getBranchesData(Network network) { LinkedHashMap<String, Double> branchesData = new LinkedHashMap<>(); network.getBranchStream().forEach(branch -> { addBranchSideData(branchesData, branch.getId(), branch.getTerminal1(), branch.getCurrentLimits1() == null ? Double.NaN : branch.getCurrentLimits1().getPermanentLimit()); addBranchSideData(branchesData, branch.getId(), branch.getTerminal2(), branch.getCurrentLimits2() == null ? Double.NaN : branch.getCurrentLimits2().getPermanentLimit()); }); return branchesData; } private  OnlineUtils(); static Collection<Contingency> filterContingencies(List<Contingency> contingencies, List<String> contingenciesIds); static Set<String> getContingencyIds(List<Contingency> contingencies); static boolean isSafe(Collection<SecurityIndex> securityIndexes); static String getPostContingencyId(String stateId, String contingencyId); static UnitEnum getUnit(LimitViolationType type); static DateTime toCetDate(DateTime date); static LinkedHashMap<String, Double> getBranchesData(Network network);  }
@Test public void getBranchesDataTest() { Network network = EurostagTutorialExample1Factory.createWithCurrentLimits(); Map<String, Double> expectedBranchesData = ImmutableMap.<String, Double>builder() .put("NHV1_NHV2_1__TO__VLHV1_I", 1192.5631358010583) .put("NHV1_NHV2_1__TO__VLHV1_P", 560.0) .put("NHV1_NHV2_1__TO__VLHV1_IMAX", 500.0) .put("NHV1_NHV2_1__TO__VLHV2_I", 1192.5631358010583) .put("NHV1_NHV2_1__TO__VLHV2_P", 560.0) .put("NHV1_NHV2_1__TO__VLHV2_IMAX", 1100.0) .put("NHV1_NHV2_2__TO__VLHV1_I", 1192.5631358010583) .put("NHV1_NHV2_2__TO__VLHV1_P", 560.0) .put("NHV1_NHV2_2__TO__VLHV1_IMAX", 1100.0) .put("NHV1_NHV2_2__TO__VLHV2_I", 1192.5631358010583) .put("NHV1_NHV2_2__TO__VLHV2_P", 560.0) .put("NHV1_NHV2_2__TO__VLHV2_IMAX", 500.0) .put("NGEN_NHV1__TO__VLGEN_I", Double.NaN) .put("NGEN_NHV1__TO__VLGEN_P", Double.NaN) .put("NGEN_NHV1__TO__VLGEN_IMAX", Double.NaN) .put("NGEN_NHV1__TO__VLHV1_I", Double.NaN) .put("NGEN_NHV1__TO__VLHV1_P", Double.NaN) .put("NGEN_NHV1__TO__VLHV1_IMAX", Double.NaN) .put("NHV2_NLOAD__TO__VLHV2_I", Double.NaN) .put("NHV2_NLOAD__TO__VLHV2_P", Double.NaN) .put("NHV2_NLOAD__TO__VLHV2_IMAX", Double.NaN) .put("NHV2_NLOAD__TO__VLLOAD_I", Double.NaN) .put("NHV2_NLOAD__TO__VLLOAD_P", Double.NaN) .put("NHV2_NLOAD__TO__VLLOAD_IMAX", Double.NaN) .build(); LinkedHashMap<String, Double> branchesData = OnlineUtils.getBranchesData(network); assertEquals(24, branchesData.values().size(), 0); expectedBranchesData.keySet().forEach(attribute -> { assertTrue(branchesData.containsKey(attribute)); assertEquals(expectedBranchesData.get(attribute), branchesData.get(attribute), 0f); }); }