use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class DefaultResourceDaoTest method testGetTopLevelResourceNodeSourceExists.
@Test
public void testGetTopLevelResourceNodeSourceExists() throws Exception {
OnmsNode node = createNode();
expect(m_nodeDao.get("source1:123")).andReturn(node).times(1);
File responseDir = m_fileAnticipator.tempDir("snmp");
File forSrcDir = m_fileAnticipator.tempDir(responseDir, "fs");
File sourceDir = m_fileAnticipator.tempDir(forSrcDir, "source1");
File idDir = m_fileAnticipator.tempDir(sourceDir, "123");
m_fileAnticipator.tempFile(idDir, "foo" + m_rrdFileExtension);
m_easyMockUtils.replayAll();
OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("nodeSource", "source1:123"));
m_easyMockUtils.verifyAll();
assertNotNull("Resource should not be null", resource);
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class DefaultResourceDaoTest method testGetResourceForNodeWithData.
@Test
public void testGetResourceForNodeWithData() throws Exception {
OnmsNode node = createNode();
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.getResourceForNode(node);
m_easyMockUtils.verifyAll();
assertNotNull("Resource should exist", resource);
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class DefaultResourceDaoTest method testGetTopLevelResourceDomainDoesNotExistInCollectdConfig.
@Test
public void testGetTopLevelResourceDomainDoesNotExistInCollectdConfig() {
m_easyMockUtils.replayAll();
OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("domain", "bogus"));
m_easyMockUtils.verifyAll();
assertNull("Resource should be null", resource);
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class DefaultResourceDaoTest method testGetTopLevelResourceWithInvalidResourceType.
@Test
public void testGetTopLevelResourceWithInvalidResourceType() {
m_easyMockUtils.replayAll();
OnmsResource resource = m_resourceDao.getResourceById(ResourceId.get("bogus", null));
m_easyMockUtils.verifyAll();
assertNull("Resource should be null", resource);
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class DefaultResourceDaoTest method testFindNodeResourcesWithDistributedResponseTime.
@Test
public void testFindNodeResourcesWithDistributedResponseTime() throws Exception {
List<OnmsNode> nodes = new LinkedList<OnmsNode>();
OnmsNode node = createNode();
OnmsIpInterface ip = createIpInterface();
node.addIpInterface(ip);
nodes.add(node);
expect(m_nodeDao.findAll()).andReturn(nodes);
File response = m_fileAnticipator.tempDir("response");
File distributed = m_fileAnticipator.tempDir(response, "distributed");
File monitor = m_fileAnticipator.tempDir(distributed, LOCATION_MONITOR_ID);
File ipDir = m_fileAnticipator.tempDir(monitor, "192.168.1.1");
m_fileAnticipator.tempFile(ipDir, "icmp" + m_rrdFileExtension);
expect(m_resourceTypesDao.getLastUpdate()).andReturn(m_lastUpdateTime);
// Setup the status to match the path on disk
OnmsLocationMonitor locMon = new OnmsLocationMonitor();
locMon.setId(LOCATION_MONITOR_ID);
OnmsIpInterface ipIntf = new OnmsIpInterface();
ipIntf.setIpAddress(InetAddress.getByName("192.168.1.1"));
LocationMonitorIpInterface locMonIpIntf = new LocationMonitorIpInterface(locMon, ipIntf);
expect(m_locationMonitorDao.findStatusChangesForNodeForUniqueMonitorAndInterface(node.getId())).andReturn(Collections.singleton(locMonIpIntf)).anyTimes();
m_easyMockUtils.replayAll();
List<OnmsResource> resources = m_resourceDao.findTopLevelResources();
m_easyMockUtils.verifyAll();
assertNotNull("Resource list should not be null", resources);
assertEquals("Resource list size", 1, resources.size());
}
Aggregations