use of org.opennms.netmgt.model.OnmsResource 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.model.OnmsResource 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();
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class RrdResourceAttributeUtilsTest method createResource.
private OnmsResource createResource() {
OnmsResource topResource = new OnmsResource("1", "Node One", new MockResourceType(), new HashSet<OnmsAttribute>(0), new ResourcePath("foo"));
Set<OnmsAttribute> attributes = new HashSet<OnmsAttribute>(1);
attributes.add(new RrdGraphAttribute("foo", "1/eth0", "foo.jrb"));
OnmsResource childResource = new OnmsResource("eth0", "Interface eth0", new MockResourceType(), attributes, new ResourcePath("foo"));
childResource.setParent(topResource);
return childResource;
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ResourceTreeWalker method walk.
/**
* <p>walk</p>
*
* @param resources a {@link java.util.Collection} object.
*/
public void walk(Collection<OnmsResource> resources) {
for (OnmsResource resource : resources) {
m_visitor.visit(resource);
walk(resource.getChildResources());
}
}
use of org.opennms.netmgt.model.OnmsResource in project opennms by OpenNMS.
the class ResponseTimeResourceType method createResource.
private OnmsResource createResource(final String location, final OnmsIpInterface ipInterface, final String ipAddr, final ResourcePath path) {
final LazyResourceAttributeLoader loader = new LazyResourceAttributeLoader(m_resourceStorageDao, path);
final Set<OnmsAttribute> set = new LazySet<OnmsAttribute>(loader);
final OnmsResource resource = new OnmsResource(ipAddr, ipAddr, this, set, path);
resource.setEntity(ipInterface);
return resource;
}
Aggregations