@Test public void testExecute() { List<Long> groupFollowerIds = cache.getList(CacheKeys.FOLLOWERS_BY_GROUP + TEST_GROUP_ID_1); assertEquals(3, groupFollowerIds.size()); assertTrue(groupFollowerIds.contains(TEST_PERSON_ID_1)); assertTrue(groupFollowerIds.contains(TEST_PERSON_ID_2)); assertTrue(groupFollowerIds.contains(TEST_PERSON_ID_4)); List<Long> groupIdsFollowing = cache.getList(CacheKeys.GROUPS_FOLLOWED_BY_PERSON + TEST_PERSON_ID_3); assertNull(groupIdsFollowing); sut.execute(TEST_PERSON_ID_3, TEST_GROUP_ID_1); List<Long> updatedGroupFollowerIds = cache.getList(CacheKeys.FOLLOWERS_BY_GROUP + TEST_GROUP_ID_1); assertEquals(4, updatedGroupFollowerIds.size()); assertTrue(updatedGroupFollowerIds.contains(TEST_PERSON_ID_1)); assertTrue(updatedGroupFollowerIds.contains(TEST_PERSON_ID_2)); assertTrue(updatedGroupFollowerIds.contains(TEST_PERSON_ID_3)); assertTrue(groupFollowerIds.contains(TEST_PERSON_ID_4)); List<Long> updatedGroupIdsFollowing = cache.getList(CacheKeys.GROUPS_FOLLOWED_BY_PERSON + TEST_PERSON_ID_3); assertEquals(1, updatedGroupIdsFollowing.size()); assertTrue(updatedGroupIdsFollowing.contains(TEST_GROUP_ID_1)); }
public Boolean execute(final Long followerId, final Long followingId) { try { List<Long> followers = followerMapper.execute(followingId); if (!followers.contains(followerId)) { getCache().addToTopOfList(CacheKeys.FOLLOWERS_BY_GROUP + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.GROUPS_FOLLOWED_BY_PERSON + followerId, followingId); } } catch (Exception ex) { logger.error("Error occurred updating the cached for a new following relationship.", ex); return false; } return true; }
AddCachedGroupFollower extends CachedDomainMapper { public Boolean execute(final Long followerId, final Long followingId) { try { List<Long> followers = followerMapper.execute(followingId); if (!followers.contains(followerId)) { getCache().addToTopOfList(CacheKeys.FOLLOWERS_BY_GROUP + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.GROUPS_FOLLOWED_BY_PERSON + followerId, followingId); } } catch (Exception ex) { logger.error("Error occurred updating the cached for a new following relationship.", ex); return false; } return true; } }
AddCachedGroupFollower extends CachedDomainMapper { public Boolean execute(final Long followerId, final Long followingId) { try { List<Long> followers = followerMapper.execute(followingId); if (!followers.contains(followerId)) { getCache().addToTopOfList(CacheKeys.FOLLOWERS_BY_GROUP + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.GROUPS_FOLLOWED_BY_PERSON + followerId, followingId); } } catch (Exception ex) { logger.error("Error occurred updating the cached for a new following relationship.", ex); return false; } return true; } AddCachedGroupFollower(final DomainMapper<Long, List<Long>> inFollowedMapper,
            final DomainMapper<Long, List<Long>> inFollowerMapper); }
AddCachedGroupFollower extends CachedDomainMapper { public Boolean execute(final Long followerId, final Long followingId) { try { List<Long> followers = followerMapper.execute(followingId); if (!followers.contains(followerId)) { getCache().addToTopOfList(CacheKeys.FOLLOWERS_BY_GROUP + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.GROUPS_FOLLOWED_BY_PERSON + followerId, followingId); } } catch (Exception ex) { logger.error("Error occurred updating the cached for a new following relationship.", ex); return false; } return true; } AddCachedGroupFollower(final DomainMapper<Long, List<Long>> inFollowedMapper,
            final DomainMapper<Long, List<Long>> inFollowerMapper); Boolean execute(final Long followerId, final Long followingId); }
AddCachedGroupFollower extends CachedDomainMapper { public Boolean execute(final Long followerId, final Long followingId) { try { List<Long> followers = followerMapper.execute(followingId); if (!followers.contains(followerId)) { getCache().addToTopOfList(CacheKeys.FOLLOWERS_BY_GROUP + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.GROUPS_FOLLOWED_BY_PERSON + followerId, followingId); } } catch (Exception ex) { logger.error("Error occurred updating the cached for a new following relationship.", ex); return false; } return true; } AddCachedGroupFollower(final DomainMapper<Long, List<Long>> inFollowedMapper,
            final DomainMapper<Long, List<Long>> inFollowerMapper); Boolean execute(final Long followerId, final Long followingId);  }