Search in sources :

Example 31 with MockResourceType

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

the class DefaultRrdDaoTest method testFetchLastValue.

public void testFetchLastValue() throws Exception {
    String rrdDir = "snmp" + File.separator + "1" + File.separator + "eth0";
    String rrdFile = "ifInOctets.jrb";
    OnmsResource topResource = new OnmsResource("1", "Node One", new MockResourceType(), new HashSet<OnmsAttribute>(0), new ResourcePath("foo"));
    OnmsAttribute attribute = new RrdGraphAttribute("ifInOctets", rrdDir, rrdFile);
    HashSet<OnmsAttribute> attributeSet = new HashSet<OnmsAttribute>(1);
    attributeSet.add(attribute);
    MockResourceType childResourceType = new MockResourceType();
    OnmsResource childResource = new OnmsResource("eth0", "Interface One: eth0", childResourceType, attributeSet, new ResourcePath("foo"));
    childResource.setParent(topResource);
    int interval = 300000;
    Double expectedValue = new Double(1.0);
    String fullRrdFilePath = m_dao.getRrdBaseDirectory().getAbsolutePath() + File.separator + rrdDir + File.separator + rrdFile;
    expect(m_rrdStrategy.fetchLastValue(fullRrdFilePath, attribute.getName(), interval)).andReturn(expectedValue);
    m_mocks.replayAll();
    Double value = m_dao.getLastFetchValue(attribute, interval);
    m_mocks.verifyAll();
    assertNotNull("last fetched value must not be null, but was null", value);
    assertEquals("last fetched value", expectedValue, value);
}
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)

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