use of org.opennms.netmgt.model.AttributeStatistic in project opennms by OpenNMS.
the class TopNAttributeStatisticVisitorTest method testVisitGetResults.
public void testVisitGetResults() throws Exception {
BottomNAttributeStatisticVisitor visitor = new TopNAttributeStatisticVisitor();
visitor.setCount(20);
visitor.afterPropertiesSet();
Map<OnmsAttribute, Double> attributes = new HashMap<OnmsAttribute, Double>();
attributes.put(new MockAttribute("foo"), 0.0);
OnmsResource resource = new OnmsResource("1", "Node One", new MockResourceType(), attributes.keySet(), ResourcePath.get("foo"));
resource.getAttributes();
for (Entry<OnmsAttribute, Double> entry : attributes.entrySet()) {
visitor.visit(entry.getKey(), entry.getValue());
}
SortedSet<AttributeStatistic> top = visitor.getResults();
assertNotNull("topN list should not be null", top);
assertEquals("topN list size", 1, top.size());
int i = 0;
for (AttributeStatistic stat : top) {
assertEquals("topN[" + i + "] value", 0.0, stat.getStatistic());
}
}
use of org.opennms.netmgt.model.AttributeStatistic in project opennms by OpenNMS.
the class StandardOutputReportPersister method persist.
/** {@inheritDoc} */
@Override
public void persist(ReportInstance report) {
System.out.println("Top " + report.getCount() + " " + report.getAttributeMatch() + " data sources on resources of type " + report.getResourceTypeMatch() + " from " + new Date(report.getStartTime()) + " to " + new Date(report.getEndTime()));
SortedSet<AttributeStatistic> top = report.getResults();
for (AttributeStatistic stat : top) {
System.out.println(stat.getAttribute().getResource().getId() + "/" + stat.getAttribute().getName() + ": " + stat.getStatistic());
}
System.out.println("");
}
Aggregations