use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class DaoWebOutageRepositoryIT method testGetOutagesByLocation.
@Test
// Relies on specific IDs so we need a fresh database
@JUnitTemporaryDatabase
public void testGetOutagesByLocation() {
createNodeEventAndOutage("Pittsboro", "nodeA", "172.16.10.10", "ICMP");
createNodeEventAndOutage("Pittsboro", "nodeB", "172.16.10.20", "ICMP");
createNodeEventAndOutage("Minneapolis", "nodeC", "172.16.20.10", "ICMP");
createNodeEventAndOutage("Minneapolis", "nodeD", "172.16.20.20", "ICMP");
createNodeEventAndOutage("Minneapolis", "nodeE", "172.16.20.30", "ICMP");
Outage[] outage1 = m_daoOutageRepo.getMatchingOutages(new OutageCriteria());
assertEquals(8, outage1.length);
Outage[] outage2 = m_daoOutageRepo.getMatchingOutages(new OutageCriteria(new LocationFilter("Minneapolis")));
assertEquals(3, outage2.length);
assertTrue(Arrays.stream(outage2).allMatch(o -> o.getLocation().equals("Minneapolis")));
Outage[] outage3 = m_daoOutageRepo.getMatchingOutages(new OutageCriteria(new NegativeLocationFilter("Minneapolis")));
assertEquals(5, outage3.length);
assertTrue(Arrays.stream(outage3).allMatch(o -> !o.getLocation().equals("Minneapolis")));
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class WebOutageRepositoryFilterIT method testRegainedServiceDateBeforeFilter.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
public void testRegainedServiceDateBeforeFilter() {
RegainedServiceDateBeforeFilter filter = new RegainedServiceDateBeforeFilter(new Date());
OutageCriteria criteria = new OutageCriteria(filter);
Outage[] outages = m_daoOutageRepo.getMatchingOutages(criteria);
assertEquals(1, outages.length);
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class WebOutageRepositoryFilterIT method testLostServiceDateBeforeFilter.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
public void testLostServiceDateBeforeFilter() {
LostServiceDateBeforeFilter filter = new LostServiceDateBeforeFilter(new Date());
OutageCriteria criteria = new OutageCriteria(filter);
Outage[] outages = m_daoOutageRepo.getMatchingOutages(criteria);
assertEquals(3, outages.length);
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class NetworkElementFactoryIT method testGetNodesWithIpLikeOneInterface.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testGetNodesWithIpLikeOneInterface() throws Exception {
// setUp() creates nodes by default, start with a clean slate
for (final OnmsNode node : m_nodeDao.findAll()) {
m_nodeDao.delete(node);
}
m_nodeDao.flush();
m_jdbcTemplate.update("INSERT INTO node (location, nodeId, nodeCreateTime, nodeType) VALUES ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 12, now(), 'A')");
m_jdbcTemplate.update("INSERT INTO ipInterface (nodeId, ipAddr, isManaged) VALUES (12, '1.1.1.1', 'M')");
final List<OnmsNode> nodes = NetworkElementFactory.getInstance(m_appContext).getNodesWithIpLike("*.*.*.*");
assertEquals("node count", 1, nodes.size());
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class NetworkElementFactoryIT method testGetNodesWithIpLikeTwoInterfaces.
// bug introduced in revision 2932
@Test
@JUnitTemporaryDatabase
public void testGetNodesWithIpLikeTwoInterfaces() throws Exception {
// setUp() creates nodes by default, start with a clean slate
for (final OnmsNode node : m_nodeDao.findAll()) {
m_nodeDao.delete(node);
}
m_nodeDao.flush();
m_jdbcTemplate.update("INSERT INTO node (location, nodeId, nodeCreateTime, nodeType) VALUES ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 12, now(), 'A')");
m_jdbcTemplate.update("INSERT INTO ipInterface (nodeId, ipAddr, isManaged) VALUES (12, '1.1.1.1', 'M')");
m_jdbcTemplate.update("INSERT INTO ipInterface (nodeId, ipAddr, isManaged) VALUES (12, '1.1.1.2', 'M')");
final List<OnmsNode> nodes = NetworkElementFactory.getInstance(m_appContext).getNodesWithIpLike("*.*.*.*");
assertEquals("node count", 1, nodes.size());
}
Aggregations