Added testCase for all Services

This commit is contained in:
Giuseppe Bueti
2016-01-31 11:05:11 +01:00
committed by giuseppe.bueti
parent 09c853477e
commit 6263054087
6 changed files with 206 additions and 137 deletions
@@ -17,6 +17,12 @@ public interface ServicesInterface {
Movie movieByImdbID(@QueryParam("imdbID") String imdbID);
@GET
@Path("/listmovies")
@Produces({"application/json"})
List<Movie> listMovies();
@POST
@Path("/addmovie")
@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@@ -34,9 +40,5 @@ public interface ServicesInterface {
Response deleteMovie(@QueryParam("imdbID") String imdbID);
@GET
@Path("/listmovies")
@Produces({"application/json"})
List<Movie> listMovies();
}
@@ -18,18 +18,21 @@ public class MovieCrudService {
private Map<String,Movie> inventory = new HashMap<String, Movie>();
@GET
@Path("/getinfo")
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public Movie movieByImdbID(@QueryParam("imdbID") String imdbID){
System.out.println("*** Calling getinfo ***");
System.out.println("*** Calling getinfo for a given ImdbID***");
if(inventory.containsKey(imdbID)){
return inventory.get(imdbID);
}else return null;
Movie movie=new Movie();
movie.setImdbID(imdbID);
return movie;
}
@POST
@Path("/addmovie")
@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@@ -41,6 +44,7 @@ public class MovieCrudService {
return Response.status(Response.Status.NOT_MODIFIED)
.entity("Movie is Already in the database.").build();
}
inventory.put(movie.getImdbID(),movie);
return Response.status(Response.Status.CREATED).build();
@@ -54,7 +58,7 @@ public class MovieCrudService {
System.out.println("*** Calling updateMovie ***");
if (null!=inventory.get(movie.getImdbID())){
if (null==inventory.get(movie.getImdbID())){
return Response.status(Response.Status.NOT_MODIFIED)
.entity("Movie is not in the database.\nUnable to Update").build();
}
@@ -79,6 +83,7 @@ public class MovieCrudService {
return Response.status(Response.Status.OK).build();
}
@GET
@Path("/listmovies")
@Produces({"application/json"})