WCAUtils { public static boolean containsViolation(List<LimitViolation> violations, LimitViolation violation) { Objects.requireNonNull(violations); Objects.requireNonNull(violation); Optional<LimitViolation> foundLimitViolation = violations .stream() .filter(limitViolation -> limitViolation.getSubjectId().equals(violation.getSubjectId()) && limitViolation.getLimitType().equals(violation.getLimitType())) .findAny(); return foundLimitViolation.isPresent(); } 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 testContainsViolation() { LimitViolation line1Violation = new LimitViolation("line1", LimitViolationType.CURRENT, "10'",10*60, 1f, 1000f, 1100f, Branch.Side.ONE); LimitViolation line2Violation = new LimitViolation("line2", LimitViolationType.CURRENT, "20'", 20*60, 1f, 900f, 950f, Branch.Side.ONE); LimitViolation line3Violation = new LimitViolation("line3", LimitViolationType.CURRENT, "30'", 30*60, 1000f, 1f, 1300f, Branch.Side.ONE); assertFalse(WCAUtils.containsViolation(Arrays.asList(line1Violation, line3Violation), line2Violation)); assertTrue(WCAUtils.containsViolation(Arrays.asList(line1Violation, line2Violation, line3Violation), line2Violation)); }