use of org.opennms.netmgt.mock.MockResourceType in project opennms by OpenNMS.
the class RrdStatisticAttributeVisitorTest method testVisitWithNotANumberRrdAttribute.
public void testVisitWithNotANumberRrdAttribute() 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("somethingOtherThanInterfaceSnmp");
OnmsAttribute attribute = new RrdGraphAttribute("ifInOctets", "something", "something else");
attribute.setResource(new OnmsResource("1", "Node One", resourceType, Collections.singleton(attribute), ResourcePath.get("foo")));
Source source = new Source();
source.setLabel("result");
source.setResourceId(attribute.getResource().getId().toString());
source.setAttribute(attribute.getName());
source.setAggregation(attributeVisitor.getConsolidationFunction().toUpperCase());
FetchResults results = new FetchResults(new long[] {}, Collections.singletonMap("result", new double[] {}), m_endTime - m_startTime, Collections.emptyMap());
expect(m_fetchStrategy.fetch(m_startTime, m_endTime, 1, 0, null, null, Collections.singletonList(source), false)).andReturn(results);
m_mocks.replayAll();
attributeVisitor.visit(attribute);
m_mocks.verifyAll();
}
use of org.opennms.netmgt.mock.MockResourceType in project opennms by OpenNMS.
the class RrdStatisticAttributeVisitorTest method testVisitTwice.
public void testVisitTwice() throws Exception {
final RrdStatisticAttributeVisitor attributeVisitor1 = new RrdStatisticAttributeVisitor();
attributeVisitor1.setFetchStrategy(m_fetchStrategy);
attributeVisitor1.setConsolidationFunction("AVERAGE");
attributeVisitor1.setStartTime(m_startTime);
attributeVisitor1.setEndTime(m_endTime);
attributeVisitor1.setStatisticVisitor(m_statisticVisitor);
attributeVisitor1.afterPropertiesSet();
final RrdStatisticAttributeVisitor attributeVisitor2 = new RrdStatisticAttributeVisitor();
attributeVisitor2.setFetchStrategy(m_fetchStrategy);
attributeVisitor2.setConsolidationFunction("AVERAGE");
attributeVisitor2.setStartTime(m_startTime);
attributeVisitor2.setEndTime(m_endTime);
attributeVisitor2.setStatisticVisitor(m_statisticVisitor);
attributeVisitor2.afterPropertiesSet();
MockResourceType resourceType = new MockResourceType();
resourceType.setName("interfaceSnmp");
OnmsAttribute attribute = new RrdGraphAttribute("ifInOctets", "something", "something else");
attribute.setResource(new OnmsResource("1", "Node One", resourceType, Collections.singleton(attribute), ResourcePath.get("foo")));
Source source = new Source();
source.setLabel("result");
source.setResourceId(attribute.getResource().getId().toString());
source.setAttribute(attribute.getName());
source.setAggregation(attributeVisitor1.getConsolidationFunction().toUpperCase());
expect(m_fetchStrategy.fetch(m_startTime, m_endTime, 1, 0, null, null, Collections.singletonList(source), false)).andReturn(new FetchResults(new long[] { m_startTime }, Collections.singletonMap("result", new double[] { 1.0 }), m_endTime - m_startTime, Collections.emptyMap()));
m_statisticVisitor.visit(attribute, 1.0);
expect(m_fetchStrategy.fetch(m_startTime, m_endTime, 1, 0, null, null, Collections.singletonList(source), false)).andReturn(new FetchResults(new long[] { m_startTime }, Collections.singletonMap("result", new double[] { 2.0 }), m_endTime - m_startTime, Collections.emptyMap()));
m_statisticVisitor.visit(attribute, 2.0);
m_mocks.replayAll();
attributeVisitor1.visit(attribute);
attributeVisitor2.visit(attribute);
m_mocks.verifyAll();
}
use of org.opennms.netmgt.mock.MockResourceType in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testGetPrefabGraphsForResourceWithSuppressUnused.
@Test
public void testGetPrefabGraphsForResourceWithSuppressUnused() {
MockResourceType resourceType = new MockResourceType();
resourceType.setName("interface");
HashSet<OnmsAttribute> attributes = new HashSet<OnmsAttribute>(0);
attributes.add(new RrdGraphAttribute("ifHCInOctets", "", ""));
attributes.add(new RrdGraphAttribute("ifHCOutOctets", "", ""));
attributes.add(new ExternalValueAttribute("ifSpeed", ""));
OnmsResource resource = new OnmsResource("node", "1", resourceType, attributes, ResourcePath.get("foo"));
PrefabGraph[] graphs = m_dao.getPrefabGraphsForResource(resource);
assertEquals("prefab graph array size", 1, graphs.length);
assertEquals("prefab graph[0] name", "mib2.HCbits", graphs[0].getName());
}
use of org.opennms.netmgt.mock.MockResourceType in project opennms by OpenNMS.
the class ResourceTreeWalkerTest method testWalkTopLevel.
public void testWalkTopLevel() {
ResourceTreeWalker walker = new ResourceTreeWalker();
walker.setResourceDao(m_resourceDao);
walker.setVisitor(m_visitor);
m_mocks.replayAll();
walker.afterPropertiesSet();
m_mocks.verifyAll();
MockResourceType resourceType = new MockResourceType();
List<OnmsResource> resources = new ArrayList<OnmsResource>(2);
resources.add(new OnmsResource("1", "Node One", resourceType, new HashSet<OnmsAttribute>(0), new ResourcePath("foo")));
resources.add(new OnmsResource("2", "Node Two", resourceType, new HashSet<OnmsAttribute>(0), new ResourcePath("foo")));
expect(m_resourceDao.findTopLevelResources()).andReturn(resources);
for (OnmsResource resource : resources) {
m_visitor.visit(resource);
}
m_mocks.replayAll();
walker.walk();
m_mocks.verifyAll();
}
use of org.opennms.netmgt.mock.MockResourceType in project opennms by OpenNMS.
the class ResourceTypeFilteringResourceVisitorTest method testVisitWithoutMatch.
public void testVisitWithoutMatch() throws Exception {
ResourceTypeFilteringResourceVisitor filteringVisitor = new ResourceTypeFilteringResourceVisitor();
filteringVisitor.setDelegatedVisitor(m_delegatedVisitor);
filteringVisitor.setResourceTypeMatch("interfaceSnmp");
filteringVisitor.afterPropertiesSet();
MockResourceType resourceType = new MockResourceType();
resourceType.setName("something other than interfaceSnmp");
OnmsResource resource = new OnmsResource("1", "Node One", resourceType, new HashSet<OnmsAttribute>(0), new ResourcePath("foo"));
m_mocks.replayAll();
filteringVisitor.visit(resource);
m_mocks.verifyAll();
}
Aggregations