TableDisplayer extends AbstractGwtDisplayer<TableDisplayer.View> { protected boolean isTotalRowsExact(DataSet dataSet, int totalRows) { return isRemoteProvider(dataSet) ? totalRows < getPageSize() : true; } @Inject  TableDisplayer(View view, FilterLabelSet filterLabelSet); @Override View getView(); FilterLabelSet getFilterLabelSet(); int getTotalRows(); String getLastOrderedColumn(); SortOrder getLastSortOrder(); String getSelectedCellColumn(); Integer getSelectedCellRow(); int getExportRowNumMax(); void setExportRowNumMax(int exportRowNumMax); void addOnCellSelectedCommand(Command onCellSelectedCommand); @Override DisplayerConstraints createDisplayerConstraints(); void sortBy(String column, SortOrder order); void selectCell(String columnId, int rowIndex); @Override void filterReset(String columnId); @Override void filterReset(); void lookupCurrentPage(final Callback<Integer> callback); void export(ExportFormat format); @Override void onFilterEnabled(Displayer displayer, DataSetGroup groupOp); @Override void onFilterEnabled(Displayer displayer, DataSetFilter filter); @Override void onFilterReset(Displayer displayer, List<DataSetGroup> groupOps); @Override void onFilterReset(Displayer displayer, DataSetFilter filter);  }
@Test public void testIsTotalRowsExactSQL() { final DataSet dataSet = mock(DataSet.class); final DataSetDef dataSetDef = new DataSetDef(); dataSetDef.setProvider(DataSetProviderType.SQL); when(dataSet.getDefinition()).thenReturn(dataSetDef); TableDisplayer table = createTableDisplayer(DisplayerSettingsFactory.newTableSettings().tablePageSize(10).buildSettings()); assertTrue(table.isTotalRowsExact(dataSet, 5)); assertTrue(table.isTotalRowsExact(dataSet, 10)); assertTrue(table.isTotalRowsExact(dataSet, 15)); }
@Test public void testIsTotalRowsExactRemote() { final DataSet dataSet = mock(DataSet.class); final DataSetDef dataSetDef = new DataSetDef(); dataSetDef.setProvider(() -> "REMOTE"); when(dataSet.getDefinition()).thenReturn(dataSetDef); TableDisplayer table = createTableDisplayer(DisplayerSettingsFactory.newTableSettings().tablePageSize(10).buildSettings()); assertTrue(table.isTotalRowsExact(dataSet, 5)); assertFalse(table.isTotalRowsExact(dataSet, 10)); assertFalse(table.isTotalRowsExact(dataSet, 15)); }