Search in sources :

Example 1 with OnmsMonitoredServiceDetail

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

the class IfServicesRestService method getServices.

@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
public OnmsMonitoredServiceDetailList getServices(@Context final UriInfo uriInfo) {
    final Criteria c = getCriteria(uriInfo.getQueryParameters());
    final OnmsMonitoredServiceDetailList servicesList = new OnmsMonitoredServiceDetailList();
    final List<OnmsMonitoredService> services = m_serviceDao.findMatching(c);
    for (OnmsMonitoredService svc : services) {
        servicesList.add(new OnmsMonitoredServiceDetail(svc));
    }
    c.setLimit(null);
    c.setOffset(null);
    c.setOrders(new ArrayList<Order>());
    servicesList.setTotalCount(m_serviceDao.countMatching(c));
    return servicesList;
}
Also used : OnmsMonitoredServiceDetailList(org.opennms.netmgt.model.OnmsMonitoredServiceDetailList) OnmsMonitoredServiceDetail(org.opennms.netmgt.model.OnmsMonitoredServiceDetail) Order(org.opennms.core.criteria.Order) Criteria(org.opennms.core.criteria.Criteria) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with OnmsMonitoredServiceDetail

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

the class IfServicesRestServiceIT method testGetServices.

@Test
@JUnitTemporaryDatabase
public void testGetServices() throws Exception {
    String url = "/ifservices";
    OnmsMonitoredServiceDetailList list = getXmlObject(JaxbUtils.getContextFor(OnmsMonitoredServiceDetailList.class), url, 200, OnmsMonitoredServiceDetailList.class);
    for (OnmsMonitoredServiceDetail detail : list.getObjects()) {
        assertFalse("F".equals(detail.getStatusCode()));
    }
    // Mark all services as forced unmanaged
    sendPut(url, "status=F", 204);
    // Verify that all statuses were updated
    list = getXmlObject(JaxbUtils.getContextFor(OnmsMonitoredServiceDetailList.class), url, 200, OnmsMonitoredServiceDetailList.class);
    for (OnmsMonitoredServiceDetail detail : list.getObjects()) {
        assertEquals("F", detail.getStatusCode());
    }
}
Also used : OnmsMonitoredServiceDetailList(org.opennms.netmgt.model.OnmsMonitoredServiceDetailList) OnmsMonitoredServiceDetail(org.opennms.netmgt.model.OnmsMonitoredServiceDetail) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 3 with OnmsMonitoredServiceDetail

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

the class IfServicesRestServiceIT method testGetById.

@Test
@JUnitTemporaryDatabase
public void testGetById() throws Exception {
    OnmsMonitoredServiceDetail service = getXmlObject(JaxbUtils.getContextFor(OnmsMonitoredServiceDetail.class), "/ifservices/2", 200, OnmsMonitoredServiceDetail.class);
    Assert.assertNotNull(service);
    Assert.assertEquals("2", service.getId());
    // verify that 404 is implemented correctly
    sendRequest(GET, "/ifservices/-2", 404);
}
Also used : OnmsMonitoredServiceDetail(org.opennms.netmgt.model.OnmsMonitoredServiceDetail) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Aggregations

OnmsMonitoredServiceDetail (org.opennms.netmgt.model.OnmsMonitoredServiceDetail)3 Test (org.junit.Test)2 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)2 OnmsMonitoredServiceDetailList (org.opennms.netmgt.model.OnmsMonitoredServiceDetailList)2 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 Criteria (org.opennms.core.criteria.Criteria)1 Order (org.opennms.core.criteria.Order)1 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)1