@Test public void deleteUser() { final String requestUserId = "USER_TO_DELETE"; doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { String argUserId = (String) invocation.getArguments()[0]; assertEquals("Service user ID should match the requested user ID", argUserId, requestUserId); return null; } }).when(userServiceMock).deleteUser(anyString()); ClientResponse clientResponse = resource().path("/api/users/" + requestUserId) .delete(ClientResponse.class); assertEquals("Response HTTP status code should be 200 (OK)", clientResponse.getStatus(), 200); verify(userServiceMock).deleteUser(anyString()); }
@DELETE @Path("/{userId}") public Response deleteUser(@PathParam("userId") String userId) { userService.deleteUser(userId); return Response.ok().build(); }
UserResource { @DELETE @Path("/{userId}") public Response deleteUser(@PathParam("userId") String userId) { userService.deleteUser(userId); return Response.ok().build(); } }
UserResource { @DELETE @Path("/{userId}") public Response deleteUser(@PathParam("userId") String userId) { userService.deleteUser(userId); return Response.ok().build(); } @Inject  UserResource(UserService userService); }
UserResource { @DELETE @Path("/{userId}") public Response deleteUser(@PathParam("userId") String userId) { userService.deleteUser(userId); return Response.ok().build(); } @Inject  UserResource(UserService userService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<User> listUsers(); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) User createUser(User user); @GET @Path("/{userId}") @Produces(MediaType.APPLICATION_JSON) User getUser(@PathParam("userId") String userId); @PUT @Path("/{userId}") @Consumes(MediaType.APPLICATION_JSON) Response updateUser(@PathParam("userId") String userId, User user); @DELETE @Path("/{userId}") Response deleteUser(@PathParam("userId") String userId); @PUT @Path("/{userId}/password") @Consumes(MediaType.APPLICATION_JSON) Response updateUserPassword(@PathParam("userId") String userId,
            PasswordChange passwordChange); }
UserResource { @DELETE @Path("/{userId}") public Response deleteUser(@PathParam("userId") String userId) { userService.deleteUser(userId); return Response.ok().build(); } @Inject  UserResource(UserService userService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<User> listUsers(); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) User createUser(User user); @GET @Path("/{userId}") @Produces(MediaType.APPLICATION_JSON) User getUser(@PathParam("userId") String userId); @PUT @Path("/{userId}") @Consumes(MediaType.APPLICATION_JSON) Response updateUser(@PathParam("userId") String userId, User user); @DELETE @Path("/{userId}") Response deleteUser(@PathParam("userId") String userId); @PUT @Path("/{userId}/password") @Consumes(MediaType.APPLICATION_JSON) Response updateUserPassword(@PathParam("userId") String userId,
            PasswordChange passwordChange);  }