### Question:
ServerStatusReader { static Step createDomainStatusReaderStep( DomainPresenceInfo info, long timeoutSeconds, Step next) { return new DomainStatusReaderStep(info, timeoutSeconds, next); } private  ServerStatusReader();   }### Answer:
@Test public void whenNoServersPresent_packetContainsEmptyStateAndHealthMaps() { Packet packet = testSupport.runSteps(ServerStatusReader.createDomainStatusReaderStep(info, 0, endStep)); assertThat((Map<?, ?>) packet.get(SERVER_STATE_MAP), Matchers.anEmptyMap()); assertThat((Map<?, ?>) packet.get(SERVER_HEALTH_MAP), Matchers.anEmptyMap()); }
@Test public void whenServersLackPods_packetContainsEmptyStateAndHealthMaps() { Packet packet = testSupport.runSteps(ServerStatusReader.createDomainStatusReaderStep(info, 0, endStep)); assertThat((Map<?, ?>) packet.get(SERVER_STATE_MAP), Matchers.anEmptyMap()); assertThat((Map<?, ?>) packet.get(SERVER_HEALTH_MAP), Matchers.anEmptyMap()); }
@Test public void whenServerPodsReturnNodeManagerStatus_recordInStateMap() { info.setServerPod("server1", createPod("server1")); info.setServerPod("server2", createPod("server2")); execFactory.defineResponse("server1", "server1 status"); execFactory.defineResponse("server2", "server2 status"); Packet packet = testSupport.runSteps(ServerStatusReader.createDomainStatusReaderStep(info, 0, endStep)); Map<String, String> serverStates = getServerStates(packet); assertThat(serverStates, hasEntry("server1", "server1 status")); assertThat(serverStates, hasEntry("server2", "server2 status")); }
@Test public void createDomainStatusReaderStep_initializesRemainingServersHealthRead_withNumServers() { info.setServerPod("server1", createPod("server1")); info.setServerPod("server2", createPod("server2")); Packet packet = testSupport.runSteps(ServerStatusReader.createDomainStatusReaderStep(info, 0, endStep)); assertThat( ((AtomicInteger) packet.get(ProcessingConstants.REMAINING_SERVERS_HEALTH_TO_READ)).get(), is(2)); }
@Test public void whenPodNotReadyAndHasLastKnownState_recordInStateMap() { info.setServerPod("server1", createPod("server1")); info.updateLastKnownServerStatus("server1", "not ready yet"); execFactory.defineResponse("server1", "still not ready yet"); Packet packet = testSupport.runSteps(ServerStatusReader.createDomainStatusReaderStep(info, 0, endStep)); Map<String, String> serverStates = getServerStates(packet); assertThat(serverStates, hasEntry("server1", "still not ready yet")); }
@Test public void whenPodIsReady_startHealthStepForIt() { info.setServerPod("server1", createPod("server1")); setReadyStatus(info.getServerPod("server1")); execFactory.defineResponse("server1", "RUNNING"); testSupport.runSteps(ServerStatusReader.createDomainStatusReaderStep(info, 0, endStep)); assertThat(stepFactory.serverNames, contains("server1")); }