use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class NodeSnmpResourceTypeTest method canGetChildByName.
@Test
public void canGetChildByName() throws IOException {
final RrdStrategy<?, ?> rrdStrategy = new NullRrdStrategy();
final FilesystemResourceStorageDao resourceStorageDao = new FilesystemResourceStorageDao();
resourceStorageDao.setRrdDirectory(tempFolder.getRoot());
resourceStorageDao.setRrdStrategy(rrdStrategy);
File nodeSnmpFolder = tempFolder.newFolder("snmp", "1");
File rrd = new File(nodeSnmpFolder, "ds" + rrdStrategy.getDefaultFileExtension());
rrd.createNewFile();
final NodeSnmpResourceType nodeSnmpResourceType = new NodeSnmpResourceType(resourceStorageDao);
final OnmsResource parent = getNodeResource(1);
final OnmsResource resource = nodeSnmpResourceType.getChildByName(parent, new String(""));
assertEquals("node[1].nodeSnmp[]", resource.getId().toString());
assertEquals(parent, resource.getParent());
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ResourceAttributeFilteringResourceVisitorTest method testVisitWithStringPropertyMatch.
public void testVisitWithStringPropertyMatch() throws Exception {
ResourceAttributeFilteringResourceVisitor filteringVisitor = new ResourceAttributeFilteringResourceVisitor();
filteringVisitor.setDelegatedVisitor(m_delegatedVisitor);
filteringVisitor.setResourceAttributeKey("ifSpeed");
filteringVisitor.setResourceAttributeValueMatch("1000000000");
filteringVisitor.afterPropertiesSet();
Set<OnmsAttribute> attributes = new HashSet<OnmsAttribute>(1);
attributes.add(new StringPropertyAttribute("ifSpeed", "1000000000"));
MockResourceType resourceType = new MockResourceType();
resourceType.setName("interfaceSnmp");
OnmsResource resource = new OnmsResource("1", "Node One", resourceType, attributes, ResourcePath.get("foo"));
// Expect
m_delegatedVisitor.visit(resource);
m_mocks.replayAll();
filteringVisitor.visit(resource);
m_mocks.verifyAll();
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ResourceAttributeFilteringResourceVisitorTest method testVisitWithExternalValueMatch.
public void testVisitWithExternalValueMatch() throws Exception {
ResourceAttributeFilteringResourceVisitor filteringVisitor = new ResourceAttributeFilteringResourceVisitor();
filteringVisitor.setDelegatedVisitor(m_delegatedVisitor);
filteringVisitor.setResourceAttributeKey("ifSpeed");
filteringVisitor.setResourceAttributeValueMatch("1000000000");
filteringVisitor.afterPropertiesSet();
Set<OnmsAttribute> attributes = new HashSet<OnmsAttribute>(1);
attributes.add(new ExternalValueAttribute("ifSpeed", "1000000000"));
MockResourceType resourceType = new MockResourceType();
resourceType.setName("interfaceSnmp");
OnmsResource resource = new OnmsResource("1", "Node One", resourceType, attributes, ResourcePath.get("foo"));
// Expect
m_delegatedVisitor.visit(resource);
m_mocks.replayAll();
filteringVisitor.visit(resource);
m_mocks.verifyAll();
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ResourceAttributeFilteringResourceVisitorTest method testVisitWithoutMatch.
public void testVisitWithoutMatch() throws Exception {
ResourceAttributeFilteringResourceVisitor filteringVisitor = new ResourceAttributeFilteringResourceVisitor();
filteringVisitor.setDelegatedVisitor(m_delegatedVisitor);
filteringVisitor.setResourceAttributeKey("ifSpeed");
filteringVisitor.setResourceAttributeValueMatch("1000000000");
filteringVisitor.afterPropertiesSet();
MockResourceType resourceType = new MockResourceType();
resourceType.setName("something other than interfaceSnmp");
OnmsResource resource = new OnmsResource("1", "Node One", resourceType, new HashSet<OnmsAttribute>(0), ResourcePath.get("foo"));
m_mocks.replayAll();
filteringVisitor.visit(resource);
m_mocks.verifyAll();
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ResourceTypeFilteringResourceVisitorTest method testVisitWithMatch.
public void testVisitWithMatch() throws Exception {
ResourceTypeFilteringResourceVisitor filteringVisitor = new ResourceTypeFilteringResourceVisitor();
filteringVisitor.setDelegatedVisitor(m_delegatedVisitor);
filteringVisitor.setResourceTypeMatch("interfaceSnmp");
filteringVisitor.afterPropertiesSet();
MockResourceType resourceType = new MockResourceType();
resourceType.setName("interfaceSnmp");
OnmsResource resource = new OnmsResource("1", "Node One", resourceType, new HashSet<OnmsAttribute>(0), new ResourcePath("foo"));
m_delegatedVisitor.visit(resource);
m_mocks.replayAll();
filteringVisitor.visit(resource);
m_mocks.verifyAll();
}
Aggregations