@Test public void testExecuteWhenFollowedInCache() { getCache().setList(keyFollowed, followedGroupIds); context.checking(new Expectations() { { oneOf(getPrivateGroupIdsMapper).execute(personId); will(returnValue(privateGroupIds)); } }); Set<Long> results = sut.execute(personId); assertResultsContainGroups(results); context.assertIsSatisfied(); }
@SuppressWarnings("unchecked") public Set<Long> execute(final Long inUserPersonId) { log.info("Requesting both lists from cache in parallel for user #" + inUserPersonId); String privateCoordinatedGroupIdsKey = CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + inUserPersonId; String followedGroupIdsKey = CacheKeys.GROUPS_FOLLOWED_BY_PERSON + inUserPersonId; List<String> cacheKeys = new ArrayList<String>(); cacheKeys.add(privateCoordinatedGroupIdsKey); cacheKeys.add(followedGroupIdsKey); Set<Long> privateGroupIds = (Set<Long>) getCache().get(privateCoordinatedGroupIdsKey); if (privateGroupIds == null) { log.info("Couldn't find the private group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetPrivateGroupsByUserId"); privateGroupIds = getPrivateGroupIdsMapper.execute(inUserPersonId); } List<Long> followedGroupIds = getCache().getList(followedGroupIdsKey); if (followedGroupIds == null) { log.info("Couldn't find the followed group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetFollowedGroupIds"); followedGroupIds = getFollowedGroupIdsMapper.execute(inUserPersonId); } Set<Long> groupIds = new HashSet<Long>(); groupIds.addAll(privateGroupIds); groupIds.addAll(followedGroupIds); return groupIds; }
GetPrivateCoordinatedAndFollowedGroupIdsForUser extends CachedDomainMapper { @SuppressWarnings("unchecked") public Set<Long> execute(final Long inUserPersonId) { log.info("Requesting both lists from cache in parallel for user #" + inUserPersonId); String privateCoordinatedGroupIdsKey = CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + inUserPersonId; String followedGroupIdsKey = CacheKeys.GROUPS_FOLLOWED_BY_PERSON + inUserPersonId; List<String> cacheKeys = new ArrayList<String>(); cacheKeys.add(privateCoordinatedGroupIdsKey); cacheKeys.add(followedGroupIdsKey); Set<Long> privateGroupIds = (Set<Long>) getCache().get(privateCoordinatedGroupIdsKey); if (privateGroupIds == null) { log.info("Couldn't find the private group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetPrivateGroupsByUserId"); privateGroupIds = getPrivateGroupIdsMapper.execute(inUserPersonId); } List<Long> followedGroupIds = getCache().getList(followedGroupIdsKey); if (followedGroupIds == null) { log.info("Couldn't find the followed group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetFollowedGroupIds"); followedGroupIds = getFollowedGroupIdsMapper.execute(inUserPersonId); } Set<Long> groupIds = new HashSet<Long>(); groupIds.addAll(privateGroupIds); groupIds.addAll(followedGroupIds); return groupIds; } }
GetPrivateCoordinatedAndFollowedGroupIdsForUser extends CachedDomainMapper { @SuppressWarnings("unchecked") public Set<Long> execute(final Long inUserPersonId) { log.info("Requesting both lists from cache in parallel for user #" + inUserPersonId); String privateCoordinatedGroupIdsKey = CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + inUserPersonId; String followedGroupIdsKey = CacheKeys.GROUPS_FOLLOWED_BY_PERSON + inUserPersonId; List<String> cacheKeys = new ArrayList<String>(); cacheKeys.add(privateCoordinatedGroupIdsKey); cacheKeys.add(followedGroupIdsKey); Set<Long> privateGroupIds = (Set<Long>) getCache().get(privateCoordinatedGroupIdsKey); if (privateGroupIds == null) { log.info("Couldn't find the private group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetPrivateGroupsByUserId"); privateGroupIds = getPrivateGroupIdsMapper.execute(inUserPersonId); } List<Long> followedGroupIds = getCache().getList(followedGroupIdsKey); if (followedGroupIds == null) { log.info("Couldn't find the followed group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetFollowedGroupIds"); followedGroupIds = getFollowedGroupIdsMapper.execute(inUserPersonId); } Set<Long> groupIds = new HashSet<Long>(); groupIds.addAll(privateGroupIds); groupIds.addAll(followedGroupIds); return groupIds; } GetPrivateCoordinatedAndFollowedGroupIdsForUser(
            final DomainMapper<Long, Set<Long>> inGetPrivateGroupIdsMapper,
            final DomainMapper<Long, List<Long>> inGetFollowedGroupIdsMapper); }
GetPrivateCoordinatedAndFollowedGroupIdsForUser extends CachedDomainMapper { @SuppressWarnings("unchecked") public Set<Long> execute(final Long inUserPersonId) { log.info("Requesting both lists from cache in parallel for user #" + inUserPersonId); String privateCoordinatedGroupIdsKey = CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + inUserPersonId; String followedGroupIdsKey = CacheKeys.GROUPS_FOLLOWED_BY_PERSON + inUserPersonId; List<String> cacheKeys = new ArrayList<String>(); cacheKeys.add(privateCoordinatedGroupIdsKey); cacheKeys.add(followedGroupIdsKey); Set<Long> privateGroupIds = (Set<Long>) getCache().get(privateCoordinatedGroupIdsKey); if (privateGroupIds == null) { log.info("Couldn't find the private group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetPrivateGroupsByUserId"); privateGroupIds = getPrivateGroupIdsMapper.execute(inUserPersonId); } List<Long> followedGroupIds = getCache().getList(followedGroupIdsKey); if (followedGroupIds == null) { log.info("Couldn't find the followed group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetFollowedGroupIds"); followedGroupIds = getFollowedGroupIdsMapper.execute(inUserPersonId); } Set<Long> groupIds = new HashSet<Long>(); groupIds.addAll(privateGroupIds); groupIds.addAll(followedGroupIds); return groupIds; } GetPrivateCoordinatedAndFollowedGroupIdsForUser(
            final DomainMapper<Long, Set<Long>> inGetPrivateGroupIdsMapper,
            final DomainMapper<Long, List<Long>> inGetFollowedGroupIdsMapper); @SuppressWarnings("unchecked") Set<Long> execute(final Long inUserPersonId); }
GetPrivateCoordinatedAndFollowedGroupIdsForUser extends CachedDomainMapper { @SuppressWarnings("unchecked") public Set<Long> execute(final Long inUserPersonId) { log.info("Requesting both lists from cache in parallel for user #" + inUserPersonId); String privateCoordinatedGroupIdsKey = CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + inUserPersonId; String followedGroupIdsKey = CacheKeys.GROUPS_FOLLOWED_BY_PERSON + inUserPersonId; List<String> cacheKeys = new ArrayList<String>(); cacheKeys.add(privateCoordinatedGroupIdsKey); cacheKeys.add(followedGroupIdsKey); Set<Long> privateGroupIds = (Set<Long>) getCache().get(privateCoordinatedGroupIdsKey); if (privateGroupIds == null) { log.info("Couldn't find the private group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetPrivateGroupsByUserId"); privateGroupIds = getPrivateGroupIdsMapper.execute(inUserPersonId); } List<Long> followedGroupIds = getCache().getList(followedGroupIdsKey); if (followedGroupIds == null) { log.info("Couldn't find the followed group ids via org/group coordinator access in cache for user #" + inUserPersonId + ", using GetFollowedGroupIds"); followedGroupIds = getFollowedGroupIdsMapper.execute(inUserPersonId); } Set<Long> groupIds = new HashSet<Long>(); groupIds.addAll(privateGroupIds); groupIds.addAll(followedGroupIds); return groupIds; } GetPrivateCoordinatedAndFollowedGroupIdsForUser(
            final DomainMapper<Long, Set<Long>> inGetPrivateGroupIdsMapper,
            final DomainMapper<Long, List<Long>> inGetFollowedGroupIdsMapper); @SuppressWarnings("unchecked") Set<Long> execute(final Long inUserPersonId);  }