public boolean accept(final T t) {
    checkContext();
    if (isComplete() || hasSentComplete()) {
      throw new IllegalStateException("Cannot call accept after complete is called");
    }
    if (!isCancelled() && !isFailed()) {
      if (getDemand() == 0) {
        buffer.add(t);
      } else {
        doOnNext(t);
      }
    }
    return buffer.size() >= bufferMaxSize;
  }
@Test
  public void shouldAcceptBuffered() throws Exception {
    publisher = new BufferedPublisher<>(context, 5);
    AsyncAssert asyncAssert = new AsyncAssert();
    for (int i = 0; i < 10; i++) {
      String record = expectedValue(i);
      final int index = i;
      execOnContextAndWait(() -> {
        boolean bufferFull = getBufferedPublisher().accept(record);
        asyncAssert.assertAsync(bufferFull, equalTo(index >= 5));
      });
    }
  }