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);
}
Aggregations