Search in sources :

Example 81 with OnmsResource

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();
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) ArrayList(java.util.ArrayList) MockResourceType(org.opennms.netmgt.mock.MockResourceType) HashSet(java.util.HashSet)

Example 82 with OnmsResource

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();
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) OnmsAttribute(org.opennms.netmgt.model.OnmsAttribute) MockResourceType(org.opennms.netmgt.mock.MockResourceType)

Example 83 with OnmsResource

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;
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) OnmsAttribute(org.opennms.netmgt.model.OnmsAttribute) RrdGraphAttribute(org.opennms.netmgt.model.RrdGraphAttribute) MockResourceType(org.opennms.netmgt.mock.MockResourceType) HashSet(java.util.HashSet)

Example 84 with OnmsResource

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

Example 85 with OnmsResource

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;
}
Also used : LazySet(org.opennms.core.collections.LazySet) OnmsResource(org.opennms.netmgt.model.OnmsResource) OnmsAttribute(org.opennms.netmgt.model.OnmsAttribute)

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