@Test(expected = ValidationException.class) public void testInvalidStreamType() { PostSplitActivityAndCommentsRequest request = new PostSplitActivityAndCommentsRequest(EntityType.RESOURCE, PERSON_ID, INPUT_STRING); TaskHandlerActionContext<PrincipalActionContext> context = TestContextCreator .createTaskHandlerContextWithPrincipal(request, USER_ACCOUNT_ID, USER_ID); sut.execute(context); mockery.assertIsSatisfied(); }
@Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { PostSplitActivityAndCommentsRequest request = (PostSplitActivityAndCommentsRequest) inActionContext .getActionContext().getParams(); DomainMapper<Long, String> uniqueIdDAO = uniqueIdDAOs.get(request.getEntityType()); if (uniqueIdDAO == null) { throw new ValidationException("Request to post to unsupported stream type " + request.getEntityType()); } String uniqueId = uniqueIdDAO.execute(request.getEntityId()); List<String> pieces = textSplitter.split(request.getText()); if (pieces.isEmpty()) { throw new ValidationException("Text to post must not be empty."); } ActivityDTO activityToPost = new ActivityDTO(); activityToPost.setBaseObjectType(BaseObjectType.NOTE); activityToPost.setVerb(ActivityVerb.POST); activityToPost.setDestinationStream(new StreamEntityDTO(request.getEntityType(), uniqueId)); activityToPost.setBaseObjectProperties(new HashMap<String, String>(Collections.singletonMap("content", pieces.get(0)))); TaskHandlerAction postActivityAction = postActivityActions.get(request.getEntityType()); ActivityDTO postedActivity = (ActivityDTO) executor.execute(postActivityAction, inActionContext, new PostActivityRequest(activityToPost)); for (String piece : pieces.subList(1, pieces.size())) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(postedActivity.getId()); executor.execute(postCommentAction, inActionContext, thisComment); } return postedActivity.getId(); }
PostSplitActivityAndCommentsExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { PostSplitActivityAndCommentsRequest request = (PostSplitActivityAndCommentsRequest) inActionContext .getActionContext().getParams(); DomainMapper<Long, String> uniqueIdDAO = uniqueIdDAOs.get(request.getEntityType()); if (uniqueIdDAO == null) { throw new ValidationException("Request to post to unsupported stream type " + request.getEntityType()); } String uniqueId = uniqueIdDAO.execute(request.getEntityId()); List<String> pieces = textSplitter.split(request.getText()); if (pieces.isEmpty()) { throw new ValidationException("Text to post must not be empty."); } ActivityDTO activityToPost = new ActivityDTO(); activityToPost.setBaseObjectType(BaseObjectType.NOTE); activityToPost.setVerb(ActivityVerb.POST); activityToPost.setDestinationStream(new StreamEntityDTO(request.getEntityType(), uniqueId)); activityToPost.setBaseObjectProperties(new HashMap<String, String>(Collections.singletonMap("content", pieces.get(0)))); TaskHandlerAction postActivityAction = postActivityActions.get(request.getEntityType()); ActivityDTO postedActivity = (ActivityDTO) executor.execute(postActivityAction, inActionContext, new PostActivityRequest(activityToPost)); for (String piece : pieces.subList(1, pieces.size())) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(postedActivity.getId()); executor.execute(postCommentAction, inActionContext, thisComment); } return postedActivity.getId(); } }
PostSplitActivityAndCommentsExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { PostSplitActivityAndCommentsRequest request = (PostSplitActivityAndCommentsRequest) inActionContext .getActionContext().getParams(); DomainMapper<Long, String> uniqueIdDAO = uniqueIdDAOs.get(request.getEntityType()); if (uniqueIdDAO == null) { throw new ValidationException("Request to post to unsupported stream type " + request.getEntityType()); } String uniqueId = uniqueIdDAO.execute(request.getEntityId()); List<String> pieces = textSplitter.split(request.getText()); if (pieces.isEmpty()) { throw new ValidationException("Text to post must not be empty."); } ActivityDTO activityToPost = new ActivityDTO(); activityToPost.setBaseObjectType(BaseObjectType.NOTE); activityToPost.setVerb(ActivityVerb.POST); activityToPost.setDestinationStream(new StreamEntityDTO(request.getEntityType(), uniqueId)); activityToPost.setBaseObjectProperties(new HashMap<String, String>(Collections.singletonMap("content", pieces.get(0)))); TaskHandlerAction postActivityAction = postActivityActions.get(request.getEntityType()); ActivityDTO postedActivity = (ActivityDTO) executor.execute(postActivityAction, inActionContext, new PostActivityRequest(activityToPost)); for (String piece : pieces.subList(1, pieces.size())) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(postedActivity.getId()); executor.execute(postCommentAction, inActionContext, thisComment); } return postedActivity.getId(); } PostSplitActivityAndCommentsExecution(final TextSplitter inTextSplitter,
            final InlineActionExecutor inExecutor, final Map<EntityType, TaskHandlerAction> inPostActivityActions,
            final TaskHandlerAction inPostCommentAction, final Map<EntityType, DomainMapper<Long, String>> inEntityDAOs); }
PostSplitActivityAndCommentsExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { PostSplitActivityAndCommentsRequest request = (PostSplitActivityAndCommentsRequest) inActionContext .getActionContext().getParams(); DomainMapper<Long, String> uniqueIdDAO = uniqueIdDAOs.get(request.getEntityType()); if (uniqueIdDAO == null) { throw new ValidationException("Request to post to unsupported stream type " + request.getEntityType()); } String uniqueId = uniqueIdDAO.execute(request.getEntityId()); List<String> pieces = textSplitter.split(request.getText()); if (pieces.isEmpty()) { throw new ValidationException("Text to post must not be empty."); } ActivityDTO activityToPost = new ActivityDTO(); activityToPost.setBaseObjectType(BaseObjectType.NOTE); activityToPost.setVerb(ActivityVerb.POST); activityToPost.setDestinationStream(new StreamEntityDTO(request.getEntityType(), uniqueId)); activityToPost.setBaseObjectProperties(new HashMap<String, String>(Collections.singletonMap("content", pieces.get(0)))); TaskHandlerAction postActivityAction = postActivityActions.get(request.getEntityType()); ActivityDTO postedActivity = (ActivityDTO) executor.execute(postActivityAction, inActionContext, new PostActivityRequest(activityToPost)); for (String piece : pieces.subList(1, pieces.size())) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(postedActivity.getId()); executor.execute(postCommentAction, inActionContext, thisComment); } return postedActivity.getId(); } PostSplitActivityAndCommentsExecution(final TextSplitter inTextSplitter,
            final InlineActionExecutor inExecutor, final Map<EntityType, TaskHandlerAction> inPostActivityActions,
            final TaskHandlerAction inPostCommentAction, final Map<EntityType, DomainMapper<Long, String>> inEntityDAOs); @Override Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext); }
PostSplitActivityAndCommentsExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { PostSplitActivityAndCommentsRequest request = (PostSplitActivityAndCommentsRequest) inActionContext .getActionContext().getParams(); DomainMapper<Long, String> uniqueIdDAO = uniqueIdDAOs.get(request.getEntityType()); if (uniqueIdDAO == null) { throw new ValidationException("Request to post to unsupported stream type " + request.getEntityType()); } String uniqueId = uniqueIdDAO.execute(request.getEntityId()); List<String> pieces = textSplitter.split(request.getText()); if (pieces.isEmpty()) { throw new ValidationException("Text to post must not be empty."); } ActivityDTO activityToPost = new ActivityDTO(); activityToPost.setBaseObjectType(BaseObjectType.NOTE); activityToPost.setVerb(ActivityVerb.POST); activityToPost.setDestinationStream(new StreamEntityDTO(request.getEntityType(), uniqueId)); activityToPost.setBaseObjectProperties(new HashMap<String, String>(Collections.singletonMap("content", pieces.get(0)))); TaskHandlerAction postActivityAction = postActivityActions.get(request.getEntityType()); ActivityDTO postedActivity = (ActivityDTO) executor.execute(postActivityAction, inActionContext, new PostActivityRequest(activityToPost)); for (String piece : pieces.subList(1, pieces.size())) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(postedActivity.getId()); executor.execute(postCommentAction, inActionContext, thisComment); } return postedActivity.getId(); } PostSplitActivityAndCommentsExecution(final TextSplitter inTextSplitter,
            final InlineActionExecutor inExecutor, final Map<EntityType, TaskHandlerAction> inPostActivityActions,
            final TaskHandlerAction inPostCommentAction, final Map<EntityType, DomainMapper<Long, String>> inEntityDAOs); @Override Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext);  }