@Test public void testDoThis() { RestAssured.given() .param("turns", 1) .expect() .statusCode(204) .when() .post("/media-module"); RestAssured.given() .param("turns", 10) .expect() .statusCode(204) .when() .post("/media-module"); RestAssured.expect() .statusCode(204) .when() .post("/media-module"); RestAssured.given() .param("turns", 123) .expect() .statusCode(444) .when() .post("/media-module"); }
@POST public Response doThis(@FormParam("turns") @DefaultValue("2") int turns) throws DoThisException { log.debug("Request to doThis {} times", turns); if (turns > 100) throw new DoThisException("At max, 100 turns are allowed"); if (turns < 0) throw new DoThisException("Can't undo 'This'"); myService.doThis(turns); return Response.noContent().build(); }
MyWebService { @POST public Response doThis(@FormParam("turns") @DefaultValue("2") int turns) throws DoThisException { log.debug("Request to doThis {} times", turns); if (turns > 100) throw new DoThisException("At max, 100 turns are allowed"); if (turns < 0) throw new DoThisException("Can't undo 'This'"); myService.doThis(turns); return Response.noContent().build(); } }
MyWebService { @POST public Response doThis(@FormParam("turns") @DefaultValue("2") int turns) throws DoThisException { log.debug("Request to doThis {} times", turns); if (turns > 100) throw new DoThisException("At max, 100 turns are allowed"); if (turns < 0) throw new DoThisException("Can't undo 'This'"); myService.doThis(turns); return Response.noContent().build(); }  }
MyWebService { @POST public Response doThis(@FormParam("turns") @DefaultValue("2") int turns) throws DoThisException { log.debug("Request to doThis {} times", turns); if (turns > 100) throw new DoThisException("At max, 100 turns are allowed"); if (turns < 0) throw new DoThisException("Can't undo 'This'"); myService.doThis(turns); return Response.noContent().build(); }  @GET @Produces("text/plain; charset=utf8") Response hello(@QueryParam("name") String name); @POST Response doThis(@FormParam("turns") @DefaultValue("2") int turns); }
MyWebService { @POST public Response doThis(@FormParam("turns") @DefaultValue("2") int turns) throws DoThisException { log.debug("Request to doThis {} times", turns); if (turns > 100) throw new DoThisException("At max, 100 turns are allowed"); if (turns < 0) throw new DoThisException("Can't undo 'This'"); myService.doThis(turns); return Response.noContent().build(); }  @GET @Produces("text/plain; charset=utf8") Response hello(@QueryParam("name") String name); @POST Response doThis(@FormParam("turns") @DefaultValue("2") int turns);  }