use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class DaoWebOutageRepositoryIT method testGetOutage.
@Test
// Relies on specific IDs so we need a fresh database
@JUnitTemporaryDatabase
public void testGetOutage() {
Outage outage = m_daoOutageRepo.getOutage(1);
assertNotNull(outage);
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class DaoWebOutageRepositoryIT method testGetOutageSummaries.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
public void testGetOutageSummaries() {
OutageSummary[] summaries = m_daoOutageRepo.getMatchingOutageSummaries(new OutageCriteria());
assertEquals("there should be 2 outage summary in the default (current) outage criteria match", 2, summaries.length);
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class HibernateCriteriaConverterIT method testDistinctQuery.
@Test
@JUnitTemporaryDatabase
public void testDistinctQuery() {
List<OnmsNode> nodes = null;
final CriteriaBuilder cb = new CriteriaBuilder(OnmsNode.class);
cb.isNotNull("id").distinct();
cb.eq("label", "node1").join("ipInterfaces", "ipInterface", JoinType.LEFT_JOIN).eq("ipInterface.ipAddress", "192.168.1.1");
nodes = m_nodeDao.findMatching(cb.toCriteria());
assertEquals(1, nodes.size());
assertEquals(Integer.valueOf(1), nodes.get(0).getId());
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class UpsertIT method testUpdate.
@Test
@JUnitTemporaryDatabase
public void testUpdate() {
String oldIfName = "eth0";
String newIfName = "newIf0";
assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, oldIfName));
assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, newIfName));
// add non existent snmpiface
OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
snmpIface.setIfIndex(2);
snmpIface.setIfName(newIfName);
m_upsertService.upsert(m_populator.getNode1().getId(), snmpIface, 0);
assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, oldIfName));
assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, newIfName));
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class HibernateCriteriaConverterIT method testNodeIlikeQuery.
@Test
@JUnitTemporaryDatabase
public void testNodeIlikeQuery() {
final CriteriaBuilder cb = new CriteriaBuilder(OnmsNode.class);
cb.isNotNull("id").eq("label", "node1").alias("ipInterfaces", "iface").ilike("iface.ipAddress", "1%");
final List<OnmsNode> nodes = m_nodeDao.findMatching(cb.toCriteria());
assertEquals(3, nodes.size());
}
Aggregations