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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user