Search in sources :

Example 1 with SimpleWebTable

use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.

the class DefaultSurveillanceServiceIntegrationIT method testCreateSurveillanceServiceTableUsingViewName.

@Test
@Transactional
public void testCreateSurveillanceServiceTableUsingViewName() {
    String viewName = "default";
    SimpleWebTable table = m_surveillanceService.createSurveillanceTable(viewName, new ProgressMonitor() {

        @Override
        public void beginNextPhase(String string) {
            System.err.println("PHASE: " + string);
        }

        @Override
        public void setPhaseCount(int i) {
        }
    });
    assertEquals("default", table.getTitle());
}
Also used : ProgressMonitor(org.opennms.web.svclayer.model.ProgressMonitor) SimpleWebTable(org.opennms.web.svclayer.model.SimpleWebTable) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SimpleWebTable

use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.

the class DefaultDistributedStatusServiceTest method testCreateStatusPutUnreportedServicesLast.

public void testCreateStatusPutUnreportedServicesLast() {
    DistributedStatusDetailsCommand command = new DistributedStatusDetailsCommand();
    Errors errors = new BindException(command, "command");
    command.setLocation(m_locationDefinition1.getLocationName());
    command.setApplication(m_application1.getName());
    expect(m_applicationDao.findByName("Application 1")).andReturn(m_application1);
    expect(m_monitoringLocationDao.get(m_locationDefinition1.getLocationName())).andReturn(m_locationDefinition1);
    expect(m_locationMonitorDao.findByLocationDefinition(m_locationDefinition1)).andReturn(Collections.singleton(m_locationMonitor1_1));
    OnmsMonitoredService httpService = findMonitoredService(m_services, m_ip, "HTTP");
    OnmsMonitoredService httpsService = findMonitoredService(m_services, m_ip, "HTTPS");
    expect(m_locationMonitorDao.getMostRecentStatusChange(m_locationMonitor1_1, httpService)).andReturn(null);
    expect(m_locationMonitorDao.getMostRecentStatusChange(m_locationMonitor1_1, httpsService)).andReturn(new OnmsLocationSpecificStatus(m_locationMonitor1_1, httpsService, PollStatus.available()));
    expect(m_monitoredServiceDao.findByApplication(m_application1)).andReturn(m_applicationServices1);
    m_easyMockUtils.replayAll();
    SimpleWebTable table = m_service.createStatusTable(command, errors);
    m_easyMockUtils.verifyAll();
    SimpleWebTable expectedTable = new SimpleWebTable();
    expectedTable.setTitle("Distributed status view for Application 1 from Raleigh location");
    expectedTable.addColumn("Node", "");
    expectedTable.addColumn("Monitor", "");
    expectedTable.addColumn("Service", "");
    expectedTable.addColumn("Status", "");
    expectedTable.addColumn("Response", "");
    expectedTable.addColumn("Last Status Change", "");
    expectedTable.addColumn("Last Update", "");
    expectedTable.newRow();
    expectedTable.addCell("Node 1", "Normal", "element/node.jsp?node=1");
    expectedTable.addCell("Raleigh-" + LOCATION_MONITOR_ID_A, "", "distributed/locationMonitorDetails.htm?monitorId=" + LOCATION_MONITOR_ID_A);
    expectedTable.addCell("HTTPS", "", "element/service.jsp?ifserviceid=null");
    expectedTable.addCell("Up", "bright");
    expectedTable.addCell("", "");
    expectedTable.addCell(IGNORE_MATCH, "");
    expectedTable.addCell(IGNORE_MATCH, "");
    expectedTable.newRow();
    expectedTable.addCell("Node 1", "Indeterminate", "element/node.jsp?node=1");
    expectedTable.addCell("Raleigh-" + LOCATION_MONITOR_ID_A, "", "distributed/locationMonitorDetails.htm?monitorId=" + LOCATION_MONITOR_ID_A);
    expectedTable.addCell("HTTP", "", "element/service.jsp?ifserviceid=null");
    expectedTable.addCell("Unknown", "bright");
    expectedTable.addCell("No status recorded for this service from this location", "");
    expectedTable.addCell(IGNORE_MATCH, "");
    expectedTable.addCell(IGNORE_MATCH, "");
    assertTableEquals(expectedTable, table);
}
Also used : Errors(org.springframework.validation.Errors) DistributedStatusDetailsCommand(org.opennms.web.svclayer.model.DistributedStatusDetailsCommand) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) BindException(org.springframework.validation.BindException) SimpleWebTable(org.opennms.web.svclayer.model.SimpleWebTable) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 3 with SimpleWebTable

use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.

the class DefaultDistributedStatusServiceTest method testCreateStatusNoLocationMonitor.

public void testCreateStatusNoLocationMonitor() {
    DistributedStatusDetailsCommand command = new DistributedStatusDetailsCommand();
    Errors errors = new BindException(command, "command");
    command.setLocation(m_locationDefinition3.getLocationName());
    command.setApplication(m_application2.getName());
    expect(m_applicationDao.findByName("Application 2")).andReturn(m_application2);
    expect(m_monitoringLocationDao.get(m_locationDefinition3.getLocationName())).andReturn(m_locationDefinition3);
    expect(m_locationMonitorDao.findByLocationDefinition(m_locationDefinition3)).andReturn(new HashSet<OnmsLocationMonitor>());
    m_easyMockUtils.replayAll();
    SimpleWebTable table = m_service.createStatusTable(command, errors);
    Errors errorsOut = table.getErrors();
    assertEquals("Number of errors", 1, errorsOut.getErrorCount());
    assertEquals("Number of global errors", 1, errorsOut.getGlobalErrorCount());
    assertEquals("Number of field errors", 0, errorsOut.getFieldErrorCount());
    ObjectError e = (ObjectError) errorsOut.getGlobalErrors().get(0);
    assertEquals("Error code 0", "location.no-monitors", e.getCode());
    assertEquals("Error 0 argument count", 2, e.getArguments().length);
    assertEquals("Error argument 0.0", "Application 2", e.getArguments()[0]);
    assertEquals("Error argument 0.0", "Columbus", e.getArguments()[1]);
    m_easyMockUtils.verifyAll();
}
Also used : Errors(org.springframework.validation.Errors) ObjectError(org.springframework.validation.ObjectError) DistributedStatusDetailsCommand(org.opennms.web.svclayer.model.DistributedStatusDetailsCommand) BindException(org.springframework.validation.BindException) SimpleWebTable(org.opennms.web.svclayer.model.SimpleWebTable) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor)

Example 4 with SimpleWebTable

use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.

the class DistributedStatusDetailsController method handle.

@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView handle(@ModelAttribute("command") DistributedStatusDetailsCommand cmd, BindingResult errors) {
    m_validator.validate(cmd, errors);
    SimpleWebTable table = m_distributedStatusService.createStatusTable(cmd, errors);
    return new ModelAndView("distributedStatusDetails", "webTable", table);
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) SimpleWebTable(org.opennms.web.svclayer.model.SimpleWebTable) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with SimpleWebTable

use of org.opennms.web.svclayer.model.SimpleWebTable in project opennms by OpenNMS.

the class DefaultDistributedStatusServiceTest method testCreateFacilityStatusTableLayoutApplicationsVertically.

/*
     * XXX need to check sorting
     */
public void testCreateFacilityStatusTableLayoutApplicationsVertically() throws Exception {
    // No need to shuffle, since this is a list
    List<OnmsMonitoringLocation> locationDefinitions = new LinkedList<>();
    locationDefinitions.add(m_locationDefinition1);
    locationDefinitions.add(m_locationDefinition2);
    locationDefinitions.add(m_locationDefinition3);
    List<OnmsApplication> applications = new LinkedList<>();
    applications.add(m_application1);
    applications.add(m_application2);
    Collections.shuffle(applications);
    OnmsMonitoredService httpService = findMonitoredService(m_services, m_ip, "HTTP");
    OnmsMonitoredService httpsService = findMonitoredService(m_services, m_ip, "HTTPS");
    OnmsMonitoredService icmpService = findMonitoredService(m_services, m_ip, "ICMP");
    Collection<OnmsLocationSpecificStatus> mostRecentStatuses = new LinkedList<>();
    mostRecentStatuses.add(createStatus(m_locationMonitor1_1, httpService, PollStatus.available(), "20061011-00:00:00"));
    mostRecentStatuses.add(createStatus(m_locationMonitor1_1, httpsService, PollStatus.available(), "20061012-06:00:00"));
    mostRecentStatuses.add(createStatus(m_locationMonitor2_1, httpService, PollStatus.available(), "20061011-00:00:00"));
    mostRecentStatuses.add(createStatus(m_locationMonitor2_1, httpsService, PollStatus.available(), "20061012-06:00:00"));
    mostRecentStatuses.add(createStatus(m_locationMonitor2_2, httpService, PollStatus.available(), "20061011-00:00:00"));
    mostRecentStatuses.add(createStatus(m_locationMonitor2_2, httpsService, PollStatus.available(), "20061012-06:00:00"));
    Collection<OnmsLocationSpecificStatus> statusChanges = new LinkedList<>();
    statusChanges.add(createStatus(m_locationMonitor1_1, httpService, PollStatus.available(), "20061011-00:00:00"));
    statusChanges.add(createStatus(m_locationMonitor1_1, httpsService, PollStatus.unavailable(), "20061012-00:00:00"));
    statusChanges.add(createStatus(m_locationMonitor1_1, httpsService, PollStatus.available(), "20061012-06:00:00"));
    statusChanges.add(createStatus(m_locationMonitor1_1, icmpService, PollStatus.down(), "20061010-06:00:00"));
    Date startDate = s_dbDate.parse("2006-10-12 00:00:00.0");
    Date endDate = s_dbDate.parse("2006-10-13 00:00:00.0");
    expect(m_monitoringLocationDao.findAll()).andReturn(locationDefinitions);
    expect(m_applicationDao.findAll()).andReturn(applications);
    expect(m_locationMonitorDao.getAllMostRecentStatusChanges()).andReturn(mostRecentStatuses);
    expect(m_locationMonitorDao.findByLocationDefinition(locationDefinitions.get(0))).andReturn(Collections.singleton(m_locationMonitor1_1));
    Collection<OnmsLocationMonitor> monitors2 = new HashSet<>();
    monitors2.add(m_locationMonitor2_1);
    monitors2.add(m_locationMonitor2_2);
    expect(m_locationMonitorDao.findByLocationDefinition(locationDefinitions.get(1))).andReturn(monitors2);
    expect(m_locationMonitorDao.findByLocationDefinition(locationDefinitions.get(2))).andReturn(new HashSet<OnmsLocationMonitor>());
    expect(m_locationMonitorDao.getStatusChangesBetween(startDate, endDate)).andReturn(statusChanges);
    expect(m_locationMonitorDao.getAllStatusChangesAt(startDate)).andReturn(new HashSet<OnmsLocationSpecificStatus>());
    expect(m_monitoredServiceDao.findByApplication(m_application1)).andReturn(m_applicationServices1).times(3);
    expect(m_monitoredServiceDao.findByApplication(m_application2)).andReturn(m_applicationServices2).times(3);
    m_service.setLayoutApplicationsVertically(true);
    m_easyMockUtils.replayAll();
    SimpleWebTable table = m_service.createFacilityStatusTable(startDate, endDate);
    m_easyMockUtils.verifyAll();
    SimpleWebTable expectedTable = new SimpleWebTable();
    expectedTable.setTitle("Distributed Status Summary");
    expectedTable.addColumn("Application", "");
    expectedTable.addColumn("Raleigh", "");
    expectedTable.addColumn("Durham", "");
    expectedTable.addColumn("Columbus", "");
    expectedTable.newRow();
    expectedTable.addCell("Application 1", "");
    expectedTable.addCell("75.000%", "Normal", "distributedStatusHistory.htm?location=Raleigh&application=Application+1");
    expectedTable.addCell("No data", "Normal");
    expectedTable.addCell("No data", "Indeterminate");
    expectedTable.newRow();
    expectedTable.addCell("Application 2", "");
    expectedTable.addCell("75.000%", "Normal", "distributedStatusHistory.htm?location=Raleigh&application=Application+2");
    expectedTable.addCell("No data", "Normal");
    expectedTable.addCell("No data", "Indeterminate");
    assertTableEquals(expectedTable, table);
}
Also used : OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) LinkedList(java.util.LinkedList) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) SimpleWebTable(org.opennms.web.svclayer.model.SimpleWebTable) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) HashSet(java.util.HashSet)

Aggregations

SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)13 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)6 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)5 Date (java.util.Date)4 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)4 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)4 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)4 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 DistributedStatusDetailsCommand (org.opennms.web.svclayer.model.DistributedStatusDetailsCommand)3 BindException (org.springframework.validation.BindException)3 Errors (org.springframework.validation.Errors)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 ProgressMonitor (org.opennms.web.svclayer.model.ProgressMonitor)2 ArrayList (java.util.ArrayList)1 GregorianCalendar (java.util.GregorianCalendar)1 TreeSet (java.util.TreeSet)1 HttpSession (javax.servlet.http.HttpSession)1 Test (org.junit.Test)1 View (org.opennms.netmgt.config.surveillanceViews.View)1