@Test public void testSetTaskInStoppedStatus() { List<String> scheduledStages = mockStages(STAGES_COUNT, "scheduled"); List<String> runningStages = mockStages(STAGES_COUNT, "running"); List<String> finishedStages = mockStages(STAGES_COUNT, "finished"); List<String> errorStages = mockStages(STAGES_COUNT, "error"); List<String> stoppedStages = mockStages(STAGES_COUNT, "stopped"); List<String> stages = new ArrayList<>(); stages.addAll(scheduledStages); stages.addAll(runningStages); stages.addAll(finishedStages); stages.addAll(errorStages); stages.addAll(stoppedStages); PipelineExecutorTaskDef taskDef = mock(PipelineExecutorTaskDef.class); Input input = mock(Input.class); when(taskDef.getInput()).thenReturn(input); when(taskDef.getStages()).thenReturn(stages); PipelineExecutorTaskImpl task = new PipelineExecutorTaskImpl(taskDef, "executionId"); task.setPipelineStatus(PipelineExecutorTask.Status.RUNNING); setStagesInStatus(task, scheduledStages, PipelineExecutorTask.Status.SCHEDULED); setStagesInStatus(task, runningStages, PipelineExecutorTask.Status.RUNNING); setStagesInStatus(task, finishedStages, PipelineExecutorTask.Status.FINISHED); setStagesInStatus(task, errorStages, PipelineExecutorTask.Status.ERROR); setStagesInStatus(task, stoppedStages, PipelineExecutorTask.Status.STOPPED); taskManagerHelper.setTaskInStoppedStatus(task); assertStagesInStatus(task, scheduledStages, PipelineExecutorTask.Status.STOPPED); assertStagesInStatus(task, runningStages, PipelineExecutorTask.Status.STOPPED); assertStagesInStatus(task, finishedStages, PipelineExecutorTask.Status.FINISHED); assertStagesInStatus(task, errorStages, PipelineExecutorTask.Status.ERROR); assertStagesInStatus(task, stoppedStages, PipelineExecutorTask.Status.STOPPED); assertEquals(PipelineExecutorTask.Status.STOPPED, task.getPipelineStatus()); }
public void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task) { task.setPipelineStatus(PipelineExecutorTask.Status.STOPPED); task.getTaskDef().getStages() .stream() .filter(stage -> PipelineExecutorTask.Status.RUNNING.equals(task.getStageStatus(stage)) || PipelineExecutorTask.Status.SCHEDULED.equals(task.getStageStatus(stage))) .forEach(stage -> task.setStageStatus(stage, PipelineExecutorTask.Status.STOPPED)); task.clearErrors(); task.setOutput(null); }
PipelineExecutorTaskManagerImplHelper { public void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task) { task.setPipelineStatus(PipelineExecutorTask.Status.STOPPED); task.getTaskDef().getStages() .stream() .filter(stage -> PipelineExecutorTask.Status.RUNNING.equals(task.getStageStatus(stage)) || PipelineExecutorTask.Status.SCHEDULED.equals(task.getStageStatus(stage))) .forEach(stage -> task.setStageStatus(stage, PipelineExecutorTask.Status.STOPPED)); task.clearErrors(); task.setOutput(null); } }
PipelineExecutorTaskManagerImplHelper { public void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task) { task.setPipelineStatus(PipelineExecutorTask.Status.STOPPED); task.getTaskDef().getStages() .stream() .filter(stage -> PipelineExecutorTask.Status.RUNNING.equals(task.getStageStatus(stage)) || PipelineExecutorTask.Status.SCHEDULED.equals(task.getStageStatus(stage))) .forEach(stage -> task.setStageStatus(stage, PipelineExecutorTask.Status.STOPPED)); task.clearErrors(); task.setOutput(null); } PipelineExecutorTaskManagerImplHelper(final Instance<ConfigExecutor> configExecutorInstance,
                                                 final Instance<PipelineEventListener> pipelineEventListenerInstance); }
PipelineExecutorTaskManagerImplHelper { public void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task) { task.setPipelineStatus(PipelineExecutorTask.Status.STOPPED); task.getTaskDef().getStages() .stream() .filter(stage -> PipelineExecutorTask.Status.RUNNING.equals(task.getStageStatus(stage)) || PipelineExecutorTask.Status.SCHEDULED.equals(task.getStageStatus(stage))) .forEach(stage -> task.setStageStatus(stage, PipelineExecutorTask.Status.STOPPED)); task.clearErrors(); task.setOutput(null); } PipelineExecutorTaskManagerImplHelper(final Instance<ConfigExecutor> configExecutorInstance,
                                                 final Instance<PipelineEventListener> pipelineEventListenerInstance); ExecutorService createExecutorService(); PipelineExecutor createPipelineExecutor(); List<PipelineEventListener> createExternalListeners(); void notifyExternalListeners(final List<PipelineEventListener> externalListeners,
                                        final PipelineEvent event); PipelineExecutorTaskImpl createTask(final PipelineExecutorTaskDef taskDef); PipelineExecutorTaskImpl createTask(final PipelineExecutorTaskDef taskDef,
                                               final String executionId); String generateTaskId(); void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task); }
PipelineExecutorTaskManagerImplHelper { public void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task) { task.setPipelineStatus(PipelineExecutorTask.Status.STOPPED); task.getTaskDef().getStages() .stream() .filter(stage -> PipelineExecutorTask.Status.RUNNING.equals(task.getStageStatus(stage)) || PipelineExecutorTask.Status.SCHEDULED.equals(task.getStageStatus(stage))) .forEach(stage -> task.setStageStatus(stage, PipelineExecutorTask.Status.STOPPED)); task.clearErrors(); task.setOutput(null); } PipelineExecutorTaskManagerImplHelper(final Instance<ConfigExecutor> configExecutorInstance,
                                                 final Instance<PipelineEventListener> pipelineEventListenerInstance); ExecutorService createExecutorService(); PipelineExecutor createPipelineExecutor(); List<PipelineEventListener> createExternalListeners(); void notifyExternalListeners(final List<PipelineEventListener> externalListeners,
                                        final PipelineEvent event); PipelineExecutorTaskImpl createTask(final PipelineExecutorTaskDef taskDef); PipelineExecutorTaskImpl createTask(final PipelineExecutorTaskDef taskDef,
                                               final String executionId); String generateTaskId(); void setTaskInStoppedStatus(final PipelineExecutorTaskImpl task);  }