OnlineDbMVStoreUtils { public static String branchesDataToCsv(String networkId, Integer stateId, String contingencyId, LinkedHashMap<String, Double> branchesData) { return String.join(";", networkId, Integer.toString(stateId), contingencyId, String.join(";", branchesData.values().stream().map(value -> Double.toString(value)).collect(Collectors.toList()))); } private  OnlineDbMVStoreUtils(); static String contingenciesIdsToJson(Collection<String> contingenciesIds); static Collection<String> jsonToContingenciesIds(String json); static String actionsIdsToJson(List<String> actionsIds); static List<String> jsonToActionsIds(String json); static String indexesDataToJson(Map<String, Boolean> indexesData); static Map<String, Boolean> jsonToIndexesData(String json); static String stateIdsToJson(Collection<Integer> statesIds); static Collection<Integer> jsonToStatesIds(String json); static String indexesTypesToJson(Set<SecurityIndexType> securityIndexTypes); static Set<SecurityIndexType> jsonToIndexesTypes(String json); static String violationToJson(Violation violation); static Violation jsonToViolation(String json); static String limitViolationToJson(LimitViolation violation); static LimitViolation jsonToLimitViolation(String json, Network network); static String actionParametersToJson(ActionParameters actionParameters); static ActionParameters jsonToActionParameters(String json); static String countriesToJson(Set<Country> countries); static Set<Country> jsonToCountries(String json); static OnlineProcess jsonToProcess(String json); static String branchesDataToCsvHeaders(LinkedHashMap<String, Double> branchesData); static String branchesDataToCsv(String networkId, Integer stateId, String contingencyId, LinkedHashMap<String, Double> branchesData); static String postContingencyStateKey(Integer stateId, String contingencyId);  }
@Test public void branchesDataToCsv() { String networkId = "network1"; Integer stateId = 1; String contingencyId = "contingency1"; String csvHeaders = String.join(";", "networkId", "stateId", "contingencyId", "NHV1_NHV2_1__TO__VLHV1_I", "NHV1_NHV2_1__TO__VLHV1_P", "NHV1_NHV2_1__TO__VLHV1_IMAX", "NHV1_NHV2_1__TO__VLHV2_I", "NHV1_NHV2_1__TO__VLHV2_P", "NHV1_NHV2_1__TO__VLHV2_IMAX", "NHV1_NHV2_2__TO__VLHV1_I", "NHV1_NHV2_2__TO__VLHV1_P", "NHV1_NHV2_2__TO__VLHV1_IMAX", "NHV1_NHV2_2__TO__VLHV2_I", "NHV1_NHV2_2__TO__VLHV2_P", "NHV1_NHV2_2__TO__VLHV2_IMAX", "NGEN_NHV1__TO__VLGEN_I", "NGEN_NHV1__TO__VLGEN_P", "NGEN_NHV1__TO__VLGEN_IMAX", "NGEN_NHV1__TO__VLHV1_I", "NGEN_NHV1__TO__VLHV1_P", "NGEN_NHV1__TO__VLHV1_IMAX", "NHV2_NLOAD__TO__VLHV2_I", "NHV2_NLOAD__TO__VLHV2_P", "NHV2_NLOAD__TO__VLHV2_IMAX", "NHV2_NLOAD__TO__VLLOAD_I", "NHV2_NLOAD__TO__VLLOAD_P", "NHV2_NLOAD__TO__VLLOAD_IMAX"); String csvValues = String.join(";", networkId, Integer.toString(stateId), contingencyId, Double.toString(1192.5631358010583), Double.toString(560.0), Double.toString(500.0), Double.toString(1192.5631358010583), Double.toString(560.0), Double.toString(1100.0), Double.toString(1192.5631358010583), Double.toString(560.0), Double.toString(1100.0), Double.toString(1192.5631358010583), Double.toString(560.0), Double.toString(500.0), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN), Double.toString(Double.NaN)); Network network1 = EurostagTutorialExample1Factory.createWithCurrentLimits(); LinkedHashMap<String, Double> branchesData1 = OnlineUtils.getBranchesData(network1); String csvHeaders1 = OnlineDbMVStoreUtils.branchesDataToCsvHeaders(branchesData1); assertEquals(csvHeaders, csvHeaders1); String csvValues1 = OnlineDbMVStoreUtils.branchesDataToCsv(networkId, stateId, contingencyId, branchesData1); assertEquals(csvValues, csvValues1); Network network2 = EurostagTutorialExample1Factory.createWithCurrentLimits(); LinkedHashMap<String, Double> branchesData2 = OnlineUtils.getBranchesData(network2); String csvHeaders2 = OnlineDbMVStoreUtils.branchesDataToCsvHeaders(branchesData2); assertEquals(csvHeaders1, csvHeaders2); String csvValues2 = OnlineDbMVStoreUtils.branchesDataToCsv(networkId, stateId, contingencyId, branchesData2); assertEquals(csvValues1, csvValues2); }