TaskExecution implements Component, SequentialExecution, ResumableComponent { @Override public void execute(Component.Context context) throws LpException { this.context = context; initialization(); configuration = getExecutionConfiguration(); prepareCheckpointDir(); TaskSource<T> taskSource = createTaskSource(); taskSource.setSkipOnError(configuration.isSkipOnError()); List<TaskExecutor<T>> executors = createExecutors(taskSource); beforeExecution(); ExecutorService executorService = createExecutorService(); start(executorService, executors); waitForShutdown(executorService); afterExecution(); checkForFailures(taskSource); }  @Override void execute(Component.Context context); @Override void resumeExecution(File previousWorkingDirectory); @Component.Inject
    public WorkingDirectory workingDirectory; @Component.Inject
    public ExceptionFactory exceptionFactory; }
@Test public void executeOneConsumer() throws LpException { MockedTaskExecution component = new MockedTaskExecution(); Mockito.when(component.config.getThreadsNumber()).thenReturn(1); Mockito.when(component.config.isSkipOnError()).thenReturn(false); component.tasks.add(new MockedTask()); component.tasks.add(new MockedTask()); component.workingDirectory = new WorkingDirectory( new File(workingDirectory, "executeOneConsumer")); Component.Context context = Mockito.mock(Component.Context.class); component.execute(context); Assert.assertEquals(1, component.consumers.size()); TaskConsumer<Task> consumer = component.consumers.get(0); Mockito.verify(consumer, Mockito.times(2)).accept(Mockito.any()); Mockito.verify(component.report, Mockito.times(2)).onTaskFinished( Mockito.any(), Mockito.any(), Mockito.any()); }
@Test public void executeTwoConsumers() throws LpException { MockedTaskExecution component = new MockedTaskExecution(); Mockito.when(component.config.getThreadsNumber()).thenReturn(2); Mockito.when(component.config.isSkipOnError()).thenReturn(false); component.tasks.add(new MockedTask()); component.tasks.add(new MockedTask()); component.workingDirectory = new WorkingDirectory( new File(workingDirectory, "executeTwoConsumers")); Component.Context context = Mockito.mock(Component.Context.class); component.execute(context); Assert.assertEquals(2, component.consumers.size()); Mockito.verify(component.report, Mockito.times(2)).onTaskFinished( Mockito.any(), Mockito.any(), Mockito.any()); }