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 shouldCompleteAfterDeliveringRecordsNoBuffering() throws Exception {
    AsyncAssert asyncAssertOnNext = new AsyncAssert();
    TestSubscriber<String> subscriber = new TestSubscriber<String>(context) {
      @Override
      public synchronized void onSubscribe(final Subscription sub) {
        super.onSubscribe(sub);
        sub.request(1);
      }

      @Override
      public synchronized void onNext(final String value) {
        super.onNext(value);
        asyncAssertOnNext.assertAsync(isCompleted(), equalTo(false));
        getSub().request(1);
      }
    };
    subscribeOnContext(subscriber);
    AsyncAssert assertNotBufferFull = new AsyncAssert();
    for (int i = 0; i < 10; i++) {
      String record = expectedValue(i);
      execOnContextAndWait(() -> {
        boolean bufferFull = getBufferedPublisher().accept(record);
        assertNotBufferFull.assertAsync(bufferFull, equalTo(false));
      });
      assertThatEventually(subscriber::getValues, hasSize(i + 1));
      assertThat(subscriber.getValues().get(i), equalTo(record));
    }
    asyncAssertOnNext.throwAssert();
    assertNotBufferFull.throwAssert();

    execOnContextAndWait(getBufferedPublisher()::complete);
    assertThatEventually(subscriber::isCompleted, equalTo(true));
  }