use of org.opennms.netmgt.config.attrsummary.Summary in project opennms by OpenNMS.
the class RrdSummaryControllerTest method canGenerateEmptySummary.
/**
* Verifies that an empty summary can be generated so an existing
* node without any resources.
*/
@Test
public void canGenerateEmptySummary() {
// Return a single node when called using the given filter
String rule = "ipaddr iplike 172.20.1.1";
FilterDao filterDao = mock(FilterDao.class);
when(filterDao.getNodeMap(rule)).thenReturn(ImmutableSortedMap.of(1, "node1"));
OnmsNode node = mock(OnmsNode.class);
NodeDao nodeDao = mock(NodeDao.class);
when(nodeDao.load(1)).thenReturn(node);
OnmsResource resource = mock(OnmsResource.class);
ResourceDao resourceDao = mock(ResourceDao.class);
when(resourceDao.getResourceForNode(node)).thenReturn(resource);
// Use our mocks
m_rrdSummaryService.setFilterDao(filterDao);
m_rrdSummaryService.setNodeDao(nodeDao);
m_rrdSummaryService.setResourceDao(resourceDao);
// Building the summary spec.
SummarySpecification summarySpec = new SummarySpecification();
summarySpec.setFilterRule("ipaddr iplike 172.20.1.1");
summarySpec.setStartTime(1472746964);
summarySpec.setEndTime(1473265364);
summarySpec.setAttributeSieve(".*");
// Invoke the controller
HttpServletResponse response = new MockHttpServletResponse();
ModelAndView mv = m_controller.processFormSubmission(response, summarySpec);
Summary summary = (Summary) mv.getModel().get("summary");
// Verify the response
assertEquals(0, summary.getResources().size());
}
Aggregations