OnlineUtils { public static Collection<Contingency> filterContingencies(List<Contingency> contingencies, List<String> contingenciesIds) { Objects.requireNonNull(contingencies, "contingencies list is null"); Objects.requireNonNull(contingenciesIds, "contingenciesIds list is null"); return contingencies .stream() .filter(contingency -> contingenciesIds.contains(contingency.getId())) .collect(Collectors.toList()); } 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 filterContingenciesTest() { Collection<Contingency> contingencyList = OnlineUtils.filterContingencies(contingencies, Collections.emptyList()); assertEquals(0, contingencyList.size()); contingencyList = OnlineUtils.filterContingencies(contingencies, Arrays.asList("id1", "id2")); assertEquals(2, contingencyList.size()); assertEquals(contingency1, contingencyList.iterator().next()); contingencyList = OnlineUtils.filterContingencies(contingencies, Collections.singletonList("id1")); assertEquals(1, contingencyList.size()); assertEquals(contingency1, contingencyList.iterator().next()); contingencyList = OnlineUtils.filterContingencies(contingencies, Collections.singletonList("id2")); assertEquals(1, contingencyList.size()); assertEquals(contingency2, contingencyList.iterator().next()); contingencyList = OnlineUtils.filterContingencies(contingencies, Collections.singletonList("id3")); assertEquals(0, contingencyList.size()); }