CandidateComputations { public static Optional<CandidateComputation> getComputation(String name) { return getComputations().stream().filter(c -> c.getName().equals(name)).findFirst(); } private  CandidateComputations(); static List<CandidateComputation> getComputations(); static List<String> getComputationsNames(); static Optional<CandidateComputation> getComputation(String name);  }
@Test public void loadFlowExists() { CandidateComputation computation = CandidateComputations.getComputation("loadflow") .orElseGet(failure()); assertNotNull(computation); assertEquals("loadflow", computation.getName()); }
@Test public void runDummyComputation() { Network network = EurostagTutorialExample1Factory.create(); CandidateComputation computation = CandidateComputations.getComputation("dummy").orElseGet(failure()); assertNotNull(computation); assertEquals("dummy", computation.getName()); computation.run(network, null); assertEquals(126f, network.getGenerator("GEN").getTerminal().getP(), 0f); }
@Test public void runLoadFlowMock() { platformConfig.createModuleConfig("loadflow-validation").setStringProperty("load-flow-name", "LoadFlowMock"); Network network = EurostagTutorialExample1Factory.create(); CandidateComputation computation = CandidateComputations.getComputation("loadflow").orElseGet(failure()); assertNotNull(computation); assertEquals("loadflow", computation.getName()); computation.run(network, Mockito.mock(ComputationManager.class)); assertEquals(92f, network.getGenerator("GEN").getTerminal().getP(), 0f); }