Search in sources :

Example 51 with MockService

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

the class PollerQueryManagerDaoIT method testServiceDeleted.

// serviceDeleted: EventConstants.SERVICE_DELETED_EVENT_UEI
@Test
public void testServiceDeleted() {
    MockService svc = m_network.getService(1, "192.168.1.1", "SMTP");
    testElementDeleted(svc);
}
Also used : MockService(org.opennms.netmgt.mock.MockService) Test(org.junit.Test)

Example 52 with MockService

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

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

Example 53 with MockService

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

the class PollerQueryManagerDaoIT 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 54 with MockService

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

the class PollerQueryManagerDaoIT method testUnmangedWithOpenOutageAtStartup.

// test open outages for unmanaged services
@Test
public void testUnmangedWithOpenOutageAtStartup() throws InterruptedException {
    // before we start we need to initialize the database
    // create an outage for the service
    MockService svc = m_network.getService(1, "192.168.1.1", "SMTP");
    MockInterface iface = m_network.getInterface(1, "192.168.1.2");
    Event svcLostEvent = MockEventUtil.createNodeLostServiceEvent("Test", svc);
    m_db.writeEvent(svcLostEvent);
    createOutages(svc, svcLostEvent);
    Event ifaceDownEvent = MockEventUtil.createInterfaceDownEvent("Test", iface);
    m_db.writeEvent(ifaceDownEvent);
    createOutages(iface, ifaceDownEvent);
    // mark the service as unmanaged
    m_db.setServiceStatus(svc, 'U');
    m_db.setInterfaceStatus(iface, 'U');
    // assert that we have an open outage
    assertEquals(1, m_db.countOpenOutagesForService(svc));
    assertEquals(1, m_db.countOutagesForService(svc));
    assertEquals(iface.getServices().size(), m_db.countOutagesForInterface(iface));
    assertEquals(iface.getServices().size(), m_db.countOpenOutagesForInterface(iface));
    startDaemons();
    // assert that we have no open outages
    assertEquals(0, m_db.countOpenOutagesForService(svc));
    assertEquals(1, m_db.countOutagesForService(svc));
    assertEquals(0, m_db.countOpenOutagesForInterface(iface));
    assertEquals(iface.getServices().size(), m_db.countOutagesForInterface(iface));
}
Also used : MockInterface(org.opennms.netmgt.mock.MockInterface) MockService(org.opennms.netmgt.mock.MockService) Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test)

Example 55 with MockService

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

the class PollerIT method anticipateServicesUp.

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

        @Override
        public void visitService(MockService svc) {
            anticipateUp(svc);
        }
    };
    node.visit(eventCreator);
}
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)59 Test (org.junit.Test)36 Event (org.opennms.netmgt.xml.event.Event)19 MockNode (org.opennms.netmgt.mock.MockNode)16 MockVisitor (org.opennms.netmgt.mock.MockVisitor)14 MockVisitorAdapter (org.opennms.netmgt.mock.MockVisitorAdapter)14 Date (java.util.Date)8 MockInterface (org.opennms.netmgt.mock.MockInterface)8 Timestamp (java.sql.Timestamp)3 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)3 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2 Querier (org.opennms.core.utils.Querier)2 PollAnticipator (org.opennms.netmgt.mock.PollAnticipator)2 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)1 LocationAwarePingClient (org.opennms.netmgt.icmp.proxy.LocationAwarePingClient)1 MockNetwork (org.opennms.netmgt.mock.MockNetwork)1