use of org.opennms.netmgt.mock.MockVisitorAdapter in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method bringDownCritSvcs.
private void bringDownCritSvcs(MockElement element) {
MockVisitor markCritSvcDown = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
if ("ICMP".equals(svc.getSvcName())) {
svc.bringDown();
}
}
};
element.visit(markCritSvcDown);
}
use of org.opennms.netmgt.mock.MockVisitorAdapter in project opennms by OpenNMS.
the class PollerIT method createOutages.
private void createOutages(MockElement element, final Event event) {
MockVisitor outageCreater = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
if (svc.getMgmtStatus().equals(SvcMgmtStatus.ACTIVE)) {
m_db.createOutage(svc, event);
}
}
};
element.visit(outageCreater);
}
use of org.opennms.netmgt.mock.MockVisitorAdapter in project opennms by OpenNMS.
the class PollerIT method sendNodeGainedServices.
private void sendNodeGainedServices(int nodeid, String nodeLabel, String ipAddr, String... svcNames) {
assertNotNull(svcNames);
assertTrue(svcNames.length > 0);
MockNode node = m_network.addNode(nodeid, nodeLabel);
m_db.writeNode(node);
MockInterface iface = m_network.addInterface(nodeid, ipAddr);
m_db.writeInterface(iface);
List<MockService> services = new ArrayList<MockService>();
for (String svcName : svcNames) {
MockService svc = m_network.addService(nodeid, ipAddr, svcName);
m_db.writeService(svc);
m_pollerConfig.addService(svc);
services.add(svc);
}
MockVisitor gainSvcSender = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
Event event = MockEventUtil.createNodeGainedServiceEvent("Test", svc);
m_eventMgr.sendEventToListeners(event);
}
};
node.visit(gainSvcSender);
MockService svc1 = services.get(0);
PollAnticipator anticipator = new PollAnticipator();
svc1.addAnticipator(anticipator);
anticipator.anticipateAllServices(svc1);
StringBuffer didNotOccur = new StringBuffer();
for (MockService service : anticipator.waitForAnticipated(10000)) {
didNotOccur.append(service.toString());
}
StringBuffer unanticipatedStuff = new StringBuffer();
for (MockService service : anticipator.unanticipatedPolls()) {
unanticipatedStuff.append(service.toString());
}
assertEquals(unanticipatedStuff.toString(), "", didNotOccur.toString());
anticipateDown(svc1);
svc1.bringDown();
verifyAnticipated(10000);
}
use of org.opennms.netmgt.mock.MockVisitorAdapter in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method testSendNodeGainedServices.
private void testSendNodeGainedServices(int nodeid, String nodeLabel, String ipAddr, String... svcNames) {
assertNotNull(svcNames);
assertTrue(svcNames.length > 0);
MockNode node = m_network.addNode(nodeid, nodeLabel);
m_db.writeNode(node);
MockInterface iface = m_network.addInterface(nodeid, ipAddr);
m_db.writeInterface(iface);
List<MockService> services = new ArrayList<MockService>();
for (String svcName : svcNames) {
MockService svc = m_network.addService(nodeid, ipAddr, svcName);
m_db.writeService(svc);
m_pollerConfig.addService(svc);
services.add(svc);
}
MockVisitor gainSvcSender = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
Event event = MockEventUtil.createNodeGainedServiceEvent("Test", svc);
m_eventMgr.sendEventToListeners(event);
}
};
node.visit(gainSvcSender);
MockService svc1 = services.get(0);
PollAnticipator anticipator = new PollAnticipator();
svc1.addAnticipator(anticipator);
anticipator.anticipateAllServices(svc1);
StringBuffer didNotOccur = new StringBuffer();
for (MockService service : anticipator.waitForAnticipated(10000)) {
didNotOccur.append(service.toString());
}
StringBuffer unanticipatedStuff = new StringBuffer();
for (MockService service : anticipator.unanticipatedPolls()) {
unanticipatedStuff.append(service.toString());
}
assertEquals(unanticipatedStuff.toString(), "", didNotOccur.toString());
anticipateDown(svc1);
svc1.bringDown();
verifyAnticipated(10000);
}
use of org.opennms.netmgt.mock.MockVisitorAdapter in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method anticipateServicesUp.
private void anticipateServicesUp(MockElement node) {
MockVisitor eventCreator = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
anticipateUp(svc);
}
};
node.visit(eventCreator);
}
Aggregations