@Test @SuppressWarnings("unchecked") public final void testExecute() throws Exception { context.checking(new Expectations() { { oneOf(actionContext).getPrincipal(); will(returnValue(principal)); oneOf(principal).getId(); will(returnValue(PERSON_ID)); oneOf(idMapper).execute(PERSON_ID); will(returnValue(Arrays.asList(1, 2, 3))); oneOf(groupMapper).execute(with(any(ArrayList.class))); will(returnValue(Arrays.asList(group1, group2, group3))); oneOf(peopleMapper).execute(with(any(List.class))); will(returnValue(Arrays.asList(person))); } }); GetCurrentUserStreamFiltersResponse response = sut.execute(actionContext); assertEquals(3, response.getStreamFilters().size()); assertEquals(HIDDEN_LINE_INDEX, response.getHiddenLineIndex().intValue()); context.assertIsSatisfied(); }
@Override public GetCurrentUserStreamFiltersResponse execute(final PrincipalActionContext inActionContext) throws ExecutionException { final long userEntityId = inActionContext.getPrincipal().getId(); List<Long> followedGroupIds = idsMapper.execute(userEntityId); List<DomainGroupModelView> followedGroups = groupsMapper.execute(followedGroupIds); List<StreamFilter> groupStreams = new ArrayList<StreamFilter>(); for (DomainGroupModelView group : followedGroups) { boolean isStreamPostable = group.isStreamPostable(); isStreamPostable = isStreamPostable ? isStreamPostable : groupPermissionsChecker .hasGroupCoordinatorAccessRecursively(userEntityId, group.getEntityId()); groupStreams.add(new GroupStreamDTO(group.getEntityId(), group.getName(), group.getShortName(), isStreamPostable)); if (log.isInfoEnabled()) { log.info("created groupstreamDTO: " + group.getEntityId() + "; " + group.getName() + "; " + group.getShortName()); } } List<PersonModelView> people = peopleMapper.execute(Arrays.asList(userEntityId)); GetCurrentUserStreamFiltersResponse response = new GetCurrentUserStreamFiltersResponse(people.get(0) .getGroupStreamHiddenLineIndex(), groupStreams); return response; }
GetCurrentUserFollowedGroupsExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public GetCurrentUserStreamFiltersResponse execute(final PrincipalActionContext inActionContext) throws ExecutionException { final long userEntityId = inActionContext.getPrincipal().getId(); List<Long> followedGroupIds = idsMapper.execute(userEntityId); List<DomainGroupModelView> followedGroups = groupsMapper.execute(followedGroupIds); List<StreamFilter> groupStreams = new ArrayList<StreamFilter>(); for (DomainGroupModelView group : followedGroups) { boolean isStreamPostable = group.isStreamPostable(); isStreamPostable = isStreamPostable ? isStreamPostable : groupPermissionsChecker .hasGroupCoordinatorAccessRecursively(userEntityId, group.getEntityId()); groupStreams.add(new GroupStreamDTO(group.getEntityId(), group.getName(), group.getShortName(), isStreamPostable)); if (log.isInfoEnabled()) { log.info("created groupstreamDTO: " + group.getEntityId() + "; " + group.getName() + "; " + group.getShortName()); } } List<PersonModelView> people = peopleMapper.execute(Arrays.asList(userEntityId)); GetCurrentUserStreamFiltersResponse response = new GetCurrentUserStreamFiltersResponse(people.get(0) .getGroupStreamHiddenLineIndex(), groupStreams); return response; } }
GetCurrentUserFollowedGroupsExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public GetCurrentUserStreamFiltersResponse execute(final PrincipalActionContext inActionContext) throws ExecutionException { final long userEntityId = inActionContext.getPrincipal().getId(); List<Long> followedGroupIds = idsMapper.execute(userEntityId); List<DomainGroupModelView> followedGroups = groupsMapper.execute(followedGroupIds); List<StreamFilter> groupStreams = new ArrayList<StreamFilter>(); for (DomainGroupModelView group : followedGroups) { boolean isStreamPostable = group.isStreamPostable(); isStreamPostable = isStreamPostable ? isStreamPostable : groupPermissionsChecker .hasGroupCoordinatorAccessRecursively(userEntityId, group.getEntityId()); groupStreams.add(new GroupStreamDTO(group.getEntityId(), group.getName(), group.getShortName(), isStreamPostable)); if (log.isInfoEnabled()) { log.info("created groupstreamDTO: " + group.getEntityId() + "; " + group.getName() + "; " + group.getShortName()); } } List<PersonModelView> people = peopleMapper.execute(Arrays.asList(userEntityId)); GetCurrentUserStreamFiltersResponse response = new GetCurrentUserStreamFiltersResponse(people.get(0) .getGroupStreamHiddenLineIndex(), groupStreams); return response; } GetCurrentUserFollowedGroupsExecution(final DomainMapper<Long, List<Long>> inIdsMapper,
            final DomainMapper<List<Long>, List<DomainGroupModelView>> inGroupsMapper,
            final DomainMapper<List<Long>, List<PersonModelView>>inPeopleMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupPermissionChecker); }
GetCurrentUserFollowedGroupsExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public GetCurrentUserStreamFiltersResponse execute(final PrincipalActionContext inActionContext) throws ExecutionException { final long userEntityId = inActionContext.getPrincipal().getId(); List<Long> followedGroupIds = idsMapper.execute(userEntityId); List<DomainGroupModelView> followedGroups = groupsMapper.execute(followedGroupIds); List<StreamFilter> groupStreams = new ArrayList<StreamFilter>(); for (DomainGroupModelView group : followedGroups) { boolean isStreamPostable = group.isStreamPostable(); isStreamPostable = isStreamPostable ? isStreamPostable : groupPermissionsChecker .hasGroupCoordinatorAccessRecursively(userEntityId, group.getEntityId()); groupStreams.add(new GroupStreamDTO(group.getEntityId(), group.getName(), group.getShortName(), isStreamPostable)); if (log.isInfoEnabled()) { log.info("created groupstreamDTO: " + group.getEntityId() + "; " + group.getName() + "; " + group.getShortName()); } } List<PersonModelView> people = peopleMapper.execute(Arrays.asList(userEntityId)); GetCurrentUserStreamFiltersResponse response = new GetCurrentUserStreamFiltersResponse(people.get(0) .getGroupStreamHiddenLineIndex(), groupStreams); return response; } GetCurrentUserFollowedGroupsExecution(final DomainMapper<Long, List<Long>> inIdsMapper,
            final DomainMapper<List<Long>, List<DomainGroupModelView>> inGroupsMapper,
            final DomainMapper<List<Long>, List<PersonModelView>>inPeopleMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupPermissionChecker); @Override GetCurrentUserStreamFiltersResponse execute(final PrincipalActionContext inActionContext); }
GetCurrentUserFollowedGroupsExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public GetCurrentUserStreamFiltersResponse execute(final PrincipalActionContext inActionContext) throws ExecutionException { final long userEntityId = inActionContext.getPrincipal().getId(); List<Long> followedGroupIds = idsMapper.execute(userEntityId); List<DomainGroupModelView> followedGroups = groupsMapper.execute(followedGroupIds); List<StreamFilter> groupStreams = new ArrayList<StreamFilter>(); for (DomainGroupModelView group : followedGroups) { boolean isStreamPostable = group.isStreamPostable(); isStreamPostable = isStreamPostable ? isStreamPostable : groupPermissionsChecker .hasGroupCoordinatorAccessRecursively(userEntityId, group.getEntityId()); groupStreams.add(new GroupStreamDTO(group.getEntityId(), group.getName(), group.getShortName(), isStreamPostable)); if (log.isInfoEnabled()) { log.info("created groupstreamDTO: " + group.getEntityId() + "; " + group.getName() + "; " + group.getShortName()); } } List<PersonModelView> people = peopleMapper.execute(Arrays.asList(userEntityId)); GetCurrentUserStreamFiltersResponse response = new GetCurrentUserStreamFiltersResponse(people.get(0) .getGroupStreamHiddenLineIndex(), groupStreams); return response; } GetCurrentUserFollowedGroupsExecution(final DomainMapper<Long, List<Long>> inIdsMapper,
            final DomainMapper<List<Long>, List<DomainGroupModelView>> inGroupsMapper,
            final DomainMapper<List<Long>, List<PersonModelView>>inPeopleMapper,
            final GetAllPersonIdsWhoHaveGroupCoordinatorAccess inGroupPermissionChecker); @Override GetCurrentUserStreamFiltersResponse execute(final PrincipalActionContext inActionContext);  }