@Test public void testExecuteGroupActivity() { final long activityId = 884872L; PostCachedActivity sut = new PostCachedActivity(personFollowersMapper, getPersonModelViewByAccountIdMapper); sut.setCache(cache); final DomainGroupModelView group = new DomainGroupModelView(); final List<DomainGroupModelView> groups = new ArrayList<DomainGroupModelView>(); groups.add(group); final List<String> orgShortNames = new ArrayList<String>(); final String orgShortName1 = "abcdefg"; final String orgShortName2 = "abcdefgh"; final String orgShortName3 = "abcdefgi"; orgShortNames.add(orgShortName1); orgShortNames.add(orgShortName2); orgShortNames.add(orgShortName3); final Activity act = context.mock(Activity.class); final StreamScope recipStreamScope = context.mock(StreamScope.class); context.checking(new Expectations() { { oneOf(cache).addToTopOfList(CacheKeys.EVERYONE_ACTIVITY_IDS, activityId); allowing(act).getId(); will(returnValue(activityId)); allowing(act).getRecipientStreamScope(); will(returnValue(recipStreamScope)); allowing(recipStreamScope).getScopeType(); will(returnValue(ScopeType.GROUP)); allowing(recipStreamScope).getUniqueKey(); will(returnValue("blah")); allowing(act).getSharedLink(); will(returnValue(null)); allowing(act).getShowInStream(); will(returnValue(true)); } }); sut.execute(act); context.assertIsSatisfied(); }
public void execute(final Activity activity) { ScopeType type = activity.getRecipientStreamScope().getScopeType(); String recipientUniqueKey = activity.getRecipientStreamScope().getUniqueKey(); long activityId = activity.getId(); if (type == ScopeType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(recipientUniqueKey); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } else if (type == ScopeType.RESOURCE && activity.getActorType() == EntityType.PERSON) { if (activity.getShowInStream()) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity.getActorId()); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } } else if (type == ScopeType.GROUP) { int donothing = 1; } else { throw new RuntimeException("Unexpected Activity destination stream type: " + type); } if (activity.getSharedLink() != null) { log.info("Adding activity with a shared resource (id:" + activity.getSharedLink().getStreamScope().getId() + ") to the top of the shared resource's cached activity stream."); getCache() .addToTopOfList( CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getSharedLink().getStreamScope().getId(), activityId); } if (activity.getShowInStream()) { log.trace("Adding activity id " + activityId + " into everyone activity list."); getCache().addToTopOfList(CacheKeys.EVERYONE_ACTIVITY_IDS, activityId); } }
PostCachedActivity extends CachedDomainMapper { public void execute(final Activity activity) { ScopeType type = activity.getRecipientStreamScope().getScopeType(); String recipientUniqueKey = activity.getRecipientStreamScope().getUniqueKey(); long activityId = activity.getId(); if (type == ScopeType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(recipientUniqueKey); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } else if (type == ScopeType.RESOURCE && activity.getActorType() == EntityType.PERSON) { if (activity.getShowInStream()) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity.getActorId()); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } } else if (type == ScopeType.GROUP) { int donothing = 1; } else { throw new RuntimeException("Unexpected Activity destination stream type: " + type); } if (activity.getSharedLink() != null) { log.info("Adding activity with a shared resource (id:" + activity.getSharedLink().getStreamScope().getId() + ") to the top of the shared resource's cached activity stream."); getCache() .addToTopOfList( CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getSharedLink().getStreamScope().getId(), activityId); } if (activity.getShowInStream()) { log.trace("Adding activity id " + activityId + " into everyone activity list."); getCache().addToTopOfList(CacheKeys.EVERYONE_ACTIVITY_IDS, activityId); } } }
PostCachedActivity extends CachedDomainMapper { public void execute(final Activity activity) { ScopeType type = activity.getRecipientStreamScope().getScopeType(); String recipientUniqueKey = activity.getRecipientStreamScope().getUniqueKey(); long activityId = activity.getId(); if (type == ScopeType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(recipientUniqueKey); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } else if (type == ScopeType.RESOURCE && activity.getActorType() == EntityType.PERSON) { if (activity.getShowInStream()) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity.getActorId()); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } } else if (type == ScopeType.GROUP) { int donothing = 1; } else { throw new RuntimeException("Unexpected Activity destination stream type: " + type); } if (activity.getSharedLink() != null) { log.info("Adding activity with a shared resource (id:" + activity.getSharedLink().getStreamScope().getId() + ") to the top of the shared resource's cached activity stream."); getCache() .addToTopOfList( CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getSharedLink().getStreamScope().getId(), activityId); } if (activity.getShowInStream()) { log.trace("Adding activity id " + activityId + " into everyone activity list."); getCache().addToTopOfList(CacheKeys.EVERYONE_ACTIVITY_IDS, activityId); } } PostCachedActivity(final DomainMapper<Long, List<Long>> inPersonFollowersMapper,
            final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper); }
PostCachedActivity extends CachedDomainMapper { public void execute(final Activity activity) { ScopeType type = activity.getRecipientStreamScope().getScopeType(); String recipientUniqueKey = activity.getRecipientStreamScope().getUniqueKey(); long activityId = activity.getId(); if (type == ScopeType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(recipientUniqueKey); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } else if (type == ScopeType.RESOURCE && activity.getActorType() == EntityType.PERSON) { if (activity.getShowInStream()) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity.getActorId()); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } } else if (type == ScopeType.GROUP) { int donothing = 1; } else { throw new RuntimeException("Unexpected Activity destination stream type: " + type); } if (activity.getSharedLink() != null) { log.info("Adding activity with a shared resource (id:" + activity.getSharedLink().getStreamScope().getId() + ") to the top of the shared resource's cached activity stream."); getCache() .addToTopOfList( CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getSharedLink().getStreamScope().getId(), activityId); } if (activity.getShowInStream()) { log.trace("Adding activity id " + activityId + " into everyone activity list."); getCache().addToTopOfList(CacheKeys.EVERYONE_ACTIVITY_IDS, activityId); } } PostCachedActivity(final DomainMapper<Long, List<Long>> inPersonFollowersMapper,
            final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper); void execute(final Activity activity); }
PostCachedActivity extends CachedDomainMapper { public void execute(final Activity activity) { ScopeType type = activity.getRecipientStreamScope().getScopeType(); String recipientUniqueKey = activity.getRecipientStreamScope().getUniqueKey(); long activityId = activity.getId(); if (type == ScopeType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(recipientUniqueKey); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } else if (type == ScopeType.RESOURCE && activity.getActorType() == EntityType.PERSON) { if (activity.getShowInStream()) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity.getActorId()); updateActivitiesByFollowingCacheLists(person.getEntityId(), activityId); } } else if (type == ScopeType.GROUP) { int donothing = 1; } else { throw new RuntimeException("Unexpected Activity destination stream type: " + type); } if (activity.getSharedLink() != null) { log.info("Adding activity with a shared resource (id:" + activity.getSharedLink().getStreamScope().getId() + ") to the top of the shared resource's cached activity stream."); getCache() .addToTopOfList( CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getSharedLink().getStreamScope().getId(), activityId); } if (activity.getShowInStream()) { log.trace("Adding activity id " + activityId + " into everyone activity list."); getCache().addToTopOfList(CacheKeys.EVERYONE_ACTIVITY_IDS, activityId); } } PostCachedActivity(final DomainMapper<Long, List<Long>> inPersonFollowersMapper,
            final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper); void execute(final Activity activity);  }