ComponentGridDecorator implements Serializable { public ComponentGridDecorator<T> setRows(Collection<T> beans) { gpc.removeAllItems(); addAll(beans); return this; } ComponentGridDecorator(Grid grid, Class<T> typeOfRows); FocusPreserveExtension getFocusPreserveExtension(); Grid getGrid(); Grid.Column addComponentColumn(Object propertyId, ComponentGenerator<T> generator); ComponentGridDecorator<T> setRows(Collection<T> beans); ComponentGridDecorator<T> addAll(Collection<T> beans); ComponentGridDecorator<T> remove(T bean); ComponentGridDecorator<T> add(T bean); ComponentGridDecorator<T> refresh(); ComponentGridDecorator<T> generateHeaders(ComponentHeaderGenerator generator); ComponentGridDecorator<T> generateHeaders(TextHeaderGenerator generator); ComponentGridDecorator<T> generateHeaders(HtmlHeaderGenerator generator);  }
@Test public void testSetRows() { Grid grid = createTestGrid(); ComponentGridDecorator<ExampleBean> decorator = new ComponentGridDecorator<>(grid, ExampleBean.class); assertThat(grid.getContainerDataSource().getItemIds().size(), is(10)); List<ExampleBean> newBeans = new ArrayList<>(); for(int i=0;i<2;i++) { ExampleBean bean = new ExampleBean(); bean.setCaption("new" +i); bean.setIsSomething(true); newBeans.add(bean); } decorator.setRows(newBeans); assertThat(grid.getContainerDataSource().getItemIds().size(), is(2)); Item firstItem = grid.getContainerDataSource().getItem(grid.getContainerDataSource().getIdByIndex(0)); assertThat((String)firstItem.getItemProperty(COLUMN_CAPTION).getValue(), is("new0")); }