@Test @SuppressWarnings("unchecked") public final void executeTestNoResults() throws Exception { final ArrayList<ActivityDTO> activities = new ArrayList<ActivityDTO>(); final List<Long> commentIds = new ArrayList<Long>(2); commentIds.add(1L); commentIds.add(2L); final List<CommentDTO> comments = new ArrayList(2); comments.add(context.mock(CommentDTO.class, "comment1")); comments.add(context.mock(CommentDTO.class, "comment2")); final PersonModelView person = new PersonModelView(); context.checking(new Expectations() { { oneOf(activityDAO).execute(with(any(ArrayList.class))); will(returnValue(activities)); allowing(filterMock).filter(with(activities), with(any(PersonModelView.class))); } }); assertNull(sut.execute(buildActionContext())); context.assertIsSatisfied(); }
@Override public Serializable execute(final PrincipalActionContext inActionContext) { String accountId = inActionContext.getPrincipal().getAccountId(); Long activityId = (Long) inActionContext.getParams(); List<ActivityDTO> results = new ArrayList<ActivityDTO>(bulkActivitiesMapper.execute(Collections .singletonList(activityId))); if (results.size() == 0) { return null; } loadAllComments(accountId, results.get(0)); PersonModelView person = getPersonModelViewByAccountIdMapper.execute(accountId); for (ActivityFilter filter : filters) { filter.filter(results, person); } return results.get(0); }
GetActivityByIdExecutionStrategy implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { String accountId = inActionContext.getPrincipal().getAccountId(); Long activityId = (Long) inActionContext.getParams(); List<ActivityDTO> results = new ArrayList<ActivityDTO>(bulkActivitiesMapper.execute(Collections .singletonList(activityId))); if (results.size() == 0) { return null; } loadAllComments(accountId, results.get(0)); PersonModelView person = getPersonModelViewByAccountIdMapper.execute(accountId); for (ActivityFilter filter : filters) { filter.filter(results, person); } return results.get(0); } }
GetActivityByIdExecutionStrategy implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { String accountId = inActionContext.getPrincipal().getAccountId(); Long activityId = (Long) inActionContext.getParams(); List<ActivityDTO> results = new ArrayList<ActivityDTO>(bulkActivitiesMapper.execute(Collections .singletonList(activityId))); if (results.size() == 0) { return null; } loadAllComments(accountId, results.get(0)); PersonModelView person = getPersonModelViewByAccountIdMapper.execute(accountId); for (ActivityFilter filter : filters) { filter.filter(results, person); } return results.get(0); } GetActivityByIdExecutionStrategy(final DomainMapper<List<Long>, List<ActivityDTO>> inBulkActivitiesMapper,
            final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final DomainMapper<List<Long>, List<CommentDTO>> inCommentsByIdDAO,
            final CommentDeletePropertyStrategy inCommentDeletableSetter,
            final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper,
            final List<ActivityFilter> inFilters); }
GetActivityByIdExecutionStrategy implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { String accountId = inActionContext.getPrincipal().getAccountId(); Long activityId = (Long) inActionContext.getParams(); List<ActivityDTO> results = new ArrayList<ActivityDTO>(bulkActivitiesMapper.execute(Collections .singletonList(activityId))); if (results.size() == 0) { return null; } loadAllComments(accountId, results.get(0)); PersonModelView person = getPersonModelViewByAccountIdMapper.execute(accountId); for (ActivityFilter filter : filters) { filter.filter(results, person); } return results.get(0); } GetActivityByIdExecutionStrategy(final DomainMapper<List<Long>, List<ActivityDTO>> inBulkActivitiesMapper,
            final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final DomainMapper<List<Long>, List<CommentDTO>> inCommentsByIdDAO,
            final CommentDeletePropertyStrategy inCommentDeletableSetter,
            final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper,
            final List<ActivityFilter> inFilters); @Override Serializable execute(final PrincipalActionContext inActionContext); }
GetActivityByIdExecutionStrategy implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { String accountId = inActionContext.getPrincipal().getAccountId(); Long activityId = (Long) inActionContext.getParams(); List<ActivityDTO> results = new ArrayList<ActivityDTO>(bulkActivitiesMapper.execute(Collections .singletonList(activityId))); if (results.size() == 0) { return null; } loadAllComments(accountId, results.get(0)); PersonModelView person = getPersonModelViewByAccountIdMapper.execute(accountId); for (ActivityFilter filter : filters) { filter.filter(results, person); } return results.get(0); } GetActivityByIdExecutionStrategy(final DomainMapper<List<Long>, List<ActivityDTO>> inBulkActivitiesMapper,
            final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final DomainMapper<List<Long>, List<CommentDTO>> inCommentsByIdDAO,
            final CommentDeletePropertyStrategy inCommentDeletableSetter,
            final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper,
            final List<ActivityFilter> inFilters); @Override Serializable execute(final PrincipalActionContext inActionContext);  }