WCAUtils { public static WCADomainsResult readDomainsResult(String domainsPrefix, Path workingDir, String uncertaintiesFile) throws IOException { Objects.requireNonNull(domainsPrefix); Objects.requireNonNull(workingDir); Objects.requireNonNull(uncertaintiesFile); boolean foundBasicViolations = false; boolean rulesViolated = false; int preventiveActionIndex = 0; Matcher matcher = parseOutFile(domainsPrefix, DOMAINS_RESULTS_PATTERN, workingDir); if (matcher != null) { int basicViolation = Integer.parseInt(matcher.group(1)); int ruleViolation = Integer.parseInt(matcher.group(2)); preventiveActionIndex = Integer.parseInt(matcher.group(3)); if (basicViolation == 1) { foundBasicViolations = true; } if (ruleViolation == 1) { rulesViolated = true; } } return new WCADomainsResult(foundBasicViolations, rulesViolated, preventiveActionIndex, parseUncertaintiesFile(uncertaintiesFile, workingDir)); } private  WCAUtils(); static void exportState(Network network, Path folder, int faultNum, int actionNum); static WCADomainsResult readDomainsResult(String domainsPrefix, Path workingDir, String uncertaintiesFile); static WCAClustersResult readClustersResult(String clustersPrefix, Path workingDir, String flowsFile, String uncertaintiesFile); static void writeContingencies(Collection<Contingency> contingencies, DataSource dataSource, StringToIntMapper<AmplSubset> mapper); static void writeActions(Collection<String> actionIds, DataSource dataSource, StringToIntMapper<AmplSubset> mapper,
                                     String title, AmplSubset amplSubset); static void applyInjections(Network network, String stateId, Map<String, Float> injections); static boolean containsViolation(List<LimitViolation> violations, LimitViolation violation);  }
@Test public void testReadDomainsResult() throws URISyntaxException, IOException { Path workingDir = Paths.get(getClass().getResource("/domains").toURI()); WCADomainsResult domainsResult = WCAUtils.readDomainsResult("wca_domains_1", workingDir, "wca_uncertainties.txt"); assertFalse(domainsResult.foundBasicViolations()); assertFalse(domainsResult.areRulesViolated()); assertEquals(0, domainsResult.getPreventiveActionIndex()); testInjection(domainsResult.getInjections(), "LOAD_1", -1.1f); testInjection(domainsResult.getInjections(), "LOAD_2", 1.5f); testInjection(domainsResult.getInjections(), "GEN_1", 1.2f); domainsResult = WCAUtils.readDomainsResult("wca_domains_2", workingDir, "wca_uncertainties.txt"); assertTrue(domainsResult.foundBasicViolations()); assertFalse(domainsResult.areRulesViolated()); assertEquals(0, domainsResult.getPreventiveActionIndex()); testInjection(domainsResult.getInjections(), "LOAD_1", -1.1f); testInjection(domainsResult.getInjections(), "LOAD_2", 1.5f); testInjection(domainsResult.getInjections(), "GEN_1", 1.2f); }