MembershipResource { @Path("/clients/{clientId}/groups/{groupId}") @Timed @ExceptionMetered @DELETE public Response evictClient( @Auth User user, @PathParam("clientId") LongParam clientId, @PathParam("groupId") LongParam groupId) { logger.info("User {} evicting clientId {} from groupId {}.", user.getName(), clientId, groupId); try { aclDAO.findAndEvictClient(clientId.get(), groupId.get(), auditLog, user.getName(), new HashMap<>()); } catch (IllegalStateException e) { throw new NotFoundException(); } return Response.ok().build(); } @Inject  MembershipResource(AclDAOFactory aclDAOFactory, AuditLog auditLog); @VisibleForTesting  MembershipResource(AclDAO aclDAO, AuditLog auditLog); @Path("/secrets/{secretId}/groups/{groupId}") @Timed @ExceptionMetered @PUT Response allowAccess(
      @Auth User user,
      @PathParam("secretId") LongParam secretId,
      @PathParam("groupId") LongParam groupId); @Path("/secrets/{secretId}/groups/{groupId}") @Timed @ExceptionMetered @DELETE Response disallowAccess(
      @Auth User user,
      @PathParam("secretId") LongParam secretId,
      @PathParam("groupId") LongParam groupId); @Path("/clients/{clientId}/groups/{groupId}") @Timed @ExceptionMetered @PUT Response enrollClient(
    @Auth User user,
    @PathParam("clientId") LongParam clientId,
    @PathParam("groupId") LongParam groupId); @Path("/clients/{clientId}/groups/{groupId}") @Timed @ExceptionMetered @DELETE Response evictClient(
      @Auth User user,
      @PathParam("clientId") LongParam clientId,
      @PathParam("groupId") LongParam groupId);  }
@Test public void canEvict() { resource.evictClient(user, new LongParam(Long.toString(client.getId())), new LongParam(Long.toString(group.getId()))); verify(aclDAO).findAndEvictClient(client.getId(), group.getId(), auditLog, "user",new HashMap<>()); }
@Test(expected = NotFoundException.class) public void evictThrowsWhenClientIdNotFound() { doThrow(IllegalStateException.class).when(aclDAO).findAndEvictClient(60984, group.getId(), auditLog, "user",new HashMap<>()); resource.evictClient(user, new LongParam("60984"), new LongParam(Long.toString(group.getId()))); }
@Test(expected = NotFoundException.class) public void evictThrowsWhenGroupIdNotFound() { doThrow(IllegalStateException.class).when(aclDAO).findAndEvictClient(client.getId(), 0xbad2, auditLog, "user",new HashMap<>()); resource.evictClient(user, new LongParam(Long.toString(client.getId())), new LongParam(Long.toString(0xbad2))); }