Search in sources :

Example 31 with JUnitTemporaryDatabase

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);
}
Also used : OnmsOutage(org.opennms.netmgt.model.OnmsOutage) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 32 with JUnitTemporaryDatabase

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);
}
Also used : OutageSummary(org.opennms.netmgt.model.outage.OutageSummary) OutageCriteria(org.opennms.web.outage.filter.OutageCriteria) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 33 with JUnitTemporaryDatabase

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());
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 34 with JUnitTemporaryDatabase

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));
}
Also used : OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 35 with JUnitTemporaryDatabase

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());
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Aggregations

JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)109 Test (org.junit.Test)105 OnmsNode (org.opennms.netmgt.model.OnmsNode)21 Date (java.util.Date)20 JSONObject (org.json.JSONObject)18 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)18 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)17 Transactional (org.springframework.transaction.annotation.Transactional)14 FileInputStream (java.io.FileInputStream)10 AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)10 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)9 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)8 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)7 AlarmIdFilter (org.opennms.web.alarm.filter.AlarmIdFilter)7 HashMap (java.util.HashMap)6 OutageCriteria (org.opennms.web.outage.filter.OutageCriteria)6 Matcher (java.util.regex.Matcher)4 Pattern (java.util.regex.Pattern)4 JSONArray (org.json.JSONArray)4 AcknowledgedByFilter (org.opennms.web.alarm.filter.AcknowledgedByFilter)4