@Test public void testCreateContainerComponent() { ColumnBasedComponentCreator containerComponentCreator = spy(new TestColumnBasedComponentCreator()); ColumnBasedComponentFactory columnBasedComponentFactory = new ColumnBasedComponentFactory( containerComponentCreator); BindingContext bindingContext = new BindingContext(); TestContainerPmo containerPmo = new TestContainerPmo(); TableFooterPmo footerPmo = $ -> "foot"; containerPmo.setFooterPmo(footerPmo); TestColumnBasedComponent<?> containerComponent = new TestColumnBasedComponent<>(); TestColumnBasedComponentWrapper<?> containerComponentWrapper = new TestColumnBasedComponentWrapper<>( containerComponent); when(containerComponentCreator.createComponent(containerPmo)).thenReturn(containerComponentWrapper); Object createdContainerComponent = columnBasedComponentFactory.createContainerComponent(containerPmo, bindingContext); assertThat(createdContainerComponent, is(sameInstance(containerComponent))); Collection<Binding> bindings = bindingContext.getBindings(); assertThat(getNumberOfBindingsFor(containerComponent, bindings), is(1)); assertThat(getBindingFor(containerComponent, bindings).getPmo(), is(containerPmo)); verify(containerComponentCreator, times(2)).initColumn(eq(containerPmo), eq(containerComponentWrapper), any(BindingContext.class), any(PropertyElementDescriptors.class)); assertThat(containerComponent.getFooterPmo(), hasValue(footerPmo)); assertThat(containerComponent.getColumnsOnLastFooterUpdate(), is(2)); assertThat(containerComponent.getPageLength(), is(0)); containerPmo.addItem(new TestRowPmo()); bindingContext.modelChanged(); assertThat(containerComponent.getPageLength(), is(1)); }
public Object createContainerComponent(ContainerPmo<?> containerPmo, BindingContext bindingContext) { ComponentWrapper tableWrapper = containerComponentCreator .createComponent(requireNonNull(containerPmo, "containerPmo must not be null")); requireNonNull(bindingContext, "bindingContext must not be null"); List<LinkkiAspectDefinition> tableAspects = AspectAnnotationReader .createAspectDefinitionsFor(containerPmo.getClass()); ContainerBinding binding = bindingContext.bindContainer(containerPmo, BoundProperty.empty(), tableAspects, tableWrapper); createColumns(containerPmo, tableWrapper, binding); binding.updateFromPmo(); return tableWrapper.getComponent(); }
ColumnBasedComponentFactory { public Object createContainerComponent(ContainerPmo<?> containerPmo, BindingContext bindingContext) { ComponentWrapper tableWrapper = containerComponentCreator .createComponent(requireNonNull(containerPmo, "containerPmo must not be null")); requireNonNull(bindingContext, "bindingContext must not be null"); List<LinkkiAspectDefinition> tableAspects = AspectAnnotationReader .createAspectDefinitionsFor(containerPmo.getClass()); ContainerBinding binding = bindingContext.bindContainer(containerPmo, BoundProperty.empty(), tableAspects, tableWrapper); createColumns(containerPmo, tableWrapper, binding); binding.updateFromPmo(); return tableWrapper.getComponent(); } }
ColumnBasedComponentFactory { public Object createContainerComponent(ContainerPmo<?> containerPmo, BindingContext bindingContext) { ComponentWrapper tableWrapper = containerComponentCreator .createComponent(requireNonNull(containerPmo, "containerPmo must not be null")); requireNonNull(bindingContext, "bindingContext must not be null"); List<LinkkiAspectDefinition> tableAspects = AspectAnnotationReader .createAspectDefinitionsFor(containerPmo.getClass()); ContainerBinding binding = bindingContext.bindContainer(containerPmo, BoundProperty.empty(), tableAspects, tableWrapper); createColumns(containerPmo, tableWrapper, binding); binding.updateFromPmo(); return tableWrapper.getComponent(); } ColumnBasedComponentFactory(ColumnBasedComponentCreator containerComponentCreator); }
ColumnBasedComponentFactory { public Object createContainerComponent(ContainerPmo<?> containerPmo, BindingContext bindingContext) { ComponentWrapper tableWrapper = containerComponentCreator .createComponent(requireNonNull(containerPmo, "containerPmo must not be null")); requireNonNull(bindingContext, "bindingContext must not be null"); List<LinkkiAspectDefinition> tableAspects = AspectAnnotationReader .createAspectDefinitionsFor(containerPmo.getClass()); ContainerBinding binding = bindingContext.bindContainer(containerPmo, BoundProperty.empty(), tableAspects, tableWrapper); createColumns(containerPmo, tableWrapper, binding); binding.updateFromPmo(); return tableWrapper.getComponent(); } ColumnBasedComponentFactory(ColumnBasedComponentCreator containerComponentCreator); Object createContainerComponent(ContainerPmo<?> containerPmo, BindingContext bindingContext); }
ColumnBasedComponentFactory { public Object createContainerComponent(ContainerPmo<?> containerPmo, BindingContext bindingContext) { ComponentWrapper tableWrapper = containerComponentCreator .createComponent(requireNonNull(containerPmo, "containerPmo must not be null")); requireNonNull(bindingContext, "bindingContext must not be null"); List<LinkkiAspectDefinition> tableAspects = AspectAnnotationReader .createAspectDefinitionsFor(containerPmo.getClass()); ContainerBinding binding = bindingContext.bindContainer(containerPmo, BoundProperty.empty(), tableAspects, tableWrapper); createColumns(containerPmo, tableWrapper, binding); binding.updateFromPmo(); return tableWrapper.getComponent(); } ColumnBasedComponentFactory(ColumnBasedComponentCreator containerComponentCreator); Object createContainerComponent(ContainerPmo<?> containerPmo, BindingContext bindingContext);  }