@Test public void test() { final TextSplitter textSplitter = mockery.mock(TextSplitter.class, "textSplitter"); final InlineActionExecutor executor = mockery.mock(InlineActionExecutor.class, "executor"); final TaskHandlerAction postCommentAction = mockery.mock(TaskHandlerAction.class, "postCommentAction"); final String inputString = " This is the text to be split and posted as multiple comments. "; final String piece1 = "This is the text..."; final String piece2 = "...to be split and posted..."; final String piece3 = "...as multiple comments."; PostSplitActivityCommentsExecution sut = new PostSplitActivityCommentsExecution(textSplitter, executor, postCommentAction); final CommentDTO params = mockery.mock(CommentDTO.class, "params"); final TaskHandlerActionContext<PrincipalActionContext> context = TestContextCreator .createTaskHandlerContextWithPrincipal(params, "user", 8L); final Sequence seq = mockery.sequence("calls"); mockery.checking(new Expectations() { { allowing(params).getActivityId(); will(returnValue(ACTIVITY_ID)); allowing(params).getBody(); will(returnValue(inputString)); oneOf(textSplitter).split(inputString); will(returnValue(Arrays.asList(piece1, piece2, piece3))); oneOf(executor).execute(with(same(postCommentAction)), with(same(context)), with(getCommentDtoMatcher(piece1))); inSequence(seq); oneOf(executor).execute(with(same(postCommentAction)), with(same(context)), with(getCommentDtoMatcher(piece2))); inSequence(seq); oneOf(executor).execute(with(same(postCommentAction)), with(same(context)), with(getCommentDtoMatcher(piece3))); inSequence(seq); } }); sut.execute(context); mockery.assertIsSatisfied(); }
@Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { CommentDTO inputComment = (CommentDTO) inActionContext.getActionContext().getParams(); String inputText = inputComment.getBody(); for (String piece : textSplitter.split(inputText)) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(inputComment.getActivityId()); executor.execute(postCommentAction, inActionContext, thisComment); } return null; }
PostSplitActivityCommentsExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { CommentDTO inputComment = (CommentDTO) inActionContext.getActionContext().getParams(); String inputText = inputComment.getBody(); for (String piece : textSplitter.split(inputText)) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(inputComment.getActivityId()); executor.execute(postCommentAction, inActionContext, thisComment); } return null; } }
PostSplitActivityCommentsExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { CommentDTO inputComment = (CommentDTO) inActionContext.getActionContext().getParams(); String inputText = inputComment.getBody(); for (String piece : textSplitter.split(inputText)) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(inputComment.getActivityId()); executor.execute(postCommentAction, inActionContext, thisComment); } return null; } PostSplitActivityCommentsExecution(final TextSplitter inTextSplitter,
            final InlineActionExecutor inExecutor, final TaskHandlerAction inPostCommentAction); }
PostSplitActivityCommentsExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { CommentDTO inputComment = (CommentDTO) inActionContext.getActionContext().getParams(); String inputText = inputComment.getBody(); for (String piece : textSplitter.split(inputText)) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(inputComment.getActivityId()); executor.execute(postCommentAction, inActionContext, thisComment); } return null; } PostSplitActivityCommentsExecution(final TextSplitter inTextSplitter,
            final InlineActionExecutor inExecutor, final TaskHandlerAction inPostCommentAction); @Override Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext); }
PostSplitActivityCommentsExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) { CommentDTO inputComment = (CommentDTO) inActionContext.getActionContext().getParams(); String inputText = inputComment.getBody(); for (String piece : textSplitter.split(inputText)) { CommentDTO thisComment = new CommentDTO(); thisComment.setBody(piece); thisComment.setActivityId(inputComment.getActivityId()); executor.execute(postCommentAction, inActionContext, thisComment); } return null; } PostSplitActivityCommentsExecution(final TextSplitter inTextSplitter,
            final InlineActionExecutor inExecutor, final TaskHandlerAction inPostCommentAction); @Override Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext);  }