Search in sources :

Example 41 with OnmsNode

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

the class GenericIndexResourceTypeTest method getNodeResource.

private OnmsResource getNodeResource(int nodeId) {
    final NodeResourceType nodeResourceType = new NodeResourceType(m_resourceDao, m_nodeDao);
    OnmsNode node = new OnmsNode();
    node.setId(nodeId);
    node.setLabel("Node" + nodeId);
    return nodeResourceType.createResourceForNode(node);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode)

Example 42 with OnmsNode

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

the class DefaultResourceDaoTest method testGetResourceByIdNewTopLevelOnly.

@Test
public void testGetResourceByIdNewTopLevelOnly() throws Exception {
    OnmsNode node = createNode();
    expect(m_nodeDao.get(node.getId().toString())).andReturn(node).times(1);
    File responseDir = m_fileAnticipator.tempDir("snmp");
    File nodeDir = m_fileAnticipator.tempDir(responseDir, node.getId().toString());
    m_fileAnticipator.tempFile(nodeDir, "foo" + m_rrdFileExtension);
    m_easyMockUtils.replayAll();
    OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("node", "1"));
    m_easyMockUtils.verifyAll();
    assertNotNull("resource should not be null", resource);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsResource(org.opennms.netmgt.model.OnmsResource) File(java.io.File) Test(org.junit.Test)

Example 43 with OnmsNode

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

the class DefaultResourceDaoTest method testGetTopLevelResourceNodeExists.

@Test
public void testGetTopLevelResourceNodeExists() throws Exception {
    OnmsNode node = createNode();
    expect(m_nodeDao.get(node.getId().toString())).andReturn(node).times(1);
    File responseDir = m_fileAnticipator.tempDir("snmp");
    File nodeDir = m_fileAnticipator.tempDir(responseDir, node.getId().toString());
    m_fileAnticipator.tempFile(nodeDir, "foo" + m_rrdFileExtension);
    m_easyMockUtils.replayAll();
    OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("node", Integer.toString(node.getId())));
    m_easyMockUtils.verifyAll();
    assertNotNull("Resource should not be null", resource);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsResource(org.opennms.netmgt.model.OnmsResource) File(java.io.File) Test(org.junit.Test)

Example 44 with OnmsNode

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

the class BasePersisterTest method setUp.

@Before
public void setUp() throws Exception {
    MockUtil.println("------------ Begin Test " + m_testName.getMethodName() + " --------------------------");
    MockLogAppender.setupLogging();
    m_fileAnticipator = new FileAnticipator();
    m_rrdStrategy = new JRobinRrdStrategy();
    m_resourceStorageDao = new FilesystemResourceStorageDao();
    m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir());
    m_intf = new OnmsIpInterface();
    m_node = new OnmsNode();
    m_node.setId(1);
    m_intf.setId(25);
    m_intf.setNode(m_node);
    m_intf.setIpAddress(InetAddressUtils.addr("1.1.1.1"));
    m_ifDao = m_easyMockUtils.createMock(IpInterfaceDao.class);
    m_serviceParams = new ServiceParameters(new HashMap<String, Object>());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) HashMap(java.util.HashMap) FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) Before(org.junit.Before)

Example 45 with OnmsNode

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

the class GenericInfoPanelItemProviderTest method setUp.

@Before
public void setUp() throws IllegalAccessException, InstantiationException {
    m_nodeDao = EasyMock.createMock(NodeDao.class);
    m_measurementsService = EasyMock.createMock(MeasurementsService.class);
    m_genericInfoPanelItemProvider = new GenericInfoPanelItemProvider(m_nodeDao, m_measurementsService);
    m_onmsNode = new OnmsNode();
    m_onmsNode.setLabel("nodeLabel");
    m_onmsNode.setId(10);
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) OnmsNode(org.opennms.netmgt.model.OnmsNode) MeasurementsService(org.opennms.netmgt.measurements.api.MeasurementsService) Before(org.junit.Before)

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