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());
}
});
}
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());
}
});
}
Aggregations