### Question:
AbstractSection extends VerticalLayout { public void addHeaderButton(Button button) { button.addStyleName(LinkkiTheme.BUTTON_TEXT); headerComponents.add(button); header.addComponent(button, 1); 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 testHeader_AddHeaderButton() { TestSection section = new TestSection("", false); HorizontalLayout header = section.getHeader(); Label captionLabel = (Label)header.getComponent(0); assertThat(header.isVisible(), is(false)); assertThat(captionLabel.isVisible(), is(false)); Button button = ComponentFactory.newButton(); section.addHeaderButton(button); assertThat(header.isVisible(), is(true)); assertThat(captionLabel.isVisible(), is(false)); }
@Test public void testAddHeaderButton() { TestSection section = new TestSection("CAP", true); HorizontalLayout header = section.getHeader(); assertThat(header.getComponentCount(), is(3)); assertThat(header.isVisible(), is(true)); Button button1 = new Button(); section.addHeaderButton(button1); assertThat(header.getComponentCount(), is(4)); assertThat(header.getComponent(1), is(button1)); Button button2 = new Button(); section.addHeaderButton(button2); assertThat(header.getComponentCount(), is(5)); assertThat(header.getComponent(1), is(button2)); assertThat(header.getComponent(2), is(button1)); section.setCaption("UPDATE"); assertThat(header.getComponentCount(), is(5)); assertThat(header.getComponent(1), is(button2)); assertThat(header.getComponent(2), is(button1)); }
@Test public void testHeaderButton_Style() { TestSection section = new TestSection("CAP", true); Button button1 = new Button(); section.addHeaderButton(button1); assertThat(button1.getStyleName(), containsString(LinkkiTheme.BUTTON_TEXT)); }