@Test public final void testPerformAction() throws Exception { final RequestForGroupMembershipRequest mapperRqst = new RequestForGroupMembershipRequest(GROUP_ID, USER_ID); context.checking(new Expectations() { { allowing(groupMapper).findByShortName(GROUP_SHORTNAME); will(returnValue(groupMock)); allowing(groupMock).getId(); will(returnValue(GROUP_ID)); oneOf(insertMembershipRequestMapper).execute(with(equalInternally(mapperRqst))); } }); List<UserActionRequest> uaRequests = callExecute(); assertEquals(1, uaRequests.size()); UserActionRequest uaRequest = uaRequests.get(0); assertEquals("createNotificationsAction", uaRequest.getActionKey()); TargetEntityNotificationsRequest request = (TargetEntityNotificationsRequest) uaRequest.getParams(); assertEquals(RequestType.REQUEST_GROUP_ACCESS, request.getType()); assertEquals(USER_ID, request.getActorId()); assertEquals(GROUP_ID, request.getTargetEntityId()); }
@Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { DomainGroupShortNameRequest request = (DomainGroupShortNameRequest) inActionContext.getActionContext() .getParams(); DomainGroup target = groupMapper.findByShortName(request.getGroupShortName()); if (null == target) { throw new IllegalArgumentException("Tried to send a request for access to an invalid group" + request.getGroupShortName()); } long personId = inActionContext.getActionContext().getPrincipal().getId(); insertMembershipRequestMapper.execute(new RequestForGroupMembershipRequest(target.getId(), personId)); inActionContext.getUserActionRequests().add( new UserActionRequest(CreateNotificationsRequest.ACTION_NAME, null, new TargetEntityNotificationsRequest(RequestType.REQUEST_GROUP_ACCESS, personId, target .getId()))); return null; }
SendGroupAccessRequestExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { DomainGroupShortNameRequest request = (DomainGroupShortNameRequest) inActionContext.getActionContext() .getParams(); DomainGroup target = groupMapper.findByShortName(request.getGroupShortName()); if (null == target) { throw new IllegalArgumentException("Tried to send a request for access to an invalid group" + request.getGroupShortName()); } long personId = inActionContext.getActionContext().getPrincipal().getId(); insertMembershipRequestMapper.execute(new RequestForGroupMembershipRequest(target.getId(), personId)); inActionContext.getUserActionRequests().add( new UserActionRequest(CreateNotificationsRequest.ACTION_NAME, null, new TargetEntityNotificationsRequest(RequestType.REQUEST_GROUP_ACCESS, personId, target .getId()))); return null; } }
SendGroupAccessRequestExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { DomainGroupShortNameRequest request = (DomainGroupShortNameRequest) inActionContext.getActionContext() .getParams(); DomainGroup target = groupMapper.findByShortName(request.getGroupShortName()); if (null == target) { throw new IllegalArgumentException("Tried to send a request for access to an invalid group" + request.getGroupShortName()); } long personId = inActionContext.getActionContext().getPrincipal().getId(); insertMembershipRequestMapper.execute(new RequestForGroupMembershipRequest(target.getId(), personId)); inActionContext.getUserActionRequests().add( new UserActionRequest(CreateNotificationsRequest.ACTION_NAME, null, new TargetEntityNotificationsRequest(RequestType.REQUEST_GROUP_ACCESS, personId, target .getId()))); return null; } SendGroupAccessRequestExecution(final DomainGroupMapper inGroupMapper,
            final InsertRequestForGroupMembership inInsertMembershipRequestMapper); }
SendGroupAccessRequestExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { DomainGroupShortNameRequest request = (DomainGroupShortNameRequest) inActionContext.getActionContext() .getParams(); DomainGroup target = groupMapper.findByShortName(request.getGroupShortName()); if (null == target) { throw new IllegalArgumentException("Tried to send a request for access to an invalid group" + request.getGroupShortName()); } long personId = inActionContext.getActionContext().getPrincipal().getId(); insertMembershipRequestMapper.execute(new RequestForGroupMembershipRequest(target.getId(), personId)); inActionContext.getUserActionRequests().add( new UserActionRequest(CreateNotificationsRequest.ACTION_NAME, null, new TargetEntityNotificationsRequest(RequestType.REQUEST_GROUP_ACCESS, personId, target .getId()))); return null; } SendGroupAccessRequestExecution(final DomainGroupMapper inGroupMapper,
            final InsertRequestForGroupMembership inInsertMembershipRequestMapper); @Override Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext); }
SendGroupAccessRequestExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { DomainGroupShortNameRequest request = (DomainGroupShortNameRequest) inActionContext.getActionContext() .getParams(); DomainGroup target = groupMapper.findByShortName(request.getGroupShortName()); if (null == target) { throw new IllegalArgumentException("Tried to send a request for access to an invalid group" + request.getGroupShortName()); } long personId = inActionContext.getActionContext().getPrincipal().getId(); insertMembershipRequestMapper.execute(new RequestForGroupMembershipRequest(target.getId(), personId)); inActionContext.getUserActionRequests().add( new UserActionRequest(CreateNotificationsRequest.ACTION_NAME, null, new TargetEntityNotificationsRequest(RequestType.REQUEST_GROUP_ACCESS, personId, target .getId()))); return null; } SendGroupAccessRequestExecution(final DomainGroupMapper inGroupMapper,
            final InsertRequestForGroupMembership inInsertMembershipRequestMapper); @Override Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext);  }