Search in sources :

Example 81 with OnmsNode

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

the class InterfaceToNodeCacheDaoImplIT method setUp.

@Before
public void setUp() throws Exception {
    m_databasePopulator.populateDatabase();
    m_cache.dataSourceSync();
    OnmsNode n = new OnmsNode(m_databasePopulator.getMonitoringLocationDao().getDefaultLocation(), "my-new-node");
    n.setForeignSource("junit");
    n.setForeignId("10001");
    OnmsIpInterface iface = new OnmsIpInterface(InetAddress.getByName("192.168.1.3"), n);
    iface.setIsManaged("M");
    iface.setIsSnmpPrimary(PrimaryType.PRIMARY);
    OnmsSnmpInterface snmpIf = new OnmsSnmpInterface(n, 1001);
    iface.setSnmpInterface(snmpIf);
    snmpIf.getIpInterfaces().add(iface);
    n.addIpInterface(iface);
    m_databasePopulator.getNodeDao().save(n);
    m_testNodeId = n.getId();
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) Before(org.junit.Before)

Example 82 with OnmsNode

use of org.opennms.netmgt.model.OnmsNode 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)

Example 83 with OnmsNode

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

the class OutageDaoIT method testDuplicateOutages.

@Test
@Transactional
public void testDuplicateOutages() {
    for (final OnmsNode node : m_nodeDao.findAll()) {
        m_nodeDao.delete(node);
    }
    OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "shoes");
    m_nodeDao.save(node);
    insertEntitiesAndOutage("172.16.1.1", "ICMP", node);
    insertEntitiesAndOutage("192.0.2.1", "ICMP", node);
    node = new OnmsNode(m_locationDao.getDefaultLocation(), "megaphone");
    m_nodeDao.save(node);
    insertEntitiesAndOutage("172.16.1.2", "ICMP", node);
    insertEntitiesAndOutage("172.17.1.2", "ICMP", node);
    insertEntitiesAndOutage("172.18.1.2", "ICMP", node);
    node = new OnmsNode(m_locationDao.getDefaultLocation(), "grunties");
    m_nodeDao.save(node);
    insertEntitiesAndOutage("172.16.1.3", "ICMP", node);
    List<OutageSummary> outages = m_outageDao.getNodeOutageSummaries(0);
    System.err.println(outages);
    assertEquals(3, outages.size());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OutageSummary(org.opennms.netmgt.model.outage.OutageSummary) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 84 with OnmsNode

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

the class RrdPersistOperationBuilderTest method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    m_rrdStrategy = new JRobinRrdStrategy();
    m_fileAnticipator = new FileAnticipator();
    m_intf = new OnmsIpInterface();
    m_node = new OnmsNode();
    m_node.setId(1);
    m_intf.setNode(m_node);
    m_intf.setIpAddress(InetAddressUtils.addr("1.1.1.1"));
    m_intf.setId(27);
    m_ifDao = EasyMock.createMock(IpInterfaceDao.class);
    EasyMock.expect(m_ifDao.load(m_intf.getId())).andReturn(m_intf).anyTimes();
    EasyMock.replay(m_ifDao);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) Before(org.junit.Before)

Example 85 with OnmsNode

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

the class MeasurementsRestServiceITCase method setUp.

public void setUp() {
    BeanUtils.assertAutowiring(this);
    OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "node1");
    node.setId(1);
    m_nodeDao.save(node);
    m_nodeDao.flush();
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode)

Aggregations

OnmsNode (org.opennms.netmgt.model.OnmsNode)496 Test (org.junit.Test)209 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)116 Transactional (org.springframework.transaction.annotation.Transactional)84 ArrayList (java.util.ArrayList)52 Date (java.util.Date)49 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)38 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)38 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)38 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)37 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)36 InetAddress (java.net.InetAddress)35 Before (org.junit.Before)32 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)31 OnmsResource (org.opennms.netmgt.model.OnmsResource)28 HashMap (java.util.HashMap)27 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)26 File (java.io.File)25 List (java.util.List)25 Path (javax.ws.rs.Path)23