@Test public void testExecuteFollowingAPersonAlreadyFollowed() { List<Long> personFollowerIds = cache.getList(CacheKeys.FOLLOWERS_BY_PERSON + TEST_PERSON_ID_1); assertEquals(3, personFollowerIds.size()); assertTrue(personFollowerIds.contains(TEST_PERSON_ID_2)); assertTrue(personFollowerIds.contains(TEST_PERSON_ID_3)); List<Long> peopleFollowedIds = cache.getList(CacheKeys.PEOPLE_FOLLOWED_BY_PERSON + TEST_PERSON_ID_2); assertEquals(2, peopleFollowedIds.size()); assertTrue(peopleFollowedIds.contains(TEST_PERSON_ID_1)); sut.execute(TEST_PERSON_ID_2, TEST_PERSON_ID_1); List<Long> updatedPersonFollowerIds = cache.getList(CacheKeys.FOLLOWERS_BY_PERSON + TEST_PERSON_ID_1); assertEquals(3, updatedPersonFollowerIds.size()); assertTrue(updatedPersonFollowerIds.contains(TEST_PERSON_ID_2)); assertTrue(updatedPersonFollowerIds.contains(TEST_PERSON_ID_3)); List<Long> updatedPeopleFollowedIds = cache.getList(CacheKeys.PEOPLE_FOLLOWED_BY_PERSON + TEST_PERSON_ID_2); assertEquals(2, updatedPeopleFollowedIds.size()); assertTrue(updatedPeopleFollowedIds.contains(TEST_PERSON_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_PERSON + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.PEOPLE_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; }
AddCachedPersonFollower 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_PERSON + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.PEOPLE_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; } }
AddCachedPersonFollower 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_PERSON + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.PEOPLE_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; } AddCachedPersonFollower(final DomainMapper<Long, List<Long>> inFollowedMapper,
            final DomainMapper<Long, List<Long>> inFollowerMapper); }
AddCachedPersonFollower 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_PERSON + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.PEOPLE_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; } AddCachedPersonFollower(final DomainMapper<Long, List<Long>> inFollowedMapper,
            final DomainMapper<Long, List<Long>> inFollowerMapper); Boolean execute(final Long followerId, final Long followingId); }
AddCachedPersonFollower 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_PERSON + followingId, followerId); } List<Long> following = followedMapper.execute(followerId); if (!following.contains(followingId)) { getCache().addToTopOfList(CacheKeys.PEOPLE_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; } AddCachedPersonFollower(final DomainMapper<Long, List<Long>> inFollowedMapper,
            final DomainMapper<Long, List<Long>> inFollowerMapper); Boolean execute(final Long followerId, final Long followingId);  }