### Question:
GrpcOutputStream extends OutputStream { @Override public void write(int b) { try { buffer.write(b); if (buffer.size() >= bufferSize) { flushBuffer(false); } } catch (Exception ex) { responseObserver.onError(ex); } } GrpcOutputStream(
      StreamObserver<CopyContainerResponseProto> responseObserver,
      long containerId, int bufferSize); @Override void write(int b); @Override void write(@Nonnull byte[] data, int offset, int length); @Override void close();  }### Answer:
@Test public void bufferFlushedWhenFull() throws IOException { byte[] bytes = getRandomBytes(bufferSize); subject.write(bytes, 0, bufferSize-1); subject.write(bytes[bufferSize-1]); verify(observer).onNext(any()); subject.write(bytes[0]); subject.write(bytes, 1, bufferSize-1); verify(observer, times(2)).onNext(any()); }