### Question:
PmoBasedTableFactory { public Table createTable() { return (Table)CONTAINER_COMPONENT_FACTORY.createContainerComponent(containerPmo, bindingContext); } PmoBasedTableFactory(ContainerPmo<?> containerPmo, BindingContext bindingContext); Table createTable();  }### Answer:
@Test public void testPageLength() { TestTablePmo tablePmo = new TestTablePmo(15); Table table = new PmoBasedTableFactory(tablePmo, bindingContext).createTable(); ItemSetChangeListener itemSetChangedListener = addItemSetChangeListener(bindingContext); assertThat(table.getPageLength(), is(15)); tablePmo.setPageLength(25); bindingContext.modelChanged(); assertThat(table.getPageLength(), is(25)); verifyNoInteractions(itemSetChangedListener); }
@Test public void testItems_AfterConstruction() { TestRowPmo rowPmo1 = new TestRowPmo(); TestRowPmo rowPmo2 = new TestRowPmo(); TestTablePmo tablePmo = new TestTablePmo(rowPmo1, rowPmo2); Table table = new PmoBasedTableFactory(tablePmo, bindingContext).createTable(); assertThat(tablePmo.getItems(), contains(rowPmo1, rowPmo2)); assertThat(table.getItemIds(), contains(rowPmo1, rowPmo2)); }
@Test public void testItems_UponUpdate_AddItems() { TestTablePmo tablePmo = new TestTablePmo(); Table table = new PmoBasedTableFactory(tablePmo, bindingContext).createTable(); ItemSetChangeListener itemSetChangedListener = addItemSetChangeListener(bindingContext); assertThat(table.getItemIds(), is(empty())); TestRowPmo newRow = new TestRowPmo(); tablePmo.getItems().add(newRow); bindingContext.modelChanged(); assertThat(tablePmo.getItems(), contains(newRow)); assertThat(table.getItemIds(), contains(newRow)); verify(itemSetChangedListener).containerItemSetChange(any()); verifyNoMoreInteractions(itemSetChangedListener); }
@Test public void testItems_UponUpdate_RemoveItems() { TestRowPmo row1 = new TestRowPmo(); TestRowPmo row2 = new TestRowPmo(); TestTablePmo tablePmo = new TestTablePmo(row1, row2); Table table = new PmoBasedTableFactory(tablePmo, bindingContext).createTable(); ItemSetChangeListener itemSetChangedListener = addItemSetChangeListener(bindingContext); assertThat(table.getItemIds().size(), is(2)); tablePmo.getItems().remove(row1); bindingContext.modelChanged(); assertThat(tablePmo.getItems(), contains(row2)); assertThat(table.getItemIds(), contains(row2)); verify(itemSetChangedListener).containerItemSetChange(any()); verifyNoMoreInteractions(itemSetChangedListener); }
@Test public void testDataSourceSet() { TestTablePmo tablePmo = new TestTablePmo(); Table table = new PmoBasedTableFactory(tablePmo, bindingContext).createTable(); assertThat(getTableContainer(bindingContext), is(table.getContainerDataSource())); }
@Test public void testFooterUpdateAfterConstruction() { TableFooterPmo footerPmo = property -> property; TestTablePmo tablePmo = new TestTablePmo(footerPmo); Table table = new PmoBasedTableFactory(tablePmo, bindingContext).createTable(); ItemSetChangeListener itemSetChangedListener = addItemSetChangeListener(bindingContext); assertThat(table.isFooterVisible()); assertThat(table.getColumnFooter(TestRowPmo.PROPERTY_VALUE_1), is(TestRowPmo.PROPERTY_VALUE_1)); assertThat(table.getColumnFooter(TestRowPmo.PROPERTY_VALUE_2), is(TestRowPmo.PROPERTY_VALUE_2)); tablePmo.setFooterPmo(null); bindingContext.modelChanged(); assertThat(table.isFooterVisible(), is(false)); verifyNoMoreInteractions(itemSetChangedListener); tablePmo.setFooterPmo(property -> "test"); bindingContext.modelChanged(); assertThat(table.isFooterVisible()); assertThat(table.getColumnFooter(TestRowPmo.PROPERTY_VALUE_1), is("test")); verifyNoMoreInteractions(itemSetChangedListener); }