@Test public void testDeleteRating() { Attendee attendee1 = sessionVote.registerAttendee(new Attendee("Jon Don")); Attendee attendee2 = sessionVote.registerAttendee(new Attendee("Do Doo")); SessionRating sessionRatingToDelete = new SessionRating("session1", attendee1.getId(), 5); sessionRatingToDelete = sessionVote.rateSession(sessionRatingToDelete); String ratingId = sessionRatingToDelete.getId(); String attendeeId = sessionRatingToDelete.getAttendeeId(); SessionRating sessionRatingToKeep = new SessionRating("session1", attendee2.getId(), 5); sessionRatingToKeep = sessionVote.rateSession(sessionRatingToKeep); sessionVote.deleteRating(ratingId); assertFalse("The deleted session was not retrieved as expected", sessionVote.getAllSessionRatings().contains(sessionRatingToDelete)); Collection<SessionRating> ratings = sessionVote.getAllSessionRatings(); assertEquals("An unexpected number of rating have been registered", 1, ratings.size()); ratings = sessionVote.allSessionVotes(sessionRatingToDelete.getSession()); assertEquals("An unexpected number of rating have been registered", 1, ratings.size()); Collection<SessionRating> ratingForAttendee = sessionVote.votesByAttendee(attendeeId); assertEquals("An unexpected number of rating have been registered", 0, ratingForAttendee.size()); }
@DELETE @Path("/rate/{id}") @Produces(APPLICATION_JSON) public void deleteRating(@PathParam("id") String id) { SessionRating rating = getRating(id); selectedSessionRatingDAO.deleteRating(rating.getId()); }
SessionVote { @DELETE @Path("/rate/{id}") @Produces(APPLICATION_JSON) public void deleteRating(@PathParam("id") String id) { SessionRating rating = getRating(id); selectedSessionRatingDAO.deleteRating(rating.getId()); } }
SessionVote { @DELETE @Path("/rate/{id}") @Produces(APPLICATION_JSON) public void deleteRating(@PathParam("id") String id) { SessionRating rating = getRating(id); selectedSessionRatingDAO.deleteRating(rating.getId()); }  }
SessionVote { @DELETE @Path("/rate/{id}") @Produces(APPLICATION_JSON) public void deleteRating(@PathParam("id") String id) { SessionRating rating = getRating(id); selectedSessionRatingDAO.deleteRating(rating.getId()); }  @GET @Path("/") @Produces(TEXT_HTML) String info(); @GET @Path("/nessProbe") @Produces(TEXT_PLAIN) Response nessProbe(); void setAttendeeSessionRating(AttendeeDAO attendee, SessionRatingDAO rating); @POST @Path("/attendee") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) Attendee registerAttendee(Attendee name); @PUT @Path("/attendee/{id}") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) Attendee updateAttendee(@PathParam("id") String id, Attendee attendee); @GET @Path("/attendee") @Produces(APPLICATION_JSON) Collection<Attendee> getAllAttendees(); @GET @Path("/attendee/{id}") @Produces(APPLICATION_JSON) Attendee getAttendee(@PathParam("id") String id); @DELETE @Path("/attendee/{id}") @Produces(APPLICATION_JSON) void deleteAttendee(@PathParam("id") String id); @POST @Path("/rate") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) SessionRating rateSession(SessionRating sessionRating); @GET @Path("/rate") @Produces(APPLICATION_JSON) Collection<SessionRating> getAllSessionRatings(); @PUT @Path("/rate/{id}") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) SessionRating updateRating(@PathParam("id") String id, SessionRating newRating); @GET @Path("/rate/{id}") @Produces(APPLICATION_JSON) SessionRating getRating(@PathParam("id") String id); @DELETE @Path("/rate/{id}") @Produces(APPLICATION_JSON) void deleteRating(@PathParam("id") String id); @GET @Path("/ratingsBySession") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) Collection<SessionRating> allSessionVotes(@QueryParam("sessionId") String sessionId); @GET @Path("/averageRatingBySession") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) double sessionRatingAverage(@QueryParam("sessionId") String sessionId); @GET @Path("/ratingsByAttendee") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) Collection<SessionRating> votesByAttendee(@QueryParam("attendeeId") String attendeeId); }
SessionVote { @DELETE @Path("/rate/{id}") @Produces(APPLICATION_JSON) public void deleteRating(@PathParam("id") String id) { SessionRating rating = getRating(id); selectedSessionRatingDAO.deleteRating(rating.getId()); }  @GET @Path("/") @Produces(TEXT_HTML) String info(); @GET @Path("/nessProbe") @Produces(TEXT_PLAIN) Response nessProbe(); void setAttendeeSessionRating(AttendeeDAO attendee, SessionRatingDAO rating); @POST @Path("/attendee") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) Attendee registerAttendee(Attendee name); @PUT @Path("/attendee/{id}") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) Attendee updateAttendee(@PathParam("id") String id, Attendee attendee); @GET @Path("/attendee") @Produces(APPLICATION_JSON) Collection<Attendee> getAllAttendees(); @GET @Path("/attendee/{id}") @Produces(APPLICATION_JSON) Attendee getAttendee(@PathParam("id") String id); @DELETE @Path("/attendee/{id}") @Produces(APPLICATION_JSON) void deleteAttendee(@PathParam("id") String id); @POST @Path("/rate") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) SessionRating rateSession(SessionRating sessionRating); @GET @Path("/rate") @Produces(APPLICATION_JSON) Collection<SessionRating> getAllSessionRatings(); @PUT @Path("/rate/{id}") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) SessionRating updateRating(@PathParam("id") String id, SessionRating newRating); @GET @Path("/rate/{id}") @Produces(APPLICATION_JSON) SessionRating getRating(@PathParam("id") String id); @DELETE @Path("/rate/{id}") @Produces(APPLICATION_JSON) void deleteRating(@PathParam("id") String id); @GET @Path("/ratingsBySession") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) Collection<SessionRating> allSessionVotes(@QueryParam("sessionId") String sessionId); @GET @Path("/averageRatingBySession") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) double sessionRatingAverage(@QueryParam("sessionId") String sessionId); @GET @Path("/ratingsByAttendee") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) Collection<SessionRating> votesByAttendee(@QueryParam("attendeeId") String attendeeId);  }