Search in sources :

Example 41 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class DefaultDistributedStatusServiceTest method testDetails.

public void testDetails() {
    List<OnmsMonitoringLocation> locationDefinitions = new LinkedList<>();
    locationDefinitions.add(m_locationDefinition1);
    locationDefinitions.add(m_locationDefinition2);
    locationDefinitions.add(m_locationDefinition3);
    expect(m_monitoringLocationDao.findAll()).andReturn(locationDefinitions);
    List<OnmsApplication> applications = new ArrayList<>();
    applications.add(m_application1);
    applications.add(m_application2);
    expect(m_applicationDao.findAll()).andReturn(applications);
    expect(m_monitoringLocationDao.get("Durham")).andReturn(m_locationDefinition2);
    expect(m_applicationDao.findByName("Application 2")).andReturn(m_application2);
    List<OnmsLocationMonitor> monitors = new ArrayList<>();
    monitors.add(m_locationMonitor2_1);
    monitors.add(m_locationMonitor2_2);
    expect(m_locationMonitorDao.findByLocationDefinition(m_locationDefinition2)).andReturn(monitors);
    for (OnmsMonitoredService service : m_applicationServices2) {
        m_locationMonitorDao.initialize(service.getIpInterface());
        m_locationMonitorDao.initialize(service.getIpInterface().getNode());
    }
    String locationName = m_locationDefinition2.getLocationName();
    String applicationName = m_application2.getName();
    String monitorId = "";
    String timeSpan = "Last Day";
    String previousLocation = "";
    expect(m_monitoredServiceDao.findByApplication(m_application2)).andReturn(m_applicationServices2).times(2);
    expectResourceDaoCall(m_locationMonitor2_1, m_applicationServices2);
    m_easyMockUtils.replayAll();
    DistributedStatusHistoryModel summary = m_service.createHistoryModel(locationName, monitorId, applicationName, timeSpan, previousLocation);
    m_easyMockUtils.verifyAll();
    assertNotNull("summary should not be null", summary);
    assertNotNull("summary locations list should not be null", summary.getLocations());
    assertNotNull("summary applications list should not be null", summary.getApplications());
    assertNotNull("summary chosen location should not be null", summary.getChosenLocation());
    assertNotNull("summary chosen application should not be null", summary.getChosenApplication());
    assertNotNull("summary error list should not be null", summary.getErrors());
    assertEquals("summary locations list size", locationDefinitions.size(), summary.getLocations().size());
    assertEquals("summary applications list size", applications.size(), summary.getApplications().size());
    assertEquals("summary error list size: " + summary.getErrors(), 0, summary.getErrors().size());
    // Verify sorting of applications
    assertEquals("summary applications 1", m_application1, summary.getApplications().get(0));
    assertEquals("summary applications 2", m_application2, summary.getApplications().get(1));
    // Verify chosen ones
    assertEquals("summary chosen location", m_locationDefinition2, summary.getChosenLocation());
    assertEquals("summary chosen application", m_application2, summary.getChosenApplication());
    // And verify that they are in the lists in the right place
    assertEquals("summary chosen location matches list", summary.getLocations().get(1), summary.getChosenLocation());
    assertEquals("summary chosen application matches list", summary.getApplications().get(1), summary.getChosenApplication());
    assertEquals("graph URL map size", 1, summary.getServiceGraphs().size());
    assertNotNull("graph 0 URL should not be null", summary.getServiceGraphs().iterator().next().getUrl());
}
Also used : DistributedStatusHistoryModel(org.opennms.web.svclayer.model.DistributedStatusHistoryModel) ArrayList(java.util.ArrayList) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) LinkedList(java.util.LinkedList) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 42 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class DefaultDistributedStatusServiceTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    Locale.setDefault(Locale.US);
    m_service.setMonitoredServiceDao(m_monitoredServiceDao);
    m_service.setMonitoringLocationDao(m_monitoringLocationDao);
    m_service.setLocationMonitorDao(m_locationMonitorDao);
    m_service.setApplicationDao(m_applicationDao);
    m_service.setResourceDao(m_resourceDao);
    m_service.setGraphDao(m_graphDao);
    m_service.afterPropertiesSet();
    m_locationDefinition1 = new OnmsMonitoringLocation("Raleigh", "OpenNMS NC", "raleigh");
    m_locationDefinition2 = new OnmsMonitoringLocation("Durham", "OpenNMS NC", "durham");
    m_locationDefinition3 = new OnmsMonitoringLocation("Columbus", "OpenNMS OH", "columbus");
    m_application1 = new OnmsApplication();
    m_application1.setName("Application 1");
    m_application2 = new OnmsApplication();
    m_application2.setName("Application 2");
    m_locationMonitor1_1 = new OnmsLocationMonitor();
    m_locationMonitor1_1.setId(LOCATION_MONITOR_ID_A);
    m_locationMonitor1_1.setLastUpdated(new Date());
    m_locationMonitor1_1.setLocation("Raleigh");
    m_locationMonitor1_1.setStatus(MonitorStatus.STARTED);
    assertEquals("location monitor 1.1 status", MonitorStatus.STARTED, m_locationMonitor1_1.getStatus());
    m_locationMonitor2_1 = new OnmsLocationMonitor();
    m_locationMonitor2_1.setId(LOCATION_MONITOR_ID_B);
    m_locationMonitor2_1.setLastUpdated(new Date());
    m_locationMonitor2_1.setLocation("Durham");
    m_locationMonitor2_1.setStatus(MonitorStatus.STARTED);
    assertEquals("location monitor 2.1 status", MonitorStatus.STARTED, m_locationMonitor2_1.getStatus());
    m_locationMonitor2_2 = new OnmsLocationMonitor();
    m_locationMonitor2_2.setId(LOCATION_MONITOR_ID_C);
    m_locationMonitor2_2.setLocation("Durham");
    m_locationMonitor2_2.setStatus(MonitorStatus.STARTED);
    assertEquals("location monitor 2.2 status", MonitorStatus.STARTED, m_locationMonitor2_2.getStatus());
    List<String> serviceNames = new ArrayList<>();
    serviceNames.add("ICMP");
    serviceNames.add("DNS");
    serviceNames.add("HTTP");
    serviceNames.add("HTTPS");
    // shuffle to test sorting
    Collections.shuffle(serviceNames);
    m_node = new OnmsNode();
    m_ip = InetAddressUtils.addr("1.1.1.1");
    m_node.setLabel("Node 1");
    m_node.setId(1);
    // Can't shuffle since it's a set
    m_services = new HashSet<>();
    m_services.add(new OnmsMonitoredService(new OnmsIpInterface(m_ip, m_node), new OnmsServiceType("ICMP")));
    m_services.add(new OnmsMonitoredService(new OnmsIpInterface(m_ip, m_node), new OnmsServiceType("DNS")));
    m_services.add(new OnmsMonitoredService(new OnmsIpInterface(m_ip, m_node), new OnmsServiceType("HTTP")));
    m_services.add(new OnmsMonitoredService(new OnmsIpInterface(m_ip, m_node), new OnmsServiceType("HTTPS")));
    // Can't shuffle since these since they are sets
    m_applicationServices1 = new TreeSet<>();
    m_applicationServices1.add(findMonitoredService(m_services, m_ip, "HTTP"));
    m_applicationServices1.add(findMonitoredService(m_services, m_ip, "HTTPS"));
    // m_application1.setMemberServices(applicationServices1);
    m_applicationServices2 = new TreeSet<>();
    m_applicationServices2.add(findMonitoredService(m_services, m_ip, "HTTPS"));
// m_application2.setMemberServices(applicationServices2);
/*
        m_application2 = new OnmsApplication();
        m_application2.setLabel("Application 2");
        // XXX shuffle to verify sorting? create new list and do: Collections.shuffle(applicationServices2)
        m_application2.setMemberServices(applicationServices1);
        */
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) ArrayList(java.util.ArrayList) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Aggregations

OnmsApplication (org.opennms.netmgt.model.OnmsApplication)42 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)20 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)14 ArrayList (java.util.ArrayList)13 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)12 Date (java.util.Date)11 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)11 LinkedList (java.util.LinkedList)8 Transactional (org.springframework.transaction.annotation.Transactional)6 HashSet (java.util.HashSet)5 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)4 StatusDetails (org.opennms.features.poller.remote.gwt.client.StatusDetails)4 SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)4 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 Test (org.junit.Test)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)3 DistributedStatusHistoryModel (org.opennms.web.svclayer.model.DistributedStatusHistoryModel)3 HashMap (java.util.HashMap)2