### Question:
TaskManager { public String createTask(String taskType, Map<String, Object> taskConfig) throws UnsupportedTaskException, TaskConfigurationException { taskFactory.createTask(taskType, taskConfig); String id = taskPersister.createTask(taskType, taskConfig); taskRunner.notifyNewTaskAvailableForRun(); return id; } TaskManager(String nodeId, TaskFactory taskFactory, TaskPersister taskPersister); synchronized void startTasksExecution(); synchronized void stopTasksExecution(); List<String> listSupportedTaskTypes(); String createTask(String taskType, Map<String, Object> taskConfig); TaskStatusInfo getTaskStatusInfo(String id); boolean cancelTask(String id); List<TaskStatusInfo> listTasks(String taskTypeFilter, List<TaskStatus> taskStatusFilter, int from, int size); String getNodeId(); TaskFactory getTaskFactory(); TaskPersister getTaskPersister(); TaskRunner getTaskRunner();  }### Answer:
@Test public void createTask() throws UnsupportedTaskException, TaskConfigurationException { TaskManager tested = getTested(); Map<String, Object> taskConfig = new HashMap<String, Object>(); Mockito.when(tested.taskFactory.createTask("tasktype", taskConfig)).thenReturn(Mockito.mock(Task.class)); Mockito.when(tested.taskPersister.createTask("tasktype", taskConfig)).thenReturn("myid"); Assert.assertEquals("myid", tested.createTask("tasktype", taskConfig)); Mockito.verify(tested.taskRunner).notifyNewTaskAvailableForRun(); Mockito.reset(tested.taskFactory, tested.taskPersister, tested.taskRunner); Mockito.when(tested.taskFactory.createTask("tasktype", taskConfig)).thenThrow(new UnsupportedTaskException("")); try { tested.createTask("tasktype", taskConfig); Assert.fail("UnsupportedTaskException expected"); } catch (UnsupportedTaskException e) { } Mockito.verifyZeroInteractions(tested.taskPersister, tested.taskRunner); }