public void scheduleHeartbeat() {
    startedHeartbeat = executorService.schedule(heartbeatTask, DEFAULT_HEARTBEAT_PERIOD, TimeUnit.SECONDS);
  }
@Test
  public void flush_exceptionIsPropagated() throws IOException {
    when(servletResponse.getOutputStream()).thenThrow(new IOException("mock exception"));
    when(executorService.schedule(any(HeartbeatTask.class), anyLong(), any(TimeUnit.class))).thenReturn(task);
    underTest.scheduleHeartbeat();

    assertThatThrownBy(underTest::flush)
      .isInstanceOf(IllegalStateException.class);
  }