@Test public void testDeleteAttendee() { Attendee jonathanDoe = sessionVote.registerAttendee(new Attendee("Jonathan Doe")); String id = jonathanDoe.getId(); Attendee attendee = sessionVote.getAttendee(id); assertEquals("Attendee's name was not retrieved as expected", "Jonathan Doe", attendee.getName()); assertEquals("Attendee's ID was not retrieved as expected", id, attendee.getId()); sessionVote.deleteAttendee(id); try { sessionVote.getAttendee(id); fail("Attendee was not deleted as expected"); } catch (NotFoundException e) { } Collection<Attendee> attendees = sessionVote.getAllAttendees(); assertEquals("An unexpected number of attendees have been registered", 0, attendees.size()); }
@DELETE @Path("/attendee/{id}") @Produces(APPLICATION_JSON) public void deleteAttendee(@PathParam("id") String id) { Attendee attendee = getAttendee(id); Collection<SessionRating> ratings = votesByAttendee(attendee.getId()); for (SessionRating rating : ratings) { selectedSessionRatingDAO.deleteRating(rating.getId()); } selectedAttendeeDAO.deleteAttendee(attendee.getId()); }
SessionVote { @DELETE @Path("/attendee/{id}") @Produces(APPLICATION_JSON) public void deleteAttendee(@PathParam("id") String id) { Attendee attendee = getAttendee(id); Collection<SessionRating> ratings = votesByAttendee(attendee.getId()); for (SessionRating rating : ratings) { selectedSessionRatingDAO.deleteRating(rating.getId()); } selectedAttendeeDAO.deleteAttendee(attendee.getId()); } }
SessionVote { @DELETE @Path("/attendee/{id}") @Produces(APPLICATION_JSON) public void deleteAttendee(@PathParam("id") String id) { Attendee attendee = getAttendee(id); Collection<SessionRating> ratings = votesByAttendee(attendee.getId()); for (SessionRating rating : ratings) { selectedSessionRatingDAO.deleteRating(rating.getId()); } selectedAttendeeDAO.deleteAttendee(attendee.getId()); }  }
SessionVote { @DELETE @Path("/attendee/{id}") @Produces(APPLICATION_JSON) public void deleteAttendee(@PathParam("id") String id) { Attendee attendee = getAttendee(id); Collection<SessionRating> ratings = votesByAttendee(attendee.getId()); for (SessionRating rating : ratings) { selectedSessionRatingDAO.deleteRating(rating.getId()); } selectedAttendeeDAO.deleteAttendee(attendee.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("/attendee/{id}") @Produces(APPLICATION_JSON) public void deleteAttendee(@PathParam("id") String id) { Attendee attendee = getAttendee(id); Collection<SessionRating> ratings = votesByAttendee(attendee.getId()); for (SessionRating rating : ratings) { selectedSessionRatingDAO.deleteRating(rating.getId()); } selectedAttendeeDAO.deleteAttendee(attendee.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);  }