use of org.opennms.web.svclayer.catstatus.model.StatusNode in project opennms by OpenNMS.
the class DefaultCategoryStatusServiceTest method testGetCategoriesStatus.
public void testGetCategoriesStatus() {
View view = new View();
Section section = new Section();
section.setSectionName("Section One");
section.addCategory("Category One");
OnmsOutage outage = new OnmsOutage();
Collection<OnmsOutage> outages = new ArrayList<>();
outage.setId(300);
OnmsServiceType svcType = new OnmsServiceType();
svcType.setId(3);
svcType.setName("HTTP");
OnmsNode node = new OnmsNode();
node.setId(1);
node.setLabel("superLabel");
OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, 1);
OnmsIpInterface iface = new OnmsIpInterface("192.168.1.1", node);
iface.setSnmpInterface(snmpIface);
// iface.setId(9);
OnmsMonitoredService monSvc = new OnmsMonitoredService(iface, svcType);
outage.setMonitoredService(monSvc);
outages.add(outage);
view.addSection(section);
List<String> services = new ArrayList<>();
services.add("HTTP");
// ServiceSelector selector = new ServiceSelector("isHTTP",(List<String>) services);
expect(viewDisplayDao.getView()).andReturn(view);
expect(categoryDao.getCategoryByLabel("Category One")).andReturn(createCategoryFromLabel("Category One"));
expect(outageDao.matchingCurrentOutages(isA(ServiceSelector.class))).andReturn(outages);
replay(categoryDao);
replay(viewDisplayDao);
replay(outageDao);
Collection<StatusSection> statusSections = categoryStatusService.getCategoriesStatus();
verify(viewDisplayDao);
verify(categoryDao);
verify(outageDao);
assertEquals("Wrong Number of StatusSections", view.getSections().size(), statusSections.size());
for (StatusSection statusSection : statusSections) {
assertEquals("StatusSection Name Does Not Match", "Section One", statusSection.getName());
Collection<StatusCategory> statusCategorys = statusSection.getCategories();
for (StatusCategory statusCategory : statusCategorys) {
assertEquals("StatusCategoryName does not match", "Category One", statusCategory.getLabel());
// assertEquals("Category Comment Does not match","Category One Comment",statusCategory.getComment());
assertTrue("Nodes >= 1", statusCategory.getNodes().size() >= 1);
for (StatusNode statusNode : statusCategory.getNodes()) {
assertEquals("Label does not match", "superLabel", statusNode.getLabel());
}
}
}
}
use of org.opennms.web.svclayer.catstatus.model.StatusNode in project opennms by OpenNMS.
the class CategoryBuilder method addNode.
/**
* <p>addNode</p>
*
* @param nodeId a int.
* @param label a {@link java.lang.String} object.
* @return a {@link org.opennms.web.svclayer.catstatus.support.CategoryBuilder} object.
*/
public CategoryBuilder addNode(int nodeId, String label) {
if (!m_nodeMap.containsKey(nodeId)) {
StatusNode m_statusnode = new StatusNode();
m_statusnode.setLabel(label);
m_nodeMap.put(nodeId, m_statusnode);
}
return this;
}
use of org.opennms.web.svclayer.catstatus.model.StatusNode in project opennms by OpenNMS.
the class DefaultCategoryStatusService method createCategory.
private StatusCategory createCategory(String category) {
Collection<OnmsOutage> outages;
CategoryBuilder categoryBuilder = new CategoryBuilder();
StatusCategory statusCategory = new StatusCategory();
Category categoryDetail = m_categoryConfigDao.getCategoryByLabel(category);
// statusCategory.setComment(categoryDetail.getCategoryComment());
statusCategory.setLabel(category);
ServiceSelector selector = new ServiceSelector(categoryDetail.getRule(), getServicesForCategory(categoryDetail));
outages = m_outageDao.matchingCurrentOutages(selector);
for (OnmsOutage outage : outages) {
OnmsMonitoredService monitoredService = outage.getMonitoredService();
OnmsServiceType serviceType = monitoredService.getServiceType();
OnmsIpInterface ipInterface = monitoredService.getIpInterface();
final String ipAddress = InetAddressUtils.str(ipInterface.getIpAddress());
categoryBuilder.addOutageService(monitoredService.getNodeId(), ipAddress, ipAddress, ipInterface.getNode().getLabel(), serviceType.getName());
}
for (StatusNode node : categoryBuilder.getNodes()) {
statusCategory.addNode(node);
}
return statusCategory;
}
use of org.opennms.web.svclayer.catstatus.model.StatusNode in project opennms by OpenNMS.
the class CategoryBuilder method addInterface.
/**
* <p>addInterface</p>
*
* @param nodeId a int.
* @param interfaceIp a {@link java.lang.String} object.
* @param ipAddress a {@link java.lang.String} object.
* @param nodeLabel a {@link java.lang.String} object.
* @return a {@link org.opennms.web.svclayer.catstatus.support.CategoryBuilder} object.
*/
public CategoryBuilder addInterface(int nodeId, String interfaceIp, String ipAddress, String nodeLabel) {
if (!m_nodeAndInterfaceMap.containsKey(getNodeAndInterfaceKey(nodeId, interfaceIp))) {
addNode(nodeId, nodeLabel);
StatusNode statusNode = m_nodeMap.get(nodeId);
StatusInterface intf = new StatusInterface();
intf.setIpAddress(ipAddress);
statusNode.addIpInterface(intf);
m_nodeAndInterfaceMap.put(getNodeAndInterfaceKey(nodeId, interfaceIp), intf);
}
return this;
}
Aggregations