TaskCommentsViewImpl extends AbstractView<TaskCommentsPresenter> implements TaskCommentsPresenter.TaskCommentsView { protected void submitCommentAddition() { if (validateForm()) { presenter.addTaskComment(newCommentTextArea.getValue()); } }  @PostConstruct void init(); @Override HTMLElement getElement(); @Override void init(final TaskCommentsPresenter presenter); @Override void clearCommentInputForm(); @Override void disableNewComments(); void clearErrorMessages(); @Override void resetPagination(); @Override void setCommentList(final List<CommentSummary> commentSummaries); @Override void hideLoadButton(); @Override void showLoadButton(); @Override void showCommentHeader(); @EventHandler("addCommentButton") @SuppressWarnings("unsued") void addCommentButton(@ForEvent("click") final Event e); @EventHandler("sort-alpha-asc") void onSortAlphaAsc(final @ForEvent("click") MouseEvent event); @EventHandler("sort-alpha-desc") void onSortAlphaDesc(final @ForEvent("click") MouseEvent event); @EventHandler("load-more-comments") void loadMoreComments(final @ForEvent("click") MouseEvent event);  }
@Test public void fieldValidationErrorTest() { when(newCommentTextArea.getValue()).thenReturn(""); view.submitCommentAddition(); final InOrder inOrder = inOrder(newCommentTextAreaHelp); inOrder.verify(newCommentTextAreaHelp).setTextContent(""); inOrder.verify(newCommentTextAreaHelp).setTextContent(Constants.INSTANCE.CommentCannotBeEmpty()); final InOrder inOrderValidationState = inOrder(newCommentTextAreaGroup); inOrderValidationState.verify(newCommentTextAreaGroup).clearValidationState(); inOrderValidationState.verify(newCommentTextAreaGroup).setValidationState(ValidationState.ERROR); verify(newCommentTextArea).focus(); verify(presenter, never()).addTaskComment(anyString()); }
@Test public void fieldValidationSuccessTest() { String commentContent = "New comment"; when(newCommentTextArea.getValue()).thenReturn(commentContent); view.submitCommentAddition(); verify(newCommentTextArea, never()).focus(); verify(newCommentTextAreaHelp).setTextContent(""); verify(newCommentTextAreaGroup).clearValidationState(); verify(presenter).addTaskComment(commentContent); }