@Test public final void testFilterGroupStreamCanNotCommentIsCooridnator() { final List<String> destinationIds = new ArrayList<String>(1); destinationIds.add(destinationGroupShortName); final List<DomainGroupModelView> domainGroupModelViews = new ArrayList<DomainGroupModelView>(1); domainGroupModelViews.add(groupMock); context.checking(new Expectations() { { allowing(activityMock).getDestinationStream(); will(returnValue(streamMock)); allowing(streamMock).getType(); will(returnValue(EntityType.GROUP)); allowing(streamMock).getUniqueIdentifier(); will(returnValue(destinationGroupShortName)); oneOf(gMapperMock).execute(destinationIds); will(returnValue(domainGroupModelViews)); allowing(groupMock).getShortName(); will(returnValue(destinationGroupShortName)); oneOf(groupMock).isCommentable(); will(returnValue(false)); oneOf(groupMock).getEntityId(); will(returnValue(1L)); oneOf(groupCoordinators).hasGroupCoordinatorAccessRecursively(currentUserAccount.getAccountId(), 1L); will(returnValue(true)); oneOf(activityMock).setCommentable(true); } }); sut.filter(activities, currentUserAccount); context.assertIsSatisfied(); }
@Override public void filter(final List<ActivityDTO> activities, final PersonModelView inCurrentUserAccountId) { if (activities.isEmpty()) { return; } Hashtable<String, Boolean> personCommentable = new Hashtable<String, Boolean>(); Hashtable<String, Boolean> groupCommentable = new Hashtable<String, Boolean>(); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: personCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case GROUP: groupCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case RESOURCE: break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } setPersonCommentableValues(inCurrentUserAccountId.getAccountId(), personCommentable); setGroupCommentableValues(inCurrentUserAccountId.getAccountId(), groupCommentable); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: activity.setCommentable(personCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case GROUP: activity.setCommentable(groupCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case RESOURCE: activity.setCommentable(true); break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } }
CanCommentFilter implements ActivityFilter { @Override public void filter(final List<ActivityDTO> activities, final PersonModelView inCurrentUserAccountId) { if (activities.isEmpty()) { return; } Hashtable<String, Boolean> personCommentable = new Hashtable<String, Boolean>(); Hashtable<String, Boolean> groupCommentable = new Hashtable<String, Boolean>(); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: personCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case GROUP: groupCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case RESOURCE: break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } setPersonCommentableValues(inCurrentUserAccountId.getAccountId(), personCommentable); setGroupCommentableValues(inCurrentUserAccountId.getAccountId(), groupCommentable); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: activity.setCommentable(personCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case GROUP: activity.setCommentable(groupCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case RESOURCE: activity.setCommentable(true); break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } } }
CanCommentFilter implements ActivityFilter { @Override public void filter(final List<ActivityDTO> activities, final PersonModelView inCurrentUserAccountId) { if (activities.isEmpty()) { return; } Hashtable<String, Boolean> personCommentable = new Hashtable<String, Boolean>(); Hashtable<String, Boolean> groupCommentable = new Hashtable<String, Boolean>(); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: personCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case GROUP: groupCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case RESOURCE: break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } setPersonCommentableValues(inCurrentUserAccountId.getAccountId(), personCommentable); setGroupCommentableValues(inCurrentUserAccountId.getAccountId(), groupCommentable); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: activity.setCommentable(personCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case GROUP: activity.setCommentable(groupCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case RESOURCE: activity.setCommentable(true); break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } } CanCommentFilter(
            final DomainMapper<List<String>, List<PersonModelView>> inGetPersonModelViewsByAccountIdsMapper,
            final GetDomainGroupsByShortNames inGroupMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinators); }
CanCommentFilter implements ActivityFilter { @Override public void filter(final List<ActivityDTO> activities, final PersonModelView inCurrentUserAccountId) { if (activities.isEmpty()) { return; } Hashtable<String, Boolean> personCommentable = new Hashtable<String, Boolean>(); Hashtable<String, Boolean> groupCommentable = new Hashtable<String, Boolean>(); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: personCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case GROUP: groupCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case RESOURCE: break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } setPersonCommentableValues(inCurrentUserAccountId.getAccountId(), personCommentable); setGroupCommentableValues(inCurrentUserAccountId.getAccountId(), groupCommentable); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: activity.setCommentable(personCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case GROUP: activity.setCommentable(groupCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case RESOURCE: activity.setCommentable(true); break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } } CanCommentFilter(
            final DomainMapper<List<String>, List<PersonModelView>> inGetPersonModelViewsByAccountIdsMapper,
            final GetDomainGroupsByShortNames inGroupMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinators); @Override void filter(final List<ActivityDTO> activities, final PersonModelView inCurrentUserAccountId); }
CanCommentFilter implements ActivityFilter { @Override public void filter(final List<ActivityDTO> activities, final PersonModelView inCurrentUserAccountId) { if (activities.isEmpty()) { return; } Hashtable<String, Boolean> personCommentable = new Hashtable<String, Boolean>(); Hashtable<String, Boolean> groupCommentable = new Hashtable<String, Boolean>(); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: personCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case GROUP: groupCommentable.put(activity.getDestinationStream().getUniqueIdentifier().trim().toLowerCase(), Boolean.TRUE); break; case RESOURCE: break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } setPersonCommentableValues(inCurrentUserAccountId.getAccountId(), personCommentable); setGroupCommentableValues(inCurrentUserAccountId.getAccountId(), groupCommentable); for (ActivityDTO activity : activities) { switch (activity.getDestinationStream().getType()) { case PERSON: activity.setCommentable(personCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case GROUP: activity.setCommentable(groupCommentable.get(activity.getDestinationStream().getUniqueIdentifier() .trim().toLowerCase())); break; case RESOURCE: activity.setCommentable(true); break; default: throw new IllegalArgumentException( "Attempted to filter Activity with unsupported destination stream type."); } } } CanCommentFilter(
            final DomainMapper<List<String>, List<PersonModelView>> inGetPersonModelViewsByAccountIdsMapper,
            final GetDomainGroupsByShortNames inGroupMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupCoordinators); @Override void filter(final List<ActivityDTO> activities, final PersonModelView inCurrentUserAccountId);  }