AbstractMultiGridPresenter extends AbstractScreenListPresenter<T> { @Override public void getData(final Range visibleRange) { try { final FilterSettings currentTableSettings = getDataSetQueryHelper().getCurrentTableSettings(); currentTableSettings.setServerTemplateId(getSelectedServerTemplate()); currentTableSettings.setTablePageSize(view.getListGrid().getPageSize()); final String sortColumn = view.getSortColumn(); final Boolean sortAscending = view.isSortAscending(); if (sortColumn != null) { getDataSetQueryHelper().setLastOrderedColumn(sortColumn); getDataSetQueryHelper().setLastSortOrder(sortAscending ? SortOrder.ASCENDING : SortOrder.DESCENDING); } getDataSetQueryHelper().setCurrentTableSettings(currentTableSettings); getDataSetQueryHelper().setDataSetHandler(currentTableSettings); getDataSetQueryHelper().lookupDataSet(visibleRange.getStart(), getDataSetReadyCallback(visibleRange.getStart(), currentTableSettings)); } catch (Exception e) { errorCallback.error(e); setEmptyResults(); } }  @Inject void setErrorHandlerBuilder(final ManagedInstance<ErrorHandlerBuilder> errorHandlerBuilder); @Inject void setAuthorizationManager(final AuthorizationManager authorizationManager); @Inject void setDataSetQueryHelper(final DataSetQueryHelper dataSetQueryHelper); @Inject void setClearAllActiveFiltersEvent(Event<ClearAllActiveFiltersEvent> clearAllActiveFiltersEvent); void setFilterSettingsManager(final FilterSettingsManager filterSettingsManager); DataSetQueryHelper getDataSetQueryHelper(); @WorkbenchPartView UberView<T> getView(); @Inject void setView(V view); abstract void setupActiveSearchFilters(); abstract boolean existActiveSearchFilters(); @PostConstruct void init(); @Override @OnOpen void onOpen(); Predicate<String> getFilterEventPredicate(); void onBasicFilterAddEvent(@Observes final BasicFilterAddEvent event); void onBasicFilterRemoveEvent(@Observes final BasicFilterRemoveEvent event); ActiveFilterItem getActiveFilterFromColumnFilter(ColumnFilter columnFilter); @Override void getData(final Range visibleRange); void saveSearchFilterSettings(final String filterName,
                                         final Consumer<String> callback); boolean isUserAuthorizedForPerspective(final String perspectiveId); void openErrorView(final String parameterId); Predicate<T> getViewErrorsActionCondition();  }
@Test public void testGetDataNoSorting(){ when(dataSetQueryHelper.getCurrentTableSettings()).thenReturn(filterSettingsMock); when(view.getListGrid()).thenReturn(mock(ListTable.class)); when(view.getSortColumn()).thenReturn(null); when(view.isSortAscending()).thenReturn(null); presenter.getData(new Range(0, 10)); verify(dataSetQueryHelper, never()).setLastOrderedColumn(any()); verify(dataSetQueryHelper, never()).setLastSortOrder(any()); }
@Test public void testGetDataSorting(){ when(dataSetQueryHelper.getCurrentTableSettings()).thenReturn(filterSettingsMock); when(view.getListGrid()).thenReturn(mock(ListTable.class)); final String column = "some_column"; when(view.getSortColumn()).thenReturn(column); when(view.isSortAscending()).thenReturn(true); presenter.getData(new Range(0, 10)); verify(dataSetQueryHelper).setLastOrderedColumn(column); verify(dataSetQueryHelper).setLastSortOrder(SortOrder.ASCENDING); }