@Before public void beforeCellTableTest() { // Create a CellTable. table = new DataGrid<Contact>(); // Create name column. TextColumn<Contact> nameColumn = new TextColumn<Contact>() { @Override public String getValue(Contact contact) { return contact.name; } }; // Create address column. TextColumn<Contact> addressColumn = new TextColumn<Contact>() { @Override public String getValue(Contact contact) { return contact.address; } }; // Add the columns. table.addColumn(nameColumn, "Name"); table.addColumn(addressColumn, "Address"); // Set the total row count. This isn't strictly necessary, but it affects // paging calculations, so its good habit to keep the row count up to // date. table.setRowCount(CONTACTS.size(), true); // Push the data into the widget. table.setRowData(0, CONTACTS); table.setVisibleRange(0, 2); // Preconditions assertThat(table.getRowCount()).isEqualTo(3); assertThat(table.getVisibleItemCount()).isEqualTo(2); }