Search in sources :

Example 1 with Summary

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());
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) FilterDao(org.opennms.netmgt.filter.api.FilterDao) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsResource(org.opennms.netmgt.model.OnmsResource) ModelAndView(org.springframework.web.servlet.ModelAndView) HttpServletResponse(javax.servlet.http.HttpServletResponse) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Summary(org.opennms.netmgt.config.attrsummary.Summary) ResourceDao(org.opennms.netmgt.dao.api.ResourceDao) SummarySpecification(org.opennms.web.svclayer.model.SummarySpecification) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Test (org.junit.Test)1 Summary (org.opennms.netmgt.config.attrsummary.Summary)1 NodeDao (org.opennms.netmgt.dao.api.NodeDao)1 ResourceDao (org.opennms.netmgt.dao.api.ResourceDao)1 FilterDao (org.opennms.netmgt.filter.api.FilterDao)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 OnmsResource (org.opennms.netmgt.model.OnmsResource)1 SummarySpecification (org.opennms.web.svclayer.model.SummarySpecification)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1