Search in sources :

Example 96 with OnmsResource

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);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsResource(org.opennms.netmgt.model.OnmsResource) File(java.io.File) Test(org.junit.Test)

Example 97 with OnmsResource

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);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsResource(org.opennms.netmgt.model.OnmsResource) File(java.io.File) Test(org.junit.Test)

Example 98 with OnmsResource

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);
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) Test(org.junit.Test)

Example 99 with OnmsResource

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);
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) Test(org.junit.Test)

Example 100 with OnmsResource

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());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsResource(org.opennms.netmgt.model.OnmsResource) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) LocationMonitorIpInterface(org.opennms.netmgt.model.LocationMonitorIpInterface) File(java.io.File) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

OnmsResource (org.opennms.netmgt.model.OnmsResource)143 Test (org.junit.Test)54 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)40 MockResourceType (org.opennms.netmgt.mock.MockResourceType)31 OnmsNode (org.opennms.netmgt.model.OnmsNode)28 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)23 File (java.io.File)22 ResourcePath (org.opennms.netmgt.model.ResourcePath)19 ArrayList (java.util.ArrayList)14 HashSet (java.util.HashSet)14 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)12 HashMap (java.util.HashMap)11 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)11 ResourceId (org.opennms.netmgt.model.ResourceId)11 Date (java.util.Date)10 Source (org.opennms.netmgt.measurements.model.Source)8 LinkedList (java.util.LinkedList)7 FetchResults (org.opennms.netmgt.measurements.api.FetchResults)7 ExternalValueAttribute (org.opennms.netmgt.model.ExternalValueAttribute)7 ModelAndView (org.springframework.web.servlet.ModelAndView)7