RestRules { @DELETE @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) public Response remove(@PathParam("id") String id) { RestListener listener = RestManager.getListener(); Response response; try { log.info("Remove request with id: {}", id); listener.remove(id); response = Response.ok().build(); } catch (RestNotFoundException e) { log.info("Remove request invalid: {}", e.getMessage()); e.printStackTrace(); response = Response.status(Response.Status.NOT_FOUND) .entity(toMap(e, Response.Status.NOT_FOUND)) .build(); } catch (Exception e) { e.printStackTrace(); response = Response.serverError() .entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR)) .build(); } return response; }  @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response add(String json); @DELETE @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) Response remove(@PathParam("id") String id); @POST @Path("/synchronize") @Consumes (MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response synchronize(String json); @GET @Produces(MediaType.APPLICATION_JSON) Response list();  }
@Test public void remove() throws Exception { Map<String, Object> elementMap = new HashMap<>(); Map<String, String> outputTopics = new HashMap<>(); outputTopics.put("outputStream", "outputTopic"); elementMap.put("id", "rule_to_delete"); elementMap.put("input", Arrays.asList("test")); elementMap.put("output", outputTopics); elementMap.put("executionPlan", "from test select a, b insert into outputStream;"); String json = objectMapper.writeValueAsString(elementMap); Entity<String> entity = Entity.json(json); Response response = target("/v1/").request(MediaType.APPLICATION_JSON_TYPE).post(entity); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); response = target("/v1/rule_to_delete").request(MediaType.APPLICATION_JSON_TYPE).delete(); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); }