@Test public void testDestroySyncTask() throws PipelineExecutorException { PipelineExecutorTaskManagerImpl.TaskEntry taskEntry = mock(PipelineExecutorTaskManagerImpl.TaskEntry.class); when(taskEntry.isAsync()).thenReturn(false); taskManager.currentTasks.put(TASK_ID, taskEntry); taskManager.init(); expectedException.expectMessage("Destroy operation is not available for taskId: " + TASK_ID + " running in SYNCHRONOUS mode"); taskManager.destroy(TASK_ID); }
@Test public void testDestroySyncTask() throws PipelineExecutorException { PipelineExecutorTaskManagerImpl.TaskEntry taskEntry = mock(PipelineExecutorTaskManagerImpl.TaskEntry.class); when(taskEntry.isAsync()).thenReturn(false); taskManager.currentTasks.put(TASK_ID, taskEntry); taskManager.init(); expectedException.expectMessage("Destroy operation is not available for taskId: " + TASK_ID + " running in SYNCHRONOUS mode"); taskManager.destroy(TASK_ID); }
@Test public void testDestroyAsyncTask() 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); taskManager.destroy(TASK_ID); verify(future, times(1)).cancel(true); assertFalse(taskManager.currentTasks.containsKey(TASK_ID)); verify(pipelineExecutorRegistry, times(1)).deregister(TASK_ID); }
@Test public void testDestroyAsyncTask() 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); taskManager.destroy(TASK_ID); verify(future, times(1)).cancel(true); assertFalse(taskManager.currentTasks.containsKey(TASK_ID)); verify(pipelineExecutorRegistry, times(1)).deregister(TASK_ID); }
@Test public void testDestroyNonExistingTask() throws PipelineExecutorException { taskManager.init(); expectedException.expectMessage("No PipelineExecutorTask was found for taskId: " + TASK_ID); taskManager.destroy(TASK_ID); }
taskManager.destroy(); tasks.forEach(task -> verify(taskManagerHelper, times(1)).setTaskInStoppedStatus(task));
@Test public void testDestroyNonExistingTask() throws PipelineExecutorException { taskManager.init(); expectedException.expectMessage("No PipelineExecutorTask was found for taskId: " + TASK_ID); taskManager.destroy(TASK_ID); }
taskManager.destroy(); tasks.forEach(task -> verify(taskManagerHelper, times(1)).setTaskInStoppedStatus(task));