use of org.opennms.netmgt.dao.support.TopNAttributeStatisticVisitor in project opennms by OpenNMS.
the class StatsdValuesIT method testValue.
@Test
@Transactional
public void testValue() throws Exception {
final OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "node1");
node.setId(1);
m_nodeDao.save(node);
m_nodeDao.flush();
final OnmsResource resource = Iterables.getOnlyElement(m_resourceDao.getResourceForNode(node).getChildResources());
final OnmsAttribute attribute = resource.getRrdGraphAttributes().get("ifInOctets");
final double statistic = m_rrdDao.getPrintValue(attribute, "AVERAGE", 1414602000000L, 1417046400000L);
final TopNAttributeStatisticVisitor result = new TopNAttributeStatisticVisitor();
result.setCount(1);
final RrdStatisticAttributeVisitor visitor = new RrdStatisticAttributeVisitor();
visitor.setFetchStrategy(m_fetchStrategy);
visitor.setConsolidationFunction("AVERAGE");
visitor.setStartTime(1414602000000L);
visitor.setEndTime(1417046400000L);
visitor.setStatisticVisitor(result);
visitor.afterPropertiesSet();
visitor.visit(attribute);
Assert.assertNotNull(result.getResults());
Assert.assertEquals(1, result.getResults().size());
Assert.assertNotNull(result.getResults().first());
Assert.assertEquals(attribute, result.getResults().first().getAttribute());
Assert.assertEquals(statistic, result.getResults().first().getStatistic(), 0.5);
}
Aggregations