@Override
  public void setSpool(final Writer writer) {
    spool.ifPresent(ignored -> {
      throw new KsqlException("Cannot set two spools! Please issue SPOOL OFF.");
    });
    spool = Optional.of(new Spool(writer, terminal.writer()));
  }
@Test
  public void shouldThrowOnTwoSpools() {
    // Given:
    final Writer spool = mock(Writer.class);
    terminal.setSpool(spool);

    // When:
    final KsqlException e = assertThrows(
        KsqlException.class,
        () -> terminal.setSpool(spool)
    );

    // Then:
    assertThat(e.getMessage(), containsString("Cannot set two spools!"));
  }