### Question:
PmoBasedSectionFactory { public static AbstractSection createAndBindSection(Object pmo, BindingContext bindingContext) { requireNonNull(pmo, "pmo must not be null"); requireNonNull(bindingContext, "bindingContext must not be null"); Class<? extends Object> pmoClass = pmo.getClass(); LinkkiComponentDefinition componentDefinition = ComponentAnnotationReader.findComponentDefinition(pmoClass) .orElse(SectionComponentDefiniton.DEFAULT); LinkkiLayoutDefinition layoutDefinition = LayoutAnnotationReader.findLayoutDefinition(pmoClass) .orElse(SectionLayoutDefinition.DEFAULT); ComponentWrapper componentWrapper = UiCreator .createComponent(pmo, bindingContext, componentDefinition, Optional.of(layoutDefinition)); return (AbstractSection)componentWrapper.getComponent(); }  AbstractSection createSection(Object pmo, BindingContext bindingContext); BaseSection createBaseSection(Object pmo, BindingContext bindingContext); TableSection createTableSection(ContainerPmo<T> pmo, BindingContext bindingContext); static AbstractSection createAndBindSection(Object pmo, BindingContext bindingContext);  }### Answer:
@Test public void testSetSectionId() { AbstractSection section = PmoBasedSectionFactory.createAndBindSection(new SCCPmoWithID(), bindingContext); assertThat(section.getId(), is("test-ID")); }
@Test public void testSetSectionDefaultId() { AbstractSection section = PmoBasedSectionFactory.createAndBindSection(new SCCPmoWithoutID(), bindingContext); assertThat(section.getId(), is("SCCPmoWithoutID")); }
@Test public void testSetComponentId() { AbstractSection section = PmoBasedSectionFactory.createAndBindSection(new SCCPmoWithID(), bindingContext); @SuppressWarnings("deprecation") GridLayout gridLayout = TestUiUtil .getContentGrid((org.linkki.core.vaadin.component.section.FormSection)section); Component textField = gridLayout.getComponent(1, 0); assertThat(textField.getId(), is("testProperty")); }
@SuppressWarnings("deprecation") @Test public void testSectionWithDefaultLayout_shouldCreateFormSection() { AbstractSection section = PmoBasedSectionFactory.createAndBindSection(new SCCPmoWithoutID(), bindingContext); assertThat(section, is(instanceOf(org.linkki.core.vaadin.component.section.FormSection.class))); }
@Test public void testSectionWithHorizontalLayout_shouldCreateHorizontalSection() { AbstractSection section = PmoBasedSectionFactory.createAndBindSection(new SectionWithHorizontalLayout(), bindingContext); assertThat(section, is(instanceOf(HorizontalSection.class))); }
@Test public void testSectionWithCustomLayout_shouldCreateCustomLayoutSection() { AbstractSection section = PmoBasedSectionFactory.createAndBindSection(new SectionWithCustomLayout(), bindingContext); assertThat(section, is(instanceOf(CustomLayoutSection.class))); }
@SuppressWarnings("deprecation") @Test public void testSectionWithoutAnnotation_usesDefaultValues() { AbstractSection section = PmoBasedSectionFactory.createAndBindSection(new SectionWithoutAnnotation(), bindingContext); assertThat(section, is(instanceOf(org.linkki.core.vaadin.component.section.FormSection.class))); assertThat(section.getId(), is(SectionWithoutAnnotation.class.getSimpleName())); assertThat(section.getCaption(), is(nullValue())); assertThat(((org.linkki.core.vaadin.component.section.FormSection)section).getNumberOfColumns(), is(1)); }