ClusterState { public List<TaskInfo> getTaskList() { List<TaskInfo> taskInfoList = null; try { taskInfoList = zooKeeperStateDriver.get(getKey()); } catch (IOException e) { LOGGER.info("Unable to get key for cluster state due to invalid frameworkID.", e); } return taskInfoList == null ? new ArrayList<>(0) : taskInfoList; } 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 shouldGetListFromZK() throws IOException { List<Protos.TaskInfo> taskList = clusterState.getTaskList(); verify(state, times(1)).get(anyString()); assertEquals(0, taskList.size()); }
@Test public void shouldHandleGetException() throws IOException { when(state.<List<String>>get(anyString())).thenThrow(new IOException("Test exception")); List<Protos.TaskInfo> taskList = clusterState.getTaskList(); verify(state, times(1)).get(anyString()); assertEquals(0, taskList.size()); }
@Test public void shouldHandleGetNull() throws IOException { when(state.get(anyString())).thenReturn(null); List<Protos.TaskInfo> taskList = clusterState.getTaskList(); verify(state, times(1)).get(anyString()); assertEquals(0, taskList.size()); }