ParallelLoadFlowActionSimulator { public void run(String script, List<String> contingencyIds) { LOGGER.debug("Starting parallel action simulator."); ExecutionEnvironment itoolsEnvironment = new ExecutionEnvironment(Collections.emptyMap(), "subTask_", config.isDebug()); int actualTaskCount = Math.min(taskCount, contingencyIds.size()); CompletableFuture<SecurityAnalysisResult> future = computationManager.execute(itoolsEnvironment, new SubTaskHandler(actualTaskCount, script, contingencyIds)); try { SecurityAnalysisResult result = future.get(); resultHandlers.forEach(h -> h.accept(result)); } catch (Exception e) { throw new PowsyblException(e); } } ParallelLoadFlowActionSimulator(Network network, ComputationManager cm, int taskCount);  ParallelLoadFlowActionSimulator(Network network, ComputationManager cm, int taskCount, LoadFlowActionSimulatorConfig config,
                                           boolean applyIfSolved, Consumer<SecurityAnalysisResult>... resultHandlers);  ParallelLoadFlowActionSimulator(Network network, ComputationManager cm, int taskCount, LoadFlowActionSimulatorConfig config,
                                           boolean applyIfSolved, List<Consumer<SecurityAnalysisResult>> resultHandlers); void run(String script, List<String> contingencyIds);  }
@Test public void test() { when(contingencies.size()).thenReturn(11); String script = ""; try { parallelLoadFlowActionSimulator.run(script, contingencies); } catch (Exception e) { } verify(computationManager, times(1)).execute(any(), any()); }
@Test public void testContingencySizeSmallerThanTasks() { when(contingencies.size()).thenReturn(3); String script = ""; try { parallelLoadFlowActionSimulator.run(script, contingencies); } catch (Exception e) { } verify(computationManager, times(1)).execute(any(), any()); }