private void updateExecutorRegistry(final PipelineExecutorTaskImpl task) { try { PipelineExecutorTaskImpl clone = (PipelineExecutorTaskImpl) task.clone(); pipelineExecutorRegistry.register(new PipelineExecutorTraceImpl(clone)); } catch (Exception e) { //clone is supported by construction, since PipelineExecutorTaskImpl is clonable. logger.error("Unexpected error: " + e.getMessage(), e); } }
private void updateExecutorRegistry(final PipelineExecutorTaskImpl task) { try { PipelineExecutorTaskImpl clone = (PipelineExecutorTaskImpl) task.clone(); pipelineExecutorRegistry.register(new PipelineExecutorTraceImpl(clone)); } catch (Exception e) { //clone is supported by construction, since PipelineExecutorTaskImpl is clonable. logger.error("Unexpected error: " + e.getMessage(), e); } }
private void verifyExecutorRegistryUpdated(boolean async) { if (async) { //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(1)).register(pipelineExecutorTraceCaptor.capture()); assertHasSameInfo(task, pipelineExecutorTraceCaptor.getValue().getTask()); } else { verify(pipelineExecutorRegistry, never()).register(anyObject()); } }
private void verifyExecutorRegistryUpdated(boolean async) { if (async) { //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(1)).register(pipelineExecutorTraceCaptor.capture()); assertHasSameInfo(task, pipelineExecutorTraceCaptor.getValue().getTask()); } else { verify(pipelineExecutorRegistry, never()).register(anyObject()); } }
times(1)).setTaskInStoppedStatus(task)); verify(pipelineExecutorRegistry, times(5)).register(pipelineExecutorTraceCaptor.capture()); Map<String, PipelineExecutorTask> registeredTasks = new HashMap<>(); pipelineExecutorTraceCaptor.getAllValues().forEach(capture -> registeredTasks.put(capture.getTaskId(),
times(1)).setTaskInStoppedStatus(task)); verify(pipelineExecutorRegistry, times(5)).register(pipelineExecutorTraceCaptor.capture()); Map<String, PipelineExecutorTask> registeredTasks = new HashMap<>(); pipelineExecutorTraceCaptor.getAllValues().forEach(capture -> registeredTasks.put(capture.getTaskId(),
@Test public void testStopAsyncTask() throws PipelineExecutorException { when(taskManagerHelper.generateTaskId()).thenReturn(TASK_ID); taskManager.init(); //prepare the input parameters. prepareExecution(); Future future = mock(Future.class); when(executorService.submit(any(Runnable.class))).thenReturn(future); String result = taskManager.execute(taskDef, PipelineExecutorTaskManager.ExecutionMode.ASYNCHRONOUS); assertEquals(TASK_ID, result); PipelineExecutorTaskManagerImpl.TaskEntry taskEntry = taskManager.currentTasks.get(TASK_ID); taskManager.stop(TASK_ID); verify(future, times(1)).cancel(true); assertFalse(taskManager.currentTasks.containsKey(TASK_ID)); verify(taskManagerHelper, times(1)).setTaskInStoppedStatus(taskEntry.getTask()); //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(2)).register(pipelineExecutorTraceCaptor.capture()); assertHasSameInfo(pipelineExecutorTraceCaptor.getAllValues().get(1).getTask(), pipelineExecutorTraceCaptor.getValue().getTask()); }
@Test public void testStopAsyncTask() throws PipelineExecutorException { when(taskManagerHelper.generateTaskId()).thenReturn(TASK_ID); taskManager.init(); //prepare the input parameters. prepareExecution(); Future future = mock(Future.class); when(executorService.submit(any(Runnable.class))).thenReturn(future); String result = taskManager.execute(taskDef, PipelineExecutorTaskManager.ExecutionMode.ASYNCHRONOUS); assertEquals(TASK_ID, result); PipelineExecutorTaskManagerImpl.TaskEntry taskEntry = taskManager.currentTasks.get(TASK_ID); taskManager.stop(TASK_ID); verify(future, times(1)).cancel(true); assertFalse(taskManager.currentTasks.containsKey(TASK_ID)); verify(taskManagerHelper, times(1)).setTaskInStoppedStatus(taskEntry.getTask()); //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(2)).register(pipelineExecutorTraceCaptor.capture()); assertHasSameInfo(pipelineExecutorTraceCaptor.getAllValues().get(1).getTask(), pipelineExecutorTraceCaptor.getValue().getTask()); }
@Test public void testExecuteSync() { when(taskManagerHelper.generateTaskId()).thenReturn(TASK_ID); taskManager.init(); //prepare the input parameters. prepareExecution(); String result = taskManager.execute(taskDef, PipelineExecutorTaskManager.ExecutionMode.SYNCHRONOUS); assertEquals(TASK_ID, result); //verify the task to execute was properly initialized. verify(taskManagerHelper, times(1)).createTask(taskDef); //verify the pipeline was properly executed. verify(pipelineExecutor, times(1)).execute(eq(taskDef.getInput()), eq(pipeline), any(Consumer.class), eq(taskManager.localListener)); //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(1)).register(pipelineExecutorTraceCaptor.capture()); assertEquals(PIPELINE_ID, pipelineExecutorTraceCaptor.getValue().getPipelineId()); assertEquals(TASK_ID, pipelineExecutorTraceCaptor.getValue().getTaskId()); }
@Test public void testExecuteSync() { when(taskManagerHelper.generateTaskId()).thenReturn(TASK_ID); taskManager.init(); //prepare the input parameters. prepareExecution(); String result = taskManager.execute(taskDef, PipelineExecutorTaskManager.ExecutionMode.SYNCHRONOUS); assertEquals(TASK_ID, result); //verify the task to execute was properly initialized. verify(taskManagerHelper, times(1)).createTask(taskDef); //verify the pipeline was properly executed. verify(pipelineExecutor, times(1)).execute(eq(taskDef.getInput()), eq(pipeline), any(Consumer.class), eq(taskManager.localListener)); //verify the pipeline executor registry was properly updated. verify(pipelineExecutorRegistry, times(1)).register(pipelineExecutorTraceCaptor.capture()); assertEquals(PIPELINE_ID, pipelineExecutorTraceCaptor.getValue().getPipelineId()); assertEquals(TASK_ID, pipelineExecutorTraceCaptor.getValue().getTaskId()); }
times(1)).register(pipelineExecutorTraceCaptor.capture());
times(1)).register(pipelineExecutorTraceCaptor.capture());