Search in sources :

Example 1 with MockResourceType

use of org.opennms.netmgt.mock.MockResourceType in project opennms by OpenNMS.

the class PropertiesGraphDaoIT method testGetPrefabGraphsForResource.

@Test
public void testGetPrefabGraphsForResource() {
    MockResourceType resourceType = new MockResourceType();
    resourceType.setName("interface");
    HashSet<OnmsAttribute> attributes = new HashSet<OnmsAttribute>(0);
    attributes.add(new RrdGraphAttribute("ifInOctets", "", ""));
    attributes.add(new RrdGraphAttribute("ifOutOctets", "", ""));
    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.bits", graphs[0].getName());
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) PrefabGraph(org.opennms.netmgt.model.PrefabGraph) OnmsAttribute(org.opennms.netmgt.model.OnmsAttribute) RrdGraphAttribute(org.opennms.netmgt.model.RrdGraphAttribute) ExternalValueAttribute(org.opennms.netmgt.model.ExternalValueAttribute) MockResourceType(org.opennms.netmgt.mock.MockResourceType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with MockResourceType

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

Example 3 with MockResourceType

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

Example 4 with MockResourceType

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

Example 5 with MockResourceType

use of org.opennms.netmgt.mock.MockResourceType 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();
}
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)

Aggregations

MockResourceType (org.opennms.netmgt.mock.MockResourceType)31 OnmsResource (org.opennms.netmgt.model.OnmsResource)31 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)30 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)16 HashSet (java.util.HashSet)13 ResourcePath (org.opennms.netmgt.model.ResourcePath)9 ExternalValueAttribute (org.opennms.netmgt.model.ExternalValueAttribute)6 HashMap (java.util.HashMap)5 FetchResults (org.opennms.netmgt.measurements.api.FetchResults)5 Source (org.opennms.netmgt.measurements.model.Source)5 AttributeStatistic (org.opennms.netmgt.model.AttributeStatistic)4 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)4 Test (org.junit.Test)3 TreeMap (java.util.TreeMap)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 StringPropertyAttribute (org.opennms.netmgt.model.StringPropertyAttribute)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 RrdDb (org.jrobin.core.RrdDb)1 RrdDef (org.jrobin.core.RrdDef)1