ClusterState { public ESTaskStatus getStatus(TaskID taskID) throws IllegalArgumentException { return getStatus(getTask(taskID)); } 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(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenGetStatusTaskIDDesntExist() throws IOException { clusterState.getStatus(Protos.TaskID.newBuilder().setValue("").build()); }
@Test public void shouldReturnStatusWhenDoesExist() throws IOException { ArrayList<Protos.TaskInfo> taskInfos = new ArrayList<>(); taskInfos.add(ProtoTestUtil.getDefaultTaskInfo()); Protos.TaskInfo defaultTaskInfo = ProtoTestUtil.getDefaultTaskInfo(); taskInfos.add(defaultTaskInfo); when(state.get(anyString())).thenReturn(taskInfos).thenReturn(ProtoTestUtil.getDefaultTaskStatus(Protos.TaskState.TASK_FINISHED)); ESTaskStatus status = clusterState.getStatus(defaultTaskInfo.getTaskId()); assertNotNull(status); }