use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class RrdStatisticAttributeVisitorTest method testVisitWithNonRrdAttribute.
public void testVisitWithNonRrdAttribute() throws Exception {
RrdStatisticAttributeVisitor attributeVisitor = new RrdStatisticAttributeVisitor();
attributeVisitor.setFetchStrategy(m_fetchStrategy);
attributeVisitor.setConsolidationFunction("AVERAGE");
attributeVisitor.setStartTime(m_startTime);
attributeVisitor.setEndTime(m_endTime);
attributeVisitor.setStatisticVisitor(m_statisticVisitor);
attributeVisitor.afterPropertiesSet();
MockResourceType resourceType = new MockResourceType();
resourceType.setName("something other than interfaceSnmp");
OnmsAttribute attribute = new StringPropertyAttribute("ifInOctets", "one billion octets!");
attribute.setResource(new OnmsResource("1", "Node One", resourceType, Collections.singleton(attribute), ResourcePath.get("foo")));
m_mocks.replayAll();
attributeVisitor.visit(attribute);
m_mocks.verifyAll();
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ResponseTimeResourceTypeTest method canGetResourcesForNode.
@Test
public void canGetResourcesForNode() throws IOException {
expect(node.getIpInterfaces()).andReturn(ipInterfaces);
expect(node.getLocation()).andReturn(null);
expect(ipInterface.getIpAddress()).andReturn(InetAddress.getByName("127.0.0.1")).atLeastOnce();
replay(node, ipInterface);
NodeResourceType nodeResourceType = new NodeResourceType(resourceDao, nodeDao);
OnmsResource nodeResource = new OnmsResource("1", "Node", nodeResourceType, Collections.emptySet(), ResourcePath.get("foo"));
nodeResource.setEntity(node);
List<OnmsResource> resources = responseTimeResourceType.getResourcesForParent(nodeResource);
verify(node, ipInterface);
assertEquals(1, resources.size());
assertEquals("127.0.0.1", resources.get(0).getName());
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ResponseTimeResourceTypeTest method canGetResourcesForNodeAtLocation.
@Test
public void canGetResourcesForNodeAtLocation() throws IOException {
OnmsMonitoringLocation location = new OnmsMonitoringLocation();
location.setLocationName(NON_DEFAULT_LOCATION_NAME);
expect(node.getIpInterfaces()).andReturn(ipInterfaces);
expect(node.getLocation()).andReturn(location).atLeastOnce();
expect(ipInterface.getIpAddress()).andReturn(InetAddress.getByName("127.0.0.1")).atLeastOnce();
replay(node, ipInterface);
NodeResourceType nodeResourceType = new NodeResourceType(resourceDao, nodeDao);
OnmsResource nodeResource = new OnmsResource("1", "Node", nodeResourceType, Collections.emptySet(), ResourcePath.get("foo"));
nodeResource.setEntity(node);
List<OnmsResource> resources = responseTimeResourceType.getResourcesForParent(nodeResource);
verify(node, ipInterface);
assertEquals(1, resources.size());
assertEquals("127.0.0.1", resources.get(0).getName());
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class RrdResourceAttributeUtilsTest method testLoadPropertiesEmpty.
@Test
public void testLoadPropertiesEmpty() throws Exception {
OnmsResource childResource = createResource();
createPropertiesFile(childResource, "", false);
Properties p = RrdResourceAttributeUtils.getStringProperties(m_fileAnticipator.getTempDir(), "snmp/1/eth0");
assertNotNull("properties should not be null", p);
assertEquals("properties size", 0, p.size());
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ReportDefinitionTest method testUnfilteredResourceAttributeFilteringWithNoMatch.
public void testUnfilteredResourceAttributeFilteringWithNoMatch() throws Exception {
MockResourceType resourceType = new MockResourceType();
resourceType.setName("interfaceSnmp");
OnmsAttribute attribute = new RrdGraphAttribute("IfInOctets", "something", "something else");
OnmsResource resource = new OnmsResource("1", "Node One", resourceType, Collections.singleton(attribute), ResourcePath.get("foo"));
EasyMock.expect(m_resourceDao.findTopLevelResources()).andReturn(Collections.singletonList(resource));
ReportDefinition def = createReportDefinition();
def.setResourceAttributeKey("ifSpeed");
def.setResourceAttributeValueMatch("100000000");
ReportInstance report = def.createReport(m_nodeDao, m_resourceDao, m_fetchStrategy, m_filterDao);
m_mocks.replayAll();
report.walk();
assertEquals("results size", 0, report.getResults().size());
}
Aggregations