CaseCommentsPresenter extends AbstractCaseInstancePresenter<CaseCommentsPresenter.CaseCommentsView> { public void sortComments(final boolean sortAsc) { this.sortAsc = sortAsc; refreshComments(); }  int getPageSize(); void setCurrentPage(int i); int getCurrentPage(); @WorkbenchPartTitle String getTittle(); void refreshComments(); void loadMoreCaseComments(); void sortComments(final boolean sortAsc); static final String SCREEN_ID; static final int PAGE_SIZE; }
@Test public void testSortComments() { final CaseInstanceSummary cis = newCaseInstanceSummary(); String comment1_id = "comment1"; String comment2_id = "comment2"; Date first = new Date(1000); Date second = new Date(2000); final CaseCommentSummary caseComment1 = CaseCommentSummary.builder().id(comment1_id).author(author).text(text).addedAt(first).build(); final CaseCommentSummary caseComment2 = CaseCommentSummary.builder().id(comment2_id).author(author).text(text).addedAt(second).build(); when(caseManagementService.getComments(cis.getContainerId(), cis.getCaseId(), 0, presenter.getPageSize())).thenReturn(Arrays.asList(caseComment1, caseComment2)); setupCaseInstance(cis); final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class); verify(caseCommentsView).setCaseCommentList(captor.capture()); assertEquals(comment2_id, ((CaseCommentSummary) captor.getValue().get(0)).getId()); assertEquals(comment1_id, ((CaseCommentSummary) captor.getValue().get(1)).getId()); presenter.sortComments(true); verify(caseCommentsView, times(2)).setCaseCommentList(captor.capture()); assertEquals(comment1_id, ((CaseCommentSummary) captor.getValue().get(0)).getId()); assertEquals(comment2_id, ((CaseCommentSummary) captor.getValue().get(1)).getId()); }