@Test public void testGetRtcForSet() { UserDetails details = populateSecurityContext(); EasyMockUtils mock = new EasyMockUtils(); MonitoredServiceDao monSvcDao = mock.createMock(MonitoredServiceDao.class); OutageDao outageDao = mock.createMock(OutageDao.class); SurveillanceViewConfigDao survViewConfigDao = mock.createMock(SurveillanceViewConfigDao.class); GroupDao groupDao = mock.createMock(GroupDao.class); CategoryDao categoryDao = mock.createMock(CategoryDao.class); mock.replayAll(); DefaultRtcService rtcService = new DefaultRtcService(); rtcService.setMonitoredServiceDao(monSvcDao); rtcService.setOutageDao(outageDao); rtcService.afterPropertiesSet(); m_service.setRtcService(rtcService); m_service.setSurveillanceViewConfigDao(survViewConfigDao); m_service.setGroupDao(groupDao); m_service.setCategoryDao(categoryDao); mock.verifyAll(); expect(survViewConfigDao.getView(details.getUsername())).andReturn(null).atLeastOnce(); expect(groupDao.findGroupsForUser(details.getUsername())).andReturn(new ArrayList<Group>()).atLeastOnce(); View defaultView = new View(); defaultView.setColumns(new Columns()); defaultView.setRows(new Rows()); expect(survViewConfigDao.getDefaultView()).andReturn(defaultView).atLeastOnce(); expect(monSvcDao.findMatching(isA(OnmsCriteria.class))).andReturn(new ArrayList<OnmsMonitoredService>()); expect(outageDao.findMatching(isA(OnmsCriteria.class))).andReturn(new ArrayList<OnmsOutage>()); mock.replayAll(); NodeRtc[] rtcs = m_service.getRtcForSet(SurveillanceSet.DEFAULT); mock.verifyAll(); assertNotNull("rtcs should not be null", rtcs); }
public NodeRtc[] getRtcForSet(SurveillanceSet set) { OnmsCriteria serviceCriteria = m_rtcService.createServiceCriteria(); OnmsCriteria outageCriteria = m_rtcService.createOutageCriteria(); addCriteriaForSurveillanceSet(serviceCriteria, set); addCriteriaForSurveillanceSet(outageCriteria, set); RtcNodeModel model = m_rtcService.getNodeListForCriteria(serviceCriteria, outageCriteria); NodeRtc[] nodeRtc = new NodeRtc[model.getNodeList().size()]; int index = 0; boolean isDashboardRole = isDashboardRole(); for (RtcNode node : model.getNodeList()) { NodeRtc n = new NodeRtc(); n.setNodeLabel(node.getNode().getLabel()); n.setNodeId(node.getNode().getNodeId()); n.setIsDashboardRole(isDashboardRole); n.setDownServiceCount(node.getDownServiceCount()); n.setServiceCount(node.getServiceCount()); if (node.getDownServiceCount() == 0) { n.setServiceStyle("Normal"); } else { n.setServiceStyle("Critical"); } n.setAvailability(node.getAvailabilityAsString()); if (node.getAvailability() == 1.0) { n.setAvailabilityStyle("Normal"); } else { n.setAvailabilityStyle("Critical"); } nodeRtc[index++] = n; } return nodeRtc; }
DefaultSurveillanceService implements SurveillanceService, InitializingBean { public NodeRtc[] getRtcForSet(SurveillanceSet set) { OnmsCriteria serviceCriteria = m_rtcService.createServiceCriteria(); OnmsCriteria outageCriteria = m_rtcService.createOutageCriteria(); addCriteriaForSurveillanceSet(serviceCriteria, set); addCriteriaForSurveillanceSet(outageCriteria, set); RtcNodeModel model = m_rtcService.getNodeListForCriteria(serviceCriteria, outageCriteria); NodeRtc[] nodeRtc = new NodeRtc[model.getNodeList().size()]; int index = 0; boolean isDashboardRole = isDashboardRole(); for (RtcNode node : model.getNodeList()) { NodeRtc n = new NodeRtc(); n.setNodeLabel(node.getNode().getLabel()); n.setNodeId(node.getNode().getNodeId()); n.setIsDashboardRole(isDashboardRole); n.setDownServiceCount(node.getDownServiceCount()); n.setServiceCount(node.getServiceCount()); if (node.getDownServiceCount() == 0) { n.setServiceStyle("Normal"); } else { n.setServiceStyle("Critical"); } n.setAvailability(node.getAvailabilityAsString()); if (node.getAvailability() == 1.0) { n.setAvailabilityStyle("Normal"); } else { n.setAvailabilityStyle("Critical"); } nodeRtc[index++] = n; } return nodeRtc; } }
DefaultSurveillanceService implements SurveillanceService, InitializingBean { public NodeRtc[] getRtcForSet(SurveillanceSet set) { OnmsCriteria serviceCriteria = m_rtcService.createServiceCriteria(); OnmsCriteria outageCriteria = m_rtcService.createOutageCriteria(); addCriteriaForSurveillanceSet(serviceCriteria, set); addCriteriaForSurveillanceSet(outageCriteria, set); RtcNodeModel model = m_rtcService.getNodeListForCriteria(serviceCriteria, outageCriteria); NodeRtc[] nodeRtc = new NodeRtc[model.getNodeList().size()]; int index = 0; boolean isDashboardRole = isDashboardRole(); for (RtcNode node : model.getNodeList()) { NodeRtc n = new NodeRtc(); n.setNodeLabel(node.getNode().getLabel()); n.setNodeId(node.getNode().getNodeId()); n.setIsDashboardRole(isDashboardRole); n.setDownServiceCount(node.getDownServiceCount()); n.setServiceCount(node.getServiceCount()); if (node.getDownServiceCount() == 0) { n.setServiceStyle("Normal"); } else { n.setServiceStyle("Critical"); } n.setAvailability(node.getAvailabilityAsString()); if (node.getAvailability() == 1.0) { n.setAvailabilityStyle("Normal"); } else { n.setAvailabilityStyle("Critical"); } nodeRtc[index++] = n; } return nodeRtc; }  }
DefaultSurveillanceService implements SurveillanceService, InitializingBean { public NodeRtc[] getRtcForSet(SurveillanceSet set) { OnmsCriteria serviceCriteria = m_rtcService.createServiceCriteria(); OnmsCriteria outageCriteria = m_rtcService.createOutageCriteria(); addCriteriaForSurveillanceSet(serviceCriteria, set); addCriteriaForSurveillanceSet(outageCriteria, set); RtcNodeModel model = m_rtcService.getNodeListForCriteria(serviceCriteria, outageCriteria); NodeRtc[] nodeRtc = new NodeRtc[model.getNodeList().size()]; int index = 0; boolean isDashboardRole = isDashboardRole(); for (RtcNode node : model.getNodeList()) { NodeRtc n = new NodeRtc(); n.setNodeLabel(node.getNode().getLabel()); n.setNodeId(node.getNode().getNodeId()); n.setIsDashboardRole(isDashboardRole); n.setDownServiceCount(node.getDownServiceCount()); n.setServiceCount(node.getServiceCount()); if (node.getDownServiceCount() == 0) { n.setServiceStyle("Normal"); } else { n.setServiceStyle("Critical"); } n.setAvailability(node.getAvailabilityAsString()); if (node.getAvailability() == 1.0) { n.setAvailabilityStyle("Normal"); } else { n.setAvailabilityStyle("Critical"); } nodeRtc[index++] = n; } return nodeRtc; }  SurveillanceData getSurveillanceData(); Alarm[] getAlarmsForSet(SurveillanceSet set); String[] getNodeNames(SurveillanceSet set); String[][] getResources(SurveillanceSet set); String[][] getChildResources(String id); String[][] getPrefabGraphs(String id); Notification[] getNotificationsForSet(SurveillanceSet set); NodeRtc[] getRtcForSet(SurveillanceSet set); @Override void afterPropertiesSet(); void setNodeDao(NodeDao nodeDao); void setNotificationDao(NotificationDao notifDao); void setResourceDao(ResourceDao resourceDao); void setGraphDao(GraphDao graphDao); org.opennms.web.svclayer.SurveillanceService getWebSurveillanceService(); void setWebSurveillanceService(org.opennms.web.svclayer.SurveillanceService webSurveillanceService); SurveillanceViewConfigDao getSurveillanceViewConfigDao(); void setSurveillanceViewConfigDao(SurveillanceViewConfigDao surveillanceViewConfigDao); CategoryDao getCategoryDao(); void setCategoryDao(CategoryDao categoryDao); AlarmDao getAlarmDao(); void setAlarmDao(AlarmDao alarmDao); RtcService getRtcService(); void setRtcService(RtcService rtcService); GroupDao getGroupDao(); void setGroupDao(GroupDao groupDao); OutageDao getOutageDao(); void setOutageDao(OutageDao outageDao); }
DefaultSurveillanceService implements SurveillanceService, InitializingBean { public NodeRtc[] getRtcForSet(SurveillanceSet set) { OnmsCriteria serviceCriteria = m_rtcService.createServiceCriteria(); OnmsCriteria outageCriteria = m_rtcService.createOutageCriteria(); addCriteriaForSurveillanceSet(serviceCriteria, set); addCriteriaForSurveillanceSet(outageCriteria, set); RtcNodeModel model = m_rtcService.getNodeListForCriteria(serviceCriteria, outageCriteria); NodeRtc[] nodeRtc = new NodeRtc[model.getNodeList().size()]; int index = 0; boolean isDashboardRole = isDashboardRole(); for (RtcNode node : model.getNodeList()) { NodeRtc n = new NodeRtc(); n.setNodeLabel(node.getNode().getLabel()); n.setNodeId(node.getNode().getNodeId()); n.setIsDashboardRole(isDashboardRole); n.setDownServiceCount(node.getDownServiceCount()); n.setServiceCount(node.getServiceCount()); if (node.getDownServiceCount() == 0) { n.setServiceStyle("Normal"); } else { n.setServiceStyle("Critical"); } n.setAvailability(node.getAvailabilityAsString()); if (node.getAvailability() == 1.0) { n.setAvailabilityStyle("Normal"); } else { n.setAvailabilityStyle("Critical"); } nodeRtc[index++] = n; } return nodeRtc; }  SurveillanceData getSurveillanceData(); Alarm[] getAlarmsForSet(SurveillanceSet set); String[] getNodeNames(SurveillanceSet set); String[][] getResources(SurveillanceSet set); String[][] getChildResources(String id); String[][] getPrefabGraphs(String id); Notification[] getNotificationsForSet(SurveillanceSet set); NodeRtc[] getRtcForSet(SurveillanceSet set); @Override void afterPropertiesSet(); void setNodeDao(NodeDao nodeDao); void setNotificationDao(NotificationDao notifDao); void setResourceDao(ResourceDao resourceDao); void setGraphDao(GraphDao graphDao); org.opennms.web.svclayer.SurveillanceService getWebSurveillanceService(); void setWebSurveillanceService(org.opennms.web.svclayer.SurveillanceService webSurveillanceService); SurveillanceViewConfigDao getSurveillanceViewConfigDao(); void setSurveillanceViewConfigDao(SurveillanceViewConfigDao surveillanceViewConfigDao); CategoryDao getCategoryDao(); void setCategoryDao(CategoryDao categoryDao); AlarmDao getAlarmDao(); void setAlarmDao(AlarmDao alarmDao); RtcService getRtcService(); void setRtcService(RtcService rtcService); GroupDao getGroupDao(); void setGroupDao(GroupDao groupDao); OutageDao getOutageDao(); void setOutageDao(OutageDao outageDao);  }