@Test public void testHello() { RestAssured.given() .param("name", "Steve") .expect() .content(containsString("Hello Steve")) .when() .get("/media-module"); RestAssured.expect() .statusCode(400) .when() .get("/media-module"); }
@GET @Produces("text/plain; charset=utf8") public Response hello(@QueryParam("name") String name) { if (StringUtils.isEmpty(name)) { log.warn("No name given"); return Response.status(Status.BAD_REQUEST).entity("Missing Parameter 'name'").build(); } log.debug("Sending regards to {}", name); return Response.ok(myService.helloWorld(name)).build(); }
MyWebService { @GET @Produces("text/plain; charset=utf8") public Response hello(@QueryParam("name") String name) { if (StringUtils.isEmpty(name)) { log.warn("No name given"); return Response.status(Status.BAD_REQUEST).entity("Missing Parameter 'name'").build(); } log.debug("Sending regards to {}", name); return Response.ok(myService.helloWorld(name)).build(); } }
MyWebService { @GET @Produces("text/plain; charset=utf8") public Response hello(@QueryParam("name") String name) { if (StringUtils.isEmpty(name)) { log.warn("No name given"); return Response.status(Status.BAD_REQUEST).entity("Missing Parameter 'name'").build(); } log.debug("Sending regards to {}", name); return Response.ok(myService.helloWorld(name)).build(); }  }
MyWebService { @GET @Produces("text/plain; charset=utf8") public Response hello(@QueryParam("name") String name) { if (StringUtils.isEmpty(name)) { log.warn("No name given"); return Response.status(Status.BAD_REQUEST).entity("Missing Parameter 'name'").build(); } log.debug("Sending regards to {}", name); return Response.ok(myService.helloWorld(name)).build(); }  @GET @Produces("text/plain; charset=utf8") Response hello(@QueryParam("name") String name); @POST Response doThis(@FormParam("turns") @DefaultValue("2") int turns); }
MyWebService { @GET @Produces("text/plain; charset=utf8") public Response hello(@QueryParam("name") String name) { if (StringUtils.isEmpty(name)) { log.warn("No name given"); return Response.status(Status.BAD_REQUEST).entity("Missing Parameter 'name'").build(); } log.debug("Sending regards to {}", name); return Response.ok(myService.helloWorld(name)).build(); }  @GET @Produces("text/plain; charset=utf8") Response hello(@QueryParam("name") String name); @POST Response doThis(@FormParam("turns") @DefaultValue("2") int turns);  }