@Test public void testExecuteException() { JUnit4Mockery mockContext = new JUnit4Mockery() { { setImposteriser(ClassImposteriser.INSTANCE); } }; final DomainMapper followerMapper = mockContext.mock(DomainMapper.class, "followerMapper"); final DomainMapper followedMapper = mockContext.mock(DomainMapper.class, "followedMapper"); sut = new AddCachedGroupFollower(followedMapper, followerMapper); mockContext.checking(new Expectations() { { allowing(followerMapper).execute(TEST_GROUP_ID_1); will(throwException(new PersistenceException())); allowing(followedMapper).execute(TEST_GROUP_ID_1); will(throwException(new PersistenceException())); } }); assertFalse(sut.execute(TEST_PERSON_ID_1, TEST_GROUP_ID_1)); mockContext.assertIsSatisfied(); }
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);  }