ScalingHistoryRestApi { @Path ("/count") @GET @Produces (MediaType.APPLICATION_JSON) public Response getHistoryCount(@Context final HttpServletRequest httpServletRequest, @QueryParam ("appId") String appId, @QueryParam ("startTime") String startTime, @QueryParam ("endTime") String endTime, @QueryParam ("status") String status, @QueryParam ("metrics") String metrics,@QueryParam ("scaleType") String scaleType){ logger.debug( "Get scaling history count. App ID is " + appId); try { ScalingHistoryFilter filter = new ScalingHistoryFilter(); filter.setAppId(appId); if (!ValidateUtil.isNull(startTime)){ filter.setStartTime(Long.parseLong(startTime)); } if (!ValidateUtil.isNull(endTime)){ filter.setEndTime(Long.parseLong(endTime)); } if (!ValidateUtil.isNull(scaleType)){ filter.setScaleType(scaleType); } if (!ValidateUtil.isNull(status)){ filter.setStatus(status); } if (!ValidateUtil.isNull(scaleType)){ filter.setScaleType(scaleType); } ScalingHistoryManager manager = ScalingHistoryManager.getInstance(); int count = manager.getHistoryCount(filter); JSONObject json = new JSONObject(); json.put("count", count); return RestApiResponseHandler.getResponseOk(json); } catch (DataStoreException e) { return RestApiResponseHandler.getResponseError(MESSAGE_KEY.RestResponseErrorMsg_database_error, e, httpServletRequest.getLocale()); } }  @GET @Produces (MediaType.APPLICATION_JSON) Response getHistoryList(@Context final HttpServletRequest httpServletRequest, @QueryParam ("appId") String appId, @QueryParam ("startTime") String startTime, 
			@QueryParam ("endTime") String endTime, @QueryParam ("status") String status,
			@QueryParam ("metrics") String metrics, @QueryParam ("offset") String offset,
			@QueryParam ("maxCount") String maxCount, @QueryParam ("scaleType") String scaleType, @QueryParam ("timeZone") String timeZone); @Path ("/count") @GET @Produces (MediaType.APPLICATION_JSON) Response getHistoryCount(@Context final HttpServletRequest httpServletRequest, @QueryParam ("appId") String appId, @QueryParam ("startTime") String startTime, 
			@QueryParam ("endTime") String endTime, @QueryParam ("status") String status,
			@QueryParam ("metrics") String metrics,@QueryParam ("scaleType") String scaleType);  }
@Test public void testGetHistoryCount(){ WebResource webResource = resource(); MultivaluedMap<String, String> paramMap = new MultivaluedMapImpl(); paramMap.add("appId", TESTAPPID); paramMap.add("startTime", String.valueOf(0)); paramMap.add("endTime", String.valueOf(System.currentTimeMillis() * 2)); paramMap.add("status", "3"); paramMap.add("scaleType", "scaleIn"); ClientResponse response = webResource.path("/history/count").queryParams(paramMap).type(MediaType.APPLICATION_JSON).get(ClientResponse.class); String jsonStr = response.getEntity(String.class); JSONObject jo = new JSONObject(jsonStr); assertEquals(jo.get("count"),1); assertEquals(response.getStatus(), STATUS200); }