@Test public void refreshListTest() { doReturn(LibraryConstants.ChangeRequestFilesSummaryManyFiles).when(ts).format(anyString(), anyInt()); doReturn(promises.resolve(true)) .when(projectController).canSubmitChangeRequest(workspaceProject); doReturn(mock(ChangeRequestListItemView.class)).when(changeRequestListItemViewInstances).get(); ChangeRequest cr = mock(ChangeRequest.class); doReturn(ChangeRequestStatus.OPEN).when(cr).getStatus(); doReturn(0).when(cr).getCommentsCount(); doReturn(new Date()).when(cr).getCreatedDate(); List<ChangeRequest> crList = Collections.nCopies(10, cr); PaginatedChangeRequestList paginatedList = new PaginatedChangeRequestList(crList, 0, 10, 10); doReturn(paginatedList).when(changeRequestService).getChangeRequests(anyString(), anyString(), anyInt(), anyInt(), anyListOf(ChangeRequestStatus.class), anyString()); presenter.postConstruct(); verify(changeRequestListItemViewInstances, times(10)).get(); verify(view, times(10)).addChangeRequestItem(any()); }
private void refreshList() { busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); if (filterType.equals(FILTER_ALL)) { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, searchFilter); } else { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, getStatusByFilterType(), searchFilter); } }
PopulatedChangeRequestListPresenter { private void refreshList() { busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); if (filterType.equals(FILTER_ALL)) { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, searchFilter); } else { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, getStatusByFilterType(), searchFilter); } } }
PopulatedChangeRequestListPresenter { private void refreshList() { busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); if (filterType.equals(FILTER_ALL)) { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, searchFilter); } else { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, getStatusByFilterType(), searchFilter); } } @Inject  PopulatedChangeRequestListPresenter(final View view,
                                               final ProjectController projectController,
                                               final LibraryPlaces libraryPlaces,
                                               final Promises promises,
                                               final EmptyState emptyState,
                                               final TranslationService ts,
                                               final ManagedInstance<ChangeRequestListItemView> changeRequestItemViews,
                                               final Caller<ChangeRequestService> changeRequestService,
                                               final BusyIndicatorView busyIndicatorView,
                                               final DateUtils dateUtils); }
PopulatedChangeRequestListPresenter { private void refreshList() { busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); if (filterType.equals(FILTER_ALL)) { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, searchFilter); } else { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, getStatusByFilterType(), searchFilter); } } @Inject  PopulatedChangeRequestListPresenter(final View view,
                                               final ProjectController projectController,
                                               final LibraryPlaces libraryPlaces,
                                               final Promises promises,
                                               final EmptyState emptyState,
                                               final TranslationService ts,
                                               final ManagedInstance<ChangeRequestListItemView> changeRequestItemViews,
                                               final Caller<ChangeRequestService> changeRequestService,
                                               final BusyIndicatorView busyIndicatorView,
                                               final DateUtils dateUtils); @PostConstruct void postConstruct(); View getView(); void onChangeRequestListUpdated(@Observes final ChangeRequestListUpdatedEvent event); void onChangeRequestUpdated(@Observes final ChangeRequestUpdatedEvent event); void onChangeRequestStatusUpdated(@Observes final ChangeRequestStatusUpdatedEvent event); void onRepositoryFileListUpdated(@Observes final RepositoryFileListUpdatedEvent event); void nextPage(); void prevPage(); void setCurrentPage(final int currentPage); void setFilterType(final String filterType); void submitChangeRequest(); void search(final String searchText); void showSearchHitNothing(); }
PopulatedChangeRequestListPresenter { private void refreshList() { busyIndicatorView.showBusyIndicator(ts.getTranslation(LibraryConstants.Loading)); if (filterType.equals(FILTER_ALL)) { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, searchFilter); } else { changeRequestService.call(getChangeRequestsCallback(), new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)) .getChangeRequests(workspaceProject.getSpace().getName(), workspaceProject.getRepository().getAlias(), Math.max(0, currentPage - 1), PAGE_SIZE, getStatusByFilterType(), searchFilter); } } @Inject  PopulatedChangeRequestListPresenter(final View view,
                                               final ProjectController projectController,
                                               final LibraryPlaces libraryPlaces,
                                               final Promises promises,
                                               final EmptyState emptyState,
                                               final TranslationService ts,
                                               final ManagedInstance<ChangeRequestListItemView> changeRequestItemViews,
                                               final Caller<ChangeRequestService> changeRequestService,
                                               final BusyIndicatorView busyIndicatorView,
                                               final DateUtils dateUtils); @PostConstruct void postConstruct(); View getView(); void onChangeRequestListUpdated(@Observes final ChangeRequestListUpdatedEvent event); void onChangeRequestUpdated(@Observes final ChangeRequestUpdatedEvent event); void onChangeRequestStatusUpdated(@Observes final ChangeRequestStatusUpdatedEvent event); void onRepositoryFileListUpdated(@Observes final RepositoryFileListUpdatedEvent event); void nextPage(); void prevPage(); void setCurrentPage(final int currentPage); void setFilterType(final String filterType); void submitChangeRequest(); void search(final String searchText); void showSearchHitNothing();  }