BAEL-2268 - Guide to JerseyTest (#5443)

* BAEL-2268 - Guide to JerseyTest
-  second attempt without formatting changes

* BAEL-2268 - Guide to JerseyTest

- Add line break to end of file
This commit is contained in:
Jonathan Cook
2018-10-13 20:19:14 +02:00
committed by Eugen
parent f61d503d1f
commit ca4b6200a7
4 changed files with 77 additions and 0 deletions
@@ -54,4 +54,9 @@ public class Fruit {
public void setSerial(String serial) {
this.serial = serial;
}
@Override
public String toString() {
return "Fruit [name: " + getName() + " colour: " + getColour() + "]";
}
}
@@ -16,6 +16,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.glassfish.jersey.server.mvc.ErrorTemplate;
import org.glassfish.jersey.server.mvc.Template;
@@ -86,6 +88,16 @@ public class FruitResource {
public void createFruit(@Valid Fruit fruit) {
SimpleStorageService.storeFruit(fruit);
}
@POST
@Path("/created")
@Consumes(MediaType.APPLICATION_JSON)
public Response createNewFruit(@Valid Fruit fruit) {
String result = "Fruit saved : " + fruit;
return Response.status(Status.CREATED.getStatusCode())
.entity(result)
.build();
}
@GET
@Valid