EventRestApi { @POST @Consumes(MediaType.APPLICATION_JSON) public Response receiveEvents(@Context final HttpServletRequest httpServletRequest, String jsonString) { logger.info("Received event, JSON string: "+jsonString); try { MonitorTriggerEvent[] event = mapper.readValue(jsonString,MonitorTriggerEvent[].class); ArrayList<MonitorTriggerEvent> eventList = new ArrayList<MonitorTriggerEvent>(); for (int i = 0; i < event.length; i++) { eventList.add(event[i]); } ScalingEventManager.getInstance().postTriggerEvents(eventList); return RestApiResponseHandler.getResponseOk("{}"); } catch (IOException e) { return RestApiResponseHandler.getResponseError(MESSAGE_KEY.RestResponseErrorMsg_build_JSON_error, e, httpServletRequest.getLocale()); } }  @POST @Consumes(MediaType.APPLICATION_JSON) Response receiveEvents(@Context final HttpServletRequest httpServletRequest, String jsonString);  }
@Test public void testReceiveEvents() throws JsonProcessingException{ WebResource webResource = resource(); String policyStr = ""; policyStr = PolicyRestApiTest.getPolicyContent(); ClientResponse response = webResource.path("/policies").type(MediaType.APPLICATION_JSON).post(ClientResponse.class,policyStr); String jsonStr = response.getEntity(String.class); JSONObject jo = new JSONObject(jsonStr); policyId = jo.getString("policyId"); assertNotNull(policyId); assertEquals(response.getStatus(), STATUS201); webResource = resource(); jo = new JSONObject(); jo.put("policyId", policyId); jo.put("state", AutoScalerPolicy.STATE_ENABLED); response = webResource.path("/apps/" + TESTAPPID).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, jo.toString()); assertEquals(response.getStatus(), STATUS200); response = webResource.path("/events").type(MediaType.APPLICATION_JSON).post(ClientResponse.class, mapper.writeValueAsString(this.generateEvents())); assertEquals(response.getStatus(), STATUS200); }