ClusterState { public void addTask(ESTaskStatus esTask) { addTask(esTask.getTaskInfo()); } ClusterState(@NotNull SerializableState zooKeeperStateDriver, @NotNull FrameworkState frameworkState); List<TaskInfo> getTaskList(); Integer getElasticNodeId(); Map<String, Task> getGuiTaskList(); ESTaskStatus getStatus(TaskID taskID); void addTask(ESTaskStatus esTask); void addTask(TaskInfo taskInfo); void removeTask(TaskInfo taskInfo); Boolean exists(TaskID taskId); TaskInfo getTask(TaskID taskID); TaskInfo getTask(Protos.ExecutorID executorID); void update(Protos.TaskStatus status); boolean taskInError(Protos.TaskStatus status); void destroy(); static final Logger LOGGER; static final String STATE_LIST; }
@Test public void shouldAddTask() throws IOException { ArrayList<Protos.TaskInfo> mock = Mockito.spy(new ArrayList<>()); when(state.get(anyString())).thenReturn(mock); Protos.TaskInfo defaultTaskInfo = ProtoTestUtil.getDefaultTaskInfo(); clusterState.addTask(defaultTaskInfo); verify(state, times(1)).set(anyString(), any()); verify(mock, times(1)).add(eq(defaultTaskInfo)); }
@Test public void shouldHandleExceptionWhenAddingTask() throws IOException { ArrayList<Protos.TaskInfo> mock = Mockito.spy(new ArrayList<>()); when(state.get(anyString())).thenReturn(mock); doThrow(IOException.class).when(state).set(anyString(), any()); Protos.TaskInfo defaultTaskInfo = ProtoTestUtil.getDefaultTaskInfo(); clusterState.addTask(defaultTaskInfo); }