Search in sources :

Example 36 with RrdGraphAttribute

use of org.opennms.netmgt.model.RrdGraphAttribute 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

RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)36 OnmsResource (org.opennms.netmgt.model.OnmsResource)23 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)21 MockResourceType (org.opennms.netmgt.mock.MockResourceType)16 HashSet (java.util.HashSet)11 Source (org.opennms.netmgt.measurements.model.Source)9 FetchResults (org.opennms.netmgt.measurements.api.FetchResults)8 ResourcePath (org.opennms.netmgt.model.ResourcePath)8 Map (java.util.Map)5 ExternalValueAttribute (org.opennms.netmgt.model.ExternalValueAttribute)5 OnmsNode (org.opennms.netmgt.model.OnmsNode)5 ResourceId (org.opennms.netmgt.model.ResourceId)5 File (java.io.File)4 List (java.util.List)4 Test (org.junit.Test)4 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)4 LinkedHashSet (java.util.LinkedHashSet)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Optional (com.google.common.base.Optional)2 Throwables (com.google.common.base.Throwables)2