FrameworkState { public Protos.FrameworkID getFrameworkID() { Protos.FrameworkID id = null; try { id = zookeeperStateDriver.get(FRAMEWORKID_KEY); } catch (IOException e) { LOGGER.warn("Unable to get FrameworkID from zookeeper", e); } return id == null ? EMPTY_ID : id; } FrameworkState(SerializableState zookeeperStateDriver); Protos.FrameworkID getFrameworkID(); void markRegistered(Protos.FrameworkID frameworkId, SchedulerDriver driver); void destroy(); SchedulerDriver getDriver(); void onRegistered(Consumer<ClusterState> listener); void onNewTask(Consumer<ESTaskStatus> listener); boolean isRegistered(); void announceNewTask(ESTaskStatus esTask); void announceStatusUpdate(Protos.TaskStatus taskStatus); void onStatusUpdate(Consumer<Protos.TaskStatus> listener); static final Protos.FrameworkID EMPTY_ID; }
@Test public void testGetFrameworkID() throws IOException { when(state.get(anyString())).thenReturn(FRAMEWORK_ID); Protos.FrameworkID frameworkID = frameworkState.getFrameworkID(); verify(state, times(1)).get(anyString()); assertEquals(FRAMEWORK_ID, frameworkID); }
@Test public void testGetEmptyWhenNoFrameworkID() throws IOException { Protos.FrameworkID frameworkID = frameworkState.getFrameworkID(); verify(state, times(1)).get(anyString()); assertEquals("", frameworkID.getValue()); }
@Test public void testHandleGetException() throws IOException { doThrow(IOException.class).when(state).get(anyString()); frameworkState.getFrameworkID(); }