### Question:
PDSMonitoringStatusService { @UseCaseAdminFetchesMonitoringStatus(@PDSStep(name="service call",description = "service fetches job state counts and gathers hearbeats of cluster members by serverId",number=4)) public PDSMonitoring getMonitoringStatus() { String serverId = serverConfiguratonService.getServerId(); PDSMonitoring monitoring = new PDSMonitoring(); addStateCounts(serverId, monitoring); addHeartBeatDataAsMember(serverId, monitoring); return monitoring; }  @UseCaseAdminFetchesMonitoringStatus(@PDSStep(name="service call",description = "service fetches job state counts and gathers hearbeats of cluster members by serverId",number=4)) PDSMonitoring getMonitoringStatus();  }### Answer:
@Test public void monitoringStatus_contains_information_about_two_members_when_two_members_defined() { PDSMonitoring testData = PDSMonitoringTestDataUtil.createTestMonitoringWith2ClusterMembers(); List<PDSHeartBeat> heartBeatsForServerId = new ArrayList<>(); PDSHeartBeat heartbeat1 = new PDSHeartBeat(); heartbeat1.setClusterMemberData(testData.getMembers().get(0).toJSON()); heartBeatsForServerId.add(heartbeat1); PDSHeartBeat heartbeat2 = new PDSHeartBeat(); heartbeat2.setClusterMemberData(testData.getMembers().get(1).toJSON()); heartBeatsForServerId.add(heartbeat2); when(heartBeatRepository.findAllByServerId(SERVER_ID)).thenReturn(heartBeatsForServerId); PDSMonitoring monitoring = serviceToTest.getMonitoringStatus(); assertEquals(2, monitoring.getMembers().size()); assertEquals(testData.getMembers().get(0).getHeartBeatTimestamp(), monitoring.getMembers().get(0).getHeartBeatTimestamp()); assertEquals(testData.getMembers().get(1).getHeartBeatTimestamp(), monitoring.getMembers().get(1).getHeartBeatTimestamp()); }
@Test public void monitoringStatus_contains_information_about_running_jobs() { addJob(SERVER_ID, PDSJobStatusState.RUNNING, 1); PDSMonitoring monitoring = serviceToTest.getMonitoringStatus(); assertFound(monitoring, PDSJobStatusState.RUNNING, 1); }
@Test public void monitoringStatus_contains_information_about_multiple_job_states_but_only_for_configured_server() { addJob(SERVER_ID, PDSJobStatusState.CREATED, 1); addJob(SERVER_ID, PDSJobStatusState.QUEUED, 2); addJob(SERVER_ID, PDSJobStatusState.RUNNING, 3); addJob(SERVER_ID, PDSJobStatusState.DONE, 4); addJob(SERVER_ID, PDSJobStatusState.FAILED, 5); addJob(SERVER_ID_FROM_OTHER_SERVER, PDSJobStatusState.QUEUED, 10); addJob(SERVER_ID_FROM_OTHER_SERVER, PDSJobStatusState.CREATED, 20); addJob(SERVER_ID_FROM_OTHER_SERVER, PDSJobStatusState.RUNNING, 30); addJob(SERVER_ID_FROM_OTHER_SERVER, PDSJobStatusState.DONE, 40); addJob(SERVER_ID_FROM_OTHER_SERVER, PDSJobStatusState.FAILED, 50); PDSMonitoring monitoring = serviceToTest.getMonitoringStatus(); assertFound(monitoring, PDSJobStatusState.CREATED,1); assertFound(monitoring, PDSJobStatusState.QUEUED,2); assertFound(monitoring, PDSJobStatusState.RUNNING,3); assertFound(monitoring, PDSJobStatusState.DONE,4); assertFound(monitoring, PDSJobStatusState.FAILED,5); }