ServerStatsRestApi { @GET @Produces(MediaType.APPLICATION_JSON) public Response getServerStats() { try { Map<String, Object> stats = new HashMap<String, Object>(); MemoryUsage heap = memoryMXBean.getHeapMemoryUsage(); MemoryUsage nonHeap = memoryMXBean.getNonHeapMemoryUsage(); stats.put("heap", heap); stats.put("nonHeap", nonHeap); double processCpuLoad = 0; processCpuLoad = (Double) mbs.getAttribute(new ObjectName("java.lang:type=OperatingSystem"), "ProcessCpuLoad"); stats.put("processCpuLoad", processCpuLoad); Map<String, Integer> appstatsMap = MonitorController.getInstance().getBoundAppStats(); stats.put("appCount", appstatsMap.get("appCount")); stats.put("instanceCount", appstatsMap.get("instanceCount")); return RestApiResponseHandler.getResponseOk(mapper.writeValueAsString(stats)); } catch (Exception e) { logger.error(e.getMessage(), e); return RestApiResponseHandler.getResponse(Status.INTERNAL_SERVER_ERROR); } }  @GET @Produces(MediaType.APPLICATION_JSON) Response getServerStats();  }
@Test public void testGetServerStats(){ WebResource webResource = resource(); ClientResponse response = webResource.path("/stats").type(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertEquals(response.getStatus(), STATUS200); }