AdminUserResource extends BaseResource { @DELETE @Timed @Path("/user/{userId}") public Response delete( @RestrictedTo({Authority.ROLE_ADMIN}) User adminUser, @PathParam("userId") Long userId, AdminDeleteEntityDto deleteEntityRequest) { Optional<User> user = userReadService.getById(userId); ResourceAsserts.assertPresent(user, "user"); User persistentUser = user.get(); persistentUser.setDeleted(true); persistentUser.setReasonForDelete(deleteEntityRequest.getReason()); persistentUser = userReadService.saveOrUpdate(user.get()); Representation representation = new AdminUserRepresentation().get(persistentUser, Optional.of(adminUser)); return ok(representation); }  @POST @Timed @Path("/user") Response create(
    @RestrictedTo({Authority.ROLE_ADMIN})
    User adminUser,
    AdminCreateUserDto createUserRequest); @GET @Timed @Path("/user") @CacheControl(maxAge = 6, maxAgeUnit = TimeUnit.HOURS) Response retrieveAllByPage(
    @RestrictedTo({Authority.ROLE_ADMIN}) User adminUser,
    @QueryParam("ps") Optional<String> rawPageSize,
    @QueryParam("pn") Optional<String> rawPageNumber); @PUT @Timed @Path("/user/{userId}") Response update(
    @RestrictedTo({Authority.ROLE_ADMIN})
    User adminUser,
    @PathParam("userId") Long userId,
    AdminUpdateUserDto updateUserRequest); @DELETE @Timed @Path("/user/{userId}") Response delete(
    @RestrictedTo({Authority.ROLE_ADMIN})
    User adminUser,
    @PathParam("userId") Long userId,
    AdminDeleteEntityDto deleteEntityRequest); void setUserReadService(UserReadService userReadService);  }
@Test public void adminDeleteUserAsHalJson() throws Exception { AdminDeleteEntityDto deleteUserRequest = new AdminDeleteEntityDto(); deleteUserRequest.setReason("At user request"); String actualResponse = configureAsClient("/admin/user/1") .accept(HalMediaType.APPLICATION_HAL_JSON) .entity(deleteUserRequest, MediaType.APPLICATION_JSON_TYPE) .delete(String.class); FixtureAsserts.assertStringMatchesJsonFixture("DeleteUser by admin response render to HAL+JSON", actualResponse, "/fixtures/hal/user/expected-admin-delete-user.json"); }