@Test public void testPerformActionWithPrivateGroupCreatePending() throws Exception { final Long coord1 = 3827L; final Long coord2 = 3828L; final Long coord3 = 3829L; final List<Long> coordIds = new ArrayList<Long>(3); coordIds.add(coord1); coordIds.add(coord2); coordIds.add(coord3); context.checking(new Expectations() { { oneOf(actionContext).getParams(); will(returnValue(request)); allowing(request).getDomainGroupId(); will(returnValue(groupId)); oneOf(groupMapper).findById(groupId); will(returnValue(groupMock)); oneOf(groupCoordinatorCacheMock).execute(groupMock); will(returnValue(coordIds)); oneOf(request).getIsUpdate(); will(returnValue(false)); allowing(groupMock).getShortName(); will(returnValue(groupName)); oneOf(getActivityIdsAuthordedByEntityDbMapper).execute(groupName, EntityType.GROUP); will(returnValue(activityIds)); exactly(activityIds.size()).of(cacheMock).delete(with(any(String.class))); oneOf(groupMock).isPublicGroup(); will(returnValue(false)); oneOf(groupMock).isPending(); will(returnValue(true)); } }); sut.execute(actionContext); context.assertIsSatisfied(); }
public final Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (log.isDebugEnabled()) { log.debug("Performing action"); } DomainGroupCacheUpdaterRequest request = (DomainGroupCacheUpdaterRequest) inActionContext.getParams(); Long domainGroupId = request.getDomainGroupId(); log.info("Loading domain group by id #" + domainGroupId); DomainGroup domainGroup = domainGroupMapper.findById(domainGroupId); log.info("Updating the cached list of coordinators for group #" + domainGroupId + " from the database"); List<Long> peopleIds = groupCoordinatorCacheManager.execute(domainGroup); if (!domainGroup.isPublicGroup()) { if (request.getIsUpdate()) { log.info("Looping across the coordinators to update" + " their private group access list to include the group #" + domainGroupId); for (Long coordinatorPersonId : peopleIds) { cache.addToSet(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + coordinatorPersonId, domainGroupId); } } else if (!domainGroup.isPending()) { addPrivateGroupIdToCachedListMapper.execute(domainGroupId); } } List<Long> activityIds = getActivityIdsAuthordedByEntityDbMapper.execute(domainGroup.getShortName(), EntityType.GROUP); if (log.isInfoEnabled()) { log.info("Found info for '" + domainGroup.getShortName() + "' - applying it to " + activityIds.size() + " activities."); } for (Long activityId : activityIds) { cache.delete(CacheKeys.ACTIVITY_BY_ID + activityId); } if (log.isDebugEnabled()) { log.debug("Action complete"); } return null; }
DomainGroupCacheUpdaterAsyncExecution implements ExecutionStrategy<ActionContext> { public final Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (log.isDebugEnabled()) { log.debug("Performing action"); } DomainGroupCacheUpdaterRequest request = (DomainGroupCacheUpdaterRequest) inActionContext.getParams(); Long domainGroupId = request.getDomainGroupId(); log.info("Loading domain group by id #" + domainGroupId); DomainGroup domainGroup = domainGroupMapper.findById(domainGroupId); log.info("Updating the cached list of coordinators for group #" + domainGroupId + " from the database"); List<Long> peopleIds = groupCoordinatorCacheManager.execute(domainGroup); if (!domainGroup.isPublicGroup()) { if (request.getIsUpdate()) { log.info("Looping across the coordinators to update" + " their private group access list to include the group #" + domainGroupId); for (Long coordinatorPersonId : peopleIds) { cache.addToSet(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + coordinatorPersonId, domainGroupId); } } else if (!domainGroup.isPending()) { addPrivateGroupIdToCachedListMapper.execute(domainGroupId); } } List<Long> activityIds = getActivityIdsAuthordedByEntityDbMapper.execute(domainGroup.getShortName(), EntityType.GROUP); if (log.isInfoEnabled()) { log.info("Found info for '" + domainGroup.getShortName() + "' - applying it to " + activityIds.size() + " activities."); } for (Long activityId : activityIds) { cache.delete(CacheKeys.ACTIVITY_BY_ID + activityId); } if (log.isDebugEnabled()) { log.debug("Action complete"); } return null; } }
DomainGroupCacheUpdaterAsyncExecution implements ExecutionStrategy<ActionContext> { public final Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (log.isDebugEnabled()) { log.debug("Performing action"); } DomainGroupCacheUpdaterRequest request = (DomainGroupCacheUpdaterRequest) inActionContext.getParams(); Long domainGroupId = request.getDomainGroupId(); log.info("Loading domain group by id #" + domainGroupId); DomainGroup domainGroup = domainGroupMapper.findById(domainGroupId); log.info("Updating the cached list of coordinators for group #" + domainGroupId + " from the database"); List<Long> peopleIds = groupCoordinatorCacheManager.execute(domainGroup); if (!domainGroup.isPublicGroup()) { if (request.getIsUpdate()) { log.info("Looping across the coordinators to update" + " their private group access list to include the group #" + domainGroupId); for (Long coordinatorPersonId : peopleIds) { cache.addToSet(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + coordinatorPersonId, domainGroupId); } } else if (!domainGroup.isPending()) { addPrivateGroupIdToCachedListMapper.execute(domainGroupId); } } List<Long> activityIds = getActivityIdsAuthordedByEntityDbMapper.execute(domainGroup.getShortName(), EntityType.GROUP); if (log.isInfoEnabled()) { log.info("Found info for '" + domainGroup.getShortName() + "' - applying it to " + activityIds.size() + " activities."); } for (Long activityId : activityIds) { cache.delete(CacheKeys.ACTIVITY_BY_ID + activityId); } if (log.isDebugEnabled()) { log.debug("Action complete"); } return null; } DomainGroupCacheUpdaterAsyncExecution(
            final GetActivityIdsAuthoredByOrOriginallyAuthoredByEntity inGetActivityIdsAuthordedByEntityDbMapper,
            final SaveDomainGroupCoordinatorsListToCache inGroupCoordinatorCacheManager,
            final DomainGroupMapper inDomainGroupMapper,
            final AddPrivateGroupIdToCachedCoordinatorAccessList inAddPrivateGroupIdToCachedListMapper,
            final Cache inCache); }
DomainGroupCacheUpdaterAsyncExecution implements ExecutionStrategy<ActionContext> { public final Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (log.isDebugEnabled()) { log.debug("Performing action"); } DomainGroupCacheUpdaterRequest request = (DomainGroupCacheUpdaterRequest) inActionContext.getParams(); Long domainGroupId = request.getDomainGroupId(); log.info("Loading domain group by id #" + domainGroupId); DomainGroup domainGroup = domainGroupMapper.findById(domainGroupId); log.info("Updating the cached list of coordinators for group #" + domainGroupId + " from the database"); List<Long> peopleIds = groupCoordinatorCacheManager.execute(domainGroup); if (!domainGroup.isPublicGroup()) { if (request.getIsUpdate()) { log.info("Looping across the coordinators to update" + " their private group access list to include the group #" + domainGroupId); for (Long coordinatorPersonId : peopleIds) { cache.addToSet(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + coordinatorPersonId, domainGroupId); } } else if (!domainGroup.isPending()) { addPrivateGroupIdToCachedListMapper.execute(domainGroupId); } } List<Long> activityIds = getActivityIdsAuthordedByEntityDbMapper.execute(domainGroup.getShortName(), EntityType.GROUP); if (log.isInfoEnabled()) { log.info("Found info for '" + domainGroup.getShortName() + "' - applying it to " + activityIds.size() + " activities."); } for (Long activityId : activityIds) { cache.delete(CacheKeys.ACTIVITY_BY_ID + activityId); } if (log.isDebugEnabled()) { log.debug("Action complete"); } return null; } DomainGroupCacheUpdaterAsyncExecution(
            final GetActivityIdsAuthoredByOrOriginallyAuthoredByEntity inGetActivityIdsAuthordedByEntityDbMapper,
            final SaveDomainGroupCoordinatorsListToCache inGroupCoordinatorCacheManager,
            final DomainGroupMapper inDomainGroupMapper,
            final AddPrivateGroupIdToCachedCoordinatorAccessList inAddPrivateGroupIdToCachedListMapper,
            final Cache inCache); final Serializable execute(final ActionContext inActionContext); }
DomainGroupCacheUpdaterAsyncExecution implements ExecutionStrategy<ActionContext> { public final Serializable execute(final ActionContext inActionContext) throws ExecutionException { if (log.isDebugEnabled()) { log.debug("Performing action"); } DomainGroupCacheUpdaterRequest request = (DomainGroupCacheUpdaterRequest) inActionContext.getParams(); Long domainGroupId = request.getDomainGroupId(); log.info("Loading domain group by id #" + domainGroupId); DomainGroup domainGroup = domainGroupMapper.findById(domainGroupId); log.info("Updating the cached list of coordinators for group #" + domainGroupId + " from the database"); List<Long> peopleIds = groupCoordinatorCacheManager.execute(domainGroup); if (!domainGroup.isPublicGroup()) { if (request.getIsUpdate()) { log.info("Looping across the coordinators to update" + " their private group access list to include the group #" + domainGroupId); for (Long coordinatorPersonId : peopleIds) { cache.addToSet(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + coordinatorPersonId, domainGroupId); } } else if (!domainGroup.isPending()) { addPrivateGroupIdToCachedListMapper.execute(domainGroupId); } } List<Long> activityIds = getActivityIdsAuthordedByEntityDbMapper.execute(domainGroup.getShortName(), EntityType.GROUP); if (log.isInfoEnabled()) { log.info("Found info for '" + domainGroup.getShortName() + "' - applying it to " + activityIds.size() + " activities."); } for (Long activityId : activityIds) { cache.delete(CacheKeys.ACTIVITY_BY_ID + activityId); } if (log.isDebugEnabled()) { log.debug("Action complete"); } return null; } DomainGroupCacheUpdaterAsyncExecution(
            final GetActivityIdsAuthoredByOrOriginallyAuthoredByEntity inGetActivityIdsAuthordedByEntityDbMapper,
            final SaveDomainGroupCoordinatorsListToCache inGroupCoordinatorCacheManager,
            final DomainGroupMapper inDomainGroupMapper,
            final AddPrivateGroupIdToCachedCoordinatorAccessList inAddPrivateGroupIdToCachedListMapper,
            final Cache inCache); final Serializable execute(final ActionContext inActionContext);  }