### Question:
AbstractSection extends VerticalLayout { @Override public void setCaption(@CheckForNull String caption) { captionLabel.setValue(caption); captionLabel.setVisible(!StringUtils.isEmpty(caption)); updateHeader(); } AbstractSection(@CheckForNull String caption);  AbstractSection(@CheckForNull String caption, boolean closeable); @Deprecated  AbstractSection(@CheckForNull String caption, boolean closeable, Optional<Button> editButton); @Override void setCaption(@CheckForNull String caption); void addHeaderButton(Button button); void addHeaderComponent(Component component); boolean isOpen(); boolean isClosed(); void open(); void close();  }### Answer:
@Test public void testSetCaption() { TestSection section = new TestSection("CAP", false); HorizontalLayout header = section.getHeader(); Label captionLabel = (Label)header.getComponent(0); assertThat(header.isVisible(), is(true)); assertThat(captionLabel.isVisible(), is(true)); assertThat(captionLabel.getValue(), is("CAP")); section.setCaption("TION"); assertThat(header.isVisible(), is(true)); assertThat(captionLabel.isVisible(), is(true)); assertThat(captionLabel.getValue(), is("TION")); }
@Test public void testSetCaption_Null() { TestSection section = new TestSection("CAP", false); HorizontalLayout header = section.getHeader(); Label captionLabel = (Label)header.getComponent(0); assertThat(header.isVisible(), is(true)); assertThat(captionLabel.isVisible(), is(true)); assertThat(captionLabel.getValue(), is("CAP")); section.setCaption(null); assertThat(header.isVisible(), is(false)); assertThat(captionLabel.isVisible(), is(false)); }
@Test public void testSetCaption_Empty() { TestSection section = new TestSection("CAP", false); HorizontalLayout header = section.getHeader(); Label captionLabel = (Label)header.getComponent(0); assertThat(header.isVisible(), is(true)); assertThat(captionLabel.isVisible(), is(true)); assertThat(captionLabel.getValue(), is("CAP")); section.setCaption(""); assertThat(header.isVisible(), is(false)); assertThat(captionLabel.isVisible(), is(false)); }