Search in sources :

Example 6 with ServiceSelector

use of org.opennms.netmgt.model.ServiceSelector in project opennms by OpenNMS.

the class OutageDaoIT method testGetMatchingOutages.

@Test
@JUnitTemporaryDatabase
public void testGetMatchingOutages() {
    m_transTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        public void doInTransactionWithoutResult(TransactionStatus status) {
            OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "localhost");
            m_nodeDao.save(node);
            insertEntitiesAndOutage("172.16.1.1", "ICMP", node);
        }
    });
    /*
         * We need to flush and finish the transaction because JdbcFilterDao
         * gets its own connection from the DataSource and won't see our data
         * otherwise.
         */
    m_transTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        public void doInTransactionWithoutResult(TransactionStatus status) {
            String[] svcs = new String[] { "ICMP" };
            ServiceSelector selector = new ServiceSelector("ipAddr IPLIKE 172.16.1.1", Arrays.asList(svcs));
            Collection<OnmsOutage> outages = m_outageDao.matchingCurrentOutages(selector);
            assertEquals("outage count", 1, outages.size());
        }
    });
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) TransactionStatus(org.springframework.transaction.TransactionStatus) Collection(java.util.Collection) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 7 with ServiceSelector

use of org.opennms.netmgt.model.ServiceSelector in project opennms by OpenNMS.

the class OutageDaoIT method testGetMatchingOutagesWithEmptyServiceList.

@Test
@JUnitTemporaryDatabase
public void testGetMatchingOutagesWithEmptyServiceList() {
    m_transTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        public void doInTransactionWithoutResult(TransactionStatus status) {
            OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "localhost");
            m_nodeDao.save(node);
            insertEntitiesAndOutage("172.16.1.1", "ICMP", node);
        }
    });
    /*
         * We need to flush and finish the transaction because JdbcFilterDao
         * gets its own connection from the DataSource and won't see our data
         * otherwise.
         */
    m_transTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        public void doInTransactionWithoutResult(TransactionStatus status) {
            ServiceSelector selector = new ServiceSelector("ipAddr IPLIKE 172.16.1.1", new ArrayList<String>(0));
            Collection<OnmsOutage> outages = m_outageDao.matchingCurrentOutages(selector);
            assertEquals(1, outages.size());
        }
    });
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) ArrayList(java.util.ArrayList) TransactionStatus(org.springframework.transaction.TransactionStatus) Collection(java.util.Collection) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Aggregations

ServiceSelector (org.opennms.netmgt.model.ServiceSelector)7 ArrayList (java.util.ArrayList)3 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)3 Collection (java.util.Collection)2 Test (org.junit.Test)2 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)2 Service (org.opennms.netmgt.config.poller.Service)2 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)2 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)2 StatusCategory (org.opennms.web.svclayer.catstatus.model.StatusCategory)2 StatusNode (org.opennms.web.svclayer.catstatus.model.StatusNode)2 TransactionStatus (org.springframework.transaction.TransactionStatus)2 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1