Search in sources :

Example 1 with MockVisitor

use of org.opennms.netmgt.mock.MockVisitor in project opennms by OpenNMS.

the class MockDatabase method populate.

public void populate(MockNetwork network) {
    MockVisitor dbCreater = new MockVisitorAdapter() {

        @Override
        public void visitNode(MockNode node) {
            writeNode(node);
        }

        @Override
        public void visitInterface(MockInterface iface) {
            writeInterface(iface);
        }

        @Override
        public void visitService(MockService svc) {
            writeService(svc);
        }

        @Override
        public void visitPathOutage(MockPathOutage out) {
            writePathOutage(out);
        }
    };
    network.visit(dbCreater);
    getJdbcTemplate().queryForObject("SELECT setval('nodeNxtId', max(nodeid)) FROM node", Integer.class);
}
Also used : MockVisitorAdapter(org.opennms.netmgt.mock.MockVisitorAdapter) MockVisitor(org.opennms.netmgt.mock.MockVisitor) MockInterface(org.opennms.netmgt.mock.MockInterface) MockPathOutage(org.opennms.netmgt.mock.MockPathOutage) MockService(org.opennms.netmgt.mock.MockService) MockNode(org.opennms.netmgt.mock.MockNode)

Example 2 with MockVisitor

use of org.opennms.netmgt.mock.MockVisitor in project opennms by OpenNMS.

the class PollablesIT method anticipateResponsive.

private void anticipateResponsive(MockElement element) {
    MockVisitor visitor = new MockVisitorAdapter() {

        @Override
        public void visitService(MockService svc) {
            m_eventMgr.getEventAnticipator().anticipateEvent(svc.createResponsiveEvent());
        }
    };
    element.visit(visitor);
}
Also used : MockVisitorAdapter(org.opennms.netmgt.mock.MockVisitorAdapter) MockVisitor(org.opennms.netmgt.mock.MockVisitor) MockService(org.opennms.netmgt.mock.MockService)

Example 3 with MockVisitor

use of org.opennms.netmgt.mock.MockVisitor in project opennms by OpenNMS.

the class PollablesIT method assertNoPoll.

/**
     * @param network
     */
private void assertNoPoll(MockElement elem) {
    MockVisitor zeroAsserter = new MockVisitorAdapter() {

        @Override
        public void visitService(MockService svc) {
            assertEquals("Unexpected poll count for " + svc, 0, svc.getPollCount());
        }
    };
    elem.visit(zeroAsserter);
}
Also used : MockVisitorAdapter(org.opennms.netmgt.mock.MockVisitorAdapter) MockVisitor(org.opennms.netmgt.mock.MockVisitor) MockService(org.opennms.netmgt.mock.MockService)

Example 4 with MockVisitor

use of org.opennms.netmgt.mock.MockVisitor in project opennms by OpenNMS.

the class PollerIT method anticipateServicesDown.

private void anticipateServicesDown(MockElement node) {
    MockVisitor eventCreator = new MockVisitorAdapter() {

        @Override
        public void visitService(MockService svc) {
            anticipateDown(svc);
        }
    };
    node.visit(eventCreator);
}
Also used : MockVisitorAdapter(org.opennms.netmgt.mock.MockVisitorAdapter) MockVisitor(org.opennms.netmgt.mock.MockVisitor) MockService(org.opennms.netmgt.mock.MockService)

Example 5 with MockVisitor

use of org.opennms.netmgt.mock.MockVisitor in project opennms by OpenNMS.

the class PollerIT 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);
}
Also used : MockVisitorAdapter(org.opennms.netmgt.mock.MockVisitorAdapter) MockVisitor(org.opennms.netmgt.mock.MockVisitor) MockService(org.opennms.netmgt.mock.MockService)

Aggregations

MockService (org.opennms.netmgt.mock.MockService)14 MockVisitor (org.opennms.netmgt.mock.MockVisitor)14 MockVisitorAdapter (org.opennms.netmgt.mock.MockVisitorAdapter)14 MockInterface (org.opennms.netmgt.mock.MockInterface)3 MockNode (org.opennms.netmgt.mock.MockNode)3 ArrayList (java.util.ArrayList)2 PollAnticipator (org.opennms.netmgt.mock.PollAnticipator)2 Event (org.opennms.netmgt.xml.event.Event)2 MockPathOutage (org.opennms.netmgt.mock.MockPathOutage)1