@Test public void execute() { final GetCurrentUserStreamFiltersResponse groupResponse = new GetCurrentUserStreamFiltersResponse(); final List<StreamFilter> filters = new ArrayList<StreamFilter>(); GroupStreamDTO groupFilter = new GroupStreamDTO(1L, "", "shortName", false); filters.add(groupFilter); groupResponse.setStreamFilters(filters); final List<StreamPopularHashTagsReportDTO> responses = new ArrayList<StreamPopularHashTagsReportDTO>(); final StreamPopularHashTagsReportDTO response1 = context.mock(StreamPopularHashTagsReportDTO.class, "r1"); final StreamPopularHashTagsReportDTO response2 = context.mock(StreamPopularHashTagsReportDTO.class, "r2"); responses.add(response1); responses.add(response2); sut = new GetAllPopularHashTagsFromGroupsJoinedExecution(popularHashTagsMapper, getGroups); context.checking(new Expectations() { { oneOf(getGroups).execute(actionContext); will(returnValue(groupResponse)); oneOf(actionContext).getPrincipal(); will(returnValue(principal)); oneOf(principal).getAccountId(); will(returnValue("joeSmith")); oneOf(popularHashTagsMapper).execute(with(any(List.class))); will(returnValue(responses)); allowing(response1).getPopularHashTags(); will(returnValue(null)); allowing(response2).getPopularHashTags(); will(returnValue(new ArrayList<String>())); } }); sut.execute(actionContext); context.assertIsSatisfied(); }
@Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetCurrentUserStreamFiltersResponse groupResponse = (GetCurrentUserStreamFiltersResponse) getGroups .execute(inActionContext); List<StreamPopularHashTagsRequest> requests = new ArrayList<StreamPopularHashTagsRequest>(); for (StreamFilter filter : groupResponse.getStreamFilters()) { StreamPopularHashTagsRequest request = new StreamPopularHashTagsRequest(ScopeType.GROUP, ((GroupStreamDTO) filter).getShortName()); requests.add(request); } StreamPopularHashTagsRequest personRequest = new StreamPopularHashTagsRequest(ScopeType.PERSON, inActionContext .getPrincipal().getAccountId()); requests.add(personRequest); List<StreamPopularHashTagsReportDTO> responses = popularHashTagsMapper.execute(requests); HashSet<String> result = new HashSet<String>(); if (responses.size() != requests.size()) { log.warn("response size does not equal request size"); } for (StreamPopularHashTagsReportDTO response : responses) { if (response.getPopularHashTags() != null) { result.addAll(response.getPopularHashTags()); } } return result; }
GetAllPopularHashTagsFromGroupsJoinedExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetCurrentUserStreamFiltersResponse groupResponse = (GetCurrentUserStreamFiltersResponse) getGroups .execute(inActionContext); List<StreamPopularHashTagsRequest> requests = new ArrayList<StreamPopularHashTagsRequest>(); for (StreamFilter filter : groupResponse.getStreamFilters()) { StreamPopularHashTagsRequest request = new StreamPopularHashTagsRequest(ScopeType.GROUP, ((GroupStreamDTO) filter).getShortName()); requests.add(request); } StreamPopularHashTagsRequest personRequest = new StreamPopularHashTagsRequest(ScopeType.PERSON, inActionContext .getPrincipal().getAccountId()); requests.add(personRequest); List<StreamPopularHashTagsReportDTO> responses = popularHashTagsMapper.execute(requests); HashSet<String> result = new HashSet<String>(); if (responses.size() != requests.size()) { log.warn("response size does not equal request size"); } for (StreamPopularHashTagsReportDTO response : responses) { if (response.getPopularHashTags() != null) { result.addAll(response.getPopularHashTags()); } } return result; } }
GetAllPopularHashTagsFromGroupsJoinedExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetCurrentUserStreamFiltersResponse groupResponse = (GetCurrentUserStreamFiltersResponse) getGroups .execute(inActionContext); List<StreamPopularHashTagsRequest> requests = new ArrayList<StreamPopularHashTagsRequest>(); for (StreamFilter filter : groupResponse.getStreamFilters()) { StreamPopularHashTagsRequest request = new StreamPopularHashTagsRequest(ScopeType.GROUP, ((GroupStreamDTO) filter).getShortName()); requests.add(request); } StreamPopularHashTagsRequest personRequest = new StreamPopularHashTagsRequest(ScopeType.PERSON, inActionContext .getPrincipal().getAccountId()); requests.add(personRequest); List<StreamPopularHashTagsReportDTO> responses = popularHashTagsMapper.execute(requests); HashSet<String> result = new HashSet<String>(); if (responses.size() != requests.size()) { log.warn("response size does not equal request size"); } for (StreamPopularHashTagsReportDTO response : responses) { if (response.getPopularHashTags() != null) { result.addAll(response.getPopularHashTags()); } } return result; } GetAllPopularHashTagsFromGroupsJoinedExecution(
            final DomainMapper<List<StreamPopularHashTagsRequest>,
            List<StreamPopularHashTagsReportDTO>> inPopularHashTagsMapper,
            final ExecutionStrategy<PrincipalActionContext> inGetGroups); }
GetAllPopularHashTagsFromGroupsJoinedExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetCurrentUserStreamFiltersResponse groupResponse = (GetCurrentUserStreamFiltersResponse) getGroups .execute(inActionContext); List<StreamPopularHashTagsRequest> requests = new ArrayList<StreamPopularHashTagsRequest>(); for (StreamFilter filter : groupResponse.getStreamFilters()) { StreamPopularHashTagsRequest request = new StreamPopularHashTagsRequest(ScopeType.GROUP, ((GroupStreamDTO) filter).getShortName()); requests.add(request); } StreamPopularHashTagsRequest personRequest = new StreamPopularHashTagsRequest(ScopeType.PERSON, inActionContext .getPrincipal().getAccountId()); requests.add(personRequest); List<StreamPopularHashTagsReportDTO> responses = popularHashTagsMapper.execute(requests); HashSet<String> result = new HashSet<String>(); if (responses.size() != requests.size()) { log.warn("response size does not equal request size"); } for (StreamPopularHashTagsReportDTO response : responses) { if (response.getPopularHashTags() != null) { result.addAll(response.getPopularHashTags()); } } return result; } GetAllPopularHashTagsFromGroupsJoinedExecution(
            final DomainMapper<List<StreamPopularHashTagsRequest>,
            List<StreamPopularHashTagsReportDTO>> inPopularHashTagsMapper,
            final ExecutionStrategy<PrincipalActionContext> inGetGroups); @Override Serializable execute(final PrincipalActionContext inActionContext); }
GetAllPopularHashTagsFromGroupsJoinedExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { GetCurrentUserStreamFiltersResponse groupResponse = (GetCurrentUserStreamFiltersResponse) getGroups .execute(inActionContext); List<StreamPopularHashTagsRequest> requests = new ArrayList<StreamPopularHashTagsRequest>(); for (StreamFilter filter : groupResponse.getStreamFilters()) { StreamPopularHashTagsRequest request = new StreamPopularHashTagsRequest(ScopeType.GROUP, ((GroupStreamDTO) filter).getShortName()); requests.add(request); } StreamPopularHashTagsRequest personRequest = new StreamPopularHashTagsRequest(ScopeType.PERSON, inActionContext .getPrincipal().getAccountId()); requests.add(personRequest); List<StreamPopularHashTagsReportDTO> responses = popularHashTagsMapper.execute(requests); HashSet<String> result = new HashSet<String>(); if (responses.size() != requests.size()) { log.warn("response size does not equal request size"); } for (StreamPopularHashTagsReportDTO response : responses) { if (response.getPopularHashTags() != null) { result.addAll(response.getPopularHashTags()); } } return result; } GetAllPopularHashTagsFromGroupsJoinedExecution(
            final DomainMapper<List<StreamPopularHashTagsRequest>,
            List<StreamPopularHashTagsReportDTO>> inPopularHashTagsMapper,
            final ExecutionStrategy<PrincipalActionContext> inGetGroups); @Override Serializable execute(final PrincipalActionContext inActionContext);  }