@Test public void deleteRole() { final String requestRoleId = "ROLE_TO_DELETE"; doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { String argRoleId = (String) invocation.getArguments()[0]; assertEquals("Service role ID should match the requested role ID", argRoleId, requestRoleId); return null; } }).when(roleServiceMock).deleteRole(anyString()); ClientResponse clientResponse = resource().path("/api/roles/" + requestRoleId) .delete(ClientResponse.class); assertEquals("Response HTTP status code should be 200 (OK)", clientResponse.getStatus(), 200); verify(roleServiceMock).deleteRole(anyString()); }
@DELETE @Path("/{roleId}") public Response deleteRole(@PathParam("roleId") String roleId) { roleService.deleteRole(roleId); return Response.ok().build(); }
RoleResource { @DELETE @Path("/{roleId}") public Response deleteRole(@PathParam("roleId") String roleId) { roleService.deleteRole(roleId); return Response.ok().build(); } }
RoleResource { @DELETE @Path("/{roleId}") public Response deleteRole(@PathParam("roleId") String roleId) { roleService.deleteRole(roleId); return Response.ok().build(); } @Inject  RoleResource(RoleService roleService); }
RoleResource { @DELETE @Path("/{roleId}") public Response deleteRole(@PathParam("roleId") String roleId) { roleService.deleteRole(roleId); return Response.ok().build(); } @Inject  RoleResource(RoleService roleService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<Role> listRoles(); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Role createRole(Role role); @GET @Path("/{roleId}") @Produces(MediaType.APPLICATION_JSON) Role getRole(@PathParam("roleId") String roleId); @PUT @Path("/{roleId}") @Consumes(MediaType.APPLICATION_JSON) Response updateRole(@PathParam("roleId") String roleId, Role role); @DELETE @Path("/{roleId}") Response deleteRole(@PathParam("roleId") String roleId); }
RoleResource { @DELETE @Path("/{roleId}") public Response deleteRole(@PathParam("roleId") String roleId) { roleService.deleteRole(roleId); return Response.ok().build(); } @Inject  RoleResource(RoleService roleService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<Role> listRoles(); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Role createRole(Role role); @GET @Path("/{roleId}") @Produces(MediaType.APPLICATION_JSON) Role getRole(@PathParam("roleId") String roleId); @PUT @Path("/{roleId}") @Consumes(MediaType.APPLICATION_JSON) Response updateRole(@PathParam("roleId") String roleId, Role role); @DELETE @Path("/{roleId}") Response deleteRole(@PathParam("roleId") String roleId);  }