@Test public void testExecuteStreamNotGroup() { TaskHandlerActionContext<PrincipalActionContext> actionContext = TestContextCreator .createTaskHandlerContextWithPrincipal(activityId, null, currentUserId); commonExpectations(); context.checking(new Expectations() { { allowing(stream).getEntityType(); will(returnValue(EntityType.PERSON)); } }); assertTrue(sut.execute(actionContext)); context.assertIsSatisfied(); assertEquals(2, actionContext.getUserActionRequests().size()); }
@Override public Boolean execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { Long activityId = (Long) inActionContext.getActionContext().getParams(); Long currentUserId = inActionContext.getActionContext().getPrincipal().getId(); List<Long> commentIds = commentIdsByActivityIdDAO.execute(activityId); List<Long> personIdsWithActivityStarred = getPersonIdsWithStarredActivityDAO.execute(activityId); ActivityDTO activity = deleteActivityDAO.execute(new DeleteActivityRequest(currentUserId, activityId)); if (activity == null) { return Boolean.TRUE; } if (activity.getDestinationStream().getEntityType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.execute(activity.getDestinationStream().getDestinationEntityId()); if (group != null && activityId.equals(group.getStickyActivityId())) { clearGroupStickyActivityExecutor.execute(inActionContext, new UpdateStickyActivityRequest(group.getId(), null)); } } inActionContext.getUserActionRequests().add( new UserActionRequest("deleteActivityCacheUpdate", null, new DeleteActivityCacheUpdateRequest( activity, commentIds, personIdsWithActivityStarred))); inActionContext.getUserActionRequests().add( new UserActionRequest("deleteFromSearchIndexAction", null, new DeleteFromSearchIndexRequest( Activity.class, activityId))); return Boolean.TRUE; }
DeleteActivityExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Boolean execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { Long activityId = (Long) inActionContext.getActionContext().getParams(); Long currentUserId = inActionContext.getActionContext().getPrincipal().getId(); List<Long> commentIds = commentIdsByActivityIdDAO.execute(activityId); List<Long> personIdsWithActivityStarred = getPersonIdsWithStarredActivityDAO.execute(activityId); ActivityDTO activity = deleteActivityDAO.execute(new DeleteActivityRequest(currentUserId, activityId)); if (activity == null) { return Boolean.TRUE; } if (activity.getDestinationStream().getEntityType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.execute(activity.getDestinationStream().getDestinationEntityId()); if (group != null && activityId.equals(group.getStickyActivityId())) { clearGroupStickyActivityExecutor.execute(inActionContext, new UpdateStickyActivityRequest(group.getId(), null)); } } inActionContext.getUserActionRequests().add( new UserActionRequest("deleteActivityCacheUpdate", null, new DeleteActivityCacheUpdateRequest( activity, commentIds, personIdsWithActivityStarred))); inActionContext.getUserActionRequests().add( new UserActionRequest("deleteFromSearchIndexAction", null, new DeleteFromSearchIndexRequest( Activity.class, activityId))); return Boolean.TRUE; } }
DeleteActivityExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Boolean execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { Long activityId = (Long) inActionContext.getActionContext().getParams(); Long currentUserId = inActionContext.getActionContext().getPrincipal().getId(); List<Long> commentIds = commentIdsByActivityIdDAO.execute(activityId); List<Long> personIdsWithActivityStarred = getPersonIdsWithStarredActivityDAO.execute(activityId); ActivityDTO activity = deleteActivityDAO.execute(new DeleteActivityRequest(currentUserId, activityId)); if (activity == null) { return Boolean.TRUE; } if (activity.getDestinationStream().getEntityType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.execute(activity.getDestinationStream().getDestinationEntityId()); if (group != null && activityId.equals(group.getStickyActivityId())) { clearGroupStickyActivityExecutor.execute(inActionContext, new UpdateStickyActivityRequest(group.getId(), null)); } } inActionContext.getUserActionRequests().add( new UserActionRequest("deleteActivityCacheUpdate", null, new DeleteActivityCacheUpdateRequest( activity, commentIds, personIdsWithActivityStarred))); inActionContext.getUserActionRequests().add( new UserActionRequest("deleteFromSearchIndexAction", null, new DeleteFromSearchIndexRequest( Activity.class, activityId))); return Boolean.TRUE; } DeleteActivityExecution(final DeleteActivity inDeleteActivityDAO,
            final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final GetPersonIdsWithStarredActivity inGetPersonIdsWithStarredActivityDAO,
            final DomainMapper<Long, DomainGroupModelView> inGroupMapper,
            final InlineExecutionStrategyWrappingExecutor inClearGroupStickyActivityExecutor); }
DeleteActivityExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Boolean execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { Long activityId = (Long) inActionContext.getActionContext().getParams(); Long currentUserId = inActionContext.getActionContext().getPrincipal().getId(); List<Long> commentIds = commentIdsByActivityIdDAO.execute(activityId); List<Long> personIdsWithActivityStarred = getPersonIdsWithStarredActivityDAO.execute(activityId); ActivityDTO activity = deleteActivityDAO.execute(new DeleteActivityRequest(currentUserId, activityId)); if (activity == null) { return Boolean.TRUE; } if (activity.getDestinationStream().getEntityType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.execute(activity.getDestinationStream().getDestinationEntityId()); if (group != null && activityId.equals(group.getStickyActivityId())) { clearGroupStickyActivityExecutor.execute(inActionContext, new UpdateStickyActivityRequest(group.getId(), null)); } } inActionContext.getUserActionRequests().add( new UserActionRequest("deleteActivityCacheUpdate", null, new DeleteActivityCacheUpdateRequest( activity, commentIds, personIdsWithActivityStarred))); inActionContext.getUserActionRequests().add( new UserActionRequest("deleteFromSearchIndexAction", null, new DeleteFromSearchIndexRequest( Activity.class, activityId))); return Boolean.TRUE; } DeleteActivityExecution(final DeleteActivity inDeleteActivityDAO,
            final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final GetPersonIdsWithStarredActivity inGetPersonIdsWithStarredActivityDAO,
            final DomainMapper<Long, DomainGroupModelView> inGroupMapper,
            final InlineExecutionStrategyWrappingExecutor inClearGroupStickyActivityExecutor); @Override Boolean execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext); }
DeleteActivityExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Boolean execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { Long activityId = (Long) inActionContext.getActionContext().getParams(); Long currentUserId = inActionContext.getActionContext().getPrincipal().getId(); List<Long> commentIds = commentIdsByActivityIdDAO.execute(activityId); List<Long> personIdsWithActivityStarred = getPersonIdsWithStarredActivityDAO.execute(activityId); ActivityDTO activity = deleteActivityDAO.execute(new DeleteActivityRequest(currentUserId, activityId)); if (activity == null) { return Boolean.TRUE; } if (activity.getDestinationStream().getEntityType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.execute(activity.getDestinationStream().getDestinationEntityId()); if (group != null && activityId.equals(group.getStickyActivityId())) { clearGroupStickyActivityExecutor.execute(inActionContext, new UpdateStickyActivityRequest(group.getId(), null)); } } inActionContext.getUserActionRequests().add( new UserActionRequest("deleteActivityCacheUpdate", null, new DeleteActivityCacheUpdateRequest( activity, commentIds, personIdsWithActivityStarred))); inActionContext.getUserActionRequests().add( new UserActionRequest("deleteFromSearchIndexAction", null, new DeleteFromSearchIndexRequest( Activity.class, activityId))); return Boolean.TRUE; } DeleteActivityExecution(final DeleteActivity inDeleteActivityDAO,
            final DomainMapper<Long, List<Long>> inCommentIdsByActivityIdDAO,
            final GetPersonIdsWithStarredActivity inGetPersonIdsWithStarredActivityDAO,
            final DomainMapper<Long, DomainGroupModelView> inGroupMapper,
            final InlineExecutionStrategyWrappingExecutor inClearGroupStickyActivityExecutor); @Override Boolean execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext);  }