Contingency extends AbstractExtendable<Contingency> { public static List<Contingency> checkValidity(List<Contingency> contingencies, Network network) { Objects.requireNonNull(contingencies); Objects.requireNonNull(network); return contingencies.stream() .filter(c -> isValid(c, network)) .collect(Collectors.toList()); } Contingency(String id, ContingencyElement... elements);  Contingency(String id, List<ContingencyElement> elements); static List<Contingency> checkValidity(List<Contingency> contingencies, Network network); String getId(); void setId(String id); void addElement(ContingencyElement element); void removeElement(ContingencyElement element); Collection<ContingencyElement> getElements(); ModificationTask toTask(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void validationTest() { Network network = EurostagTutorialExample1Factory.create(); Contingency generatorContingency = new Contingency("GEN contingency", new GeneratorContingency("GEN")); Contingency generatorInvalidContingency = new Contingency("GEN invalid contingency", new GeneratorContingency("GE")); Contingency lineContingency = new Contingency("NHV1_NHV2_1 contingency", new BranchContingency("NHV1_NHV2_1", "VLHV1")); Contingency lineInvalidContingency = new Contingency("NHV1_NHV2_1 invalid contingency", new BranchContingency("NHV1_NHV2_1", "VLHV")); List<Contingency> validContingencies = Contingency.checkValidity(Arrays.asList(generatorContingency, generatorInvalidContingency, lineContingency, lineInvalidContingency), network); assertEquals(Arrays.asList("GEN contingency", "NHV1_NHV2_1 contingency"), validContingencies.stream().map(Contingency::getId).collect(Collectors.toList())); }
@Test public void validationTestForShunt() { Network network = HvdcTestNetwork.createLcc(); Contingency shuntCompensatorContingency = new Contingency("Shunt contingency", new ShuntCompensatorContingency("C1_Filter1")); Contingency shuntCompensatorInvalidContingency = new Contingency("Shunt invalid contingency", new ShuntCompensatorContingency("C_Filter")); List<Contingency> validContingencies = Contingency.checkValidity(Arrays.asList(shuntCompensatorContingency, shuntCompensatorInvalidContingency), network); assertEquals(Arrays.asList("Shunt contingency"), validContingencies.stream().map(Contingency::getId).collect(Collectors.toList())); }
@Test public void validationTestForSVC() { Network network = SvcTestCaseFactory.create(); Contingency staticVarCompensatorContingency = new Contingency("SVC contingency", new StaticVarCompensatorContingency("SVC2")); Contingency staticVarCompensatorInvalidContingency = new Contingency("SVC invalid contingency", new StaticVarCompensatorContingency("SVC")); List<Contingency> validContingencies = Contingency.checkValidity(Arrays.asList(staticVarCompensatorContingency, staticVarCompensatorInvalidContingency), network); assertEquals(Arrays.asList("SVC contingency"), validContingencies.stream().map(Contingency::getId).collect(Collectors.toList())); }
@Test public void validationTestForDL() { Network network = DanglingLineNetworkFactory.create(); Contingency danglingLineContingency = new Contingency("DL contingency", new DanglingLineContingency("DL")); Contingency danglingLineInvalidContingency = new Contingency("DL invalid contingency", new DanglingLineContingency("DL_THAT_DO_NOT_EXIST")); List<Contingency> validContingencies = Contingency.checkValidity(Arrays.asList(danglingLineContingency, danglingLineInvalidContingency), network); assertEquals(Arrays.asList("DL contingency"), validContingencies.stream().map(Contingency::getId).collect(Collectors.toList())); }