### Question:
RealBufferedSink implements BufferedSink { @Override public BufferedSink writeUtf8(String string) throws IOException { if (closed) throw new IllegalStateException("closed"); buffer.writeUtf8(string); return emitCompleteSegments(); } RealBufferedSink(Sink sink, Buffer buffer);  RealBufferedSink(Sink sink); @Override Buffer buffer(); @Override void write(Buffer source, long byteCount); @Override BufferedSink write(ByteString byteString); @Override BufferedSink writeUtf8(String string); @Override BufferedSink writeUtf8(String string, int beginIndex, int endIndex); @Override BufferedSink writeUtf8CodePoint(int codePoint); @Override BufferedSink writeString(String string, Charset charset); @Override BufferedSink writeString(String string, int beginIndex, int endIndex,
      Charset charset); @Override BufferedSink write(byte[] source); @Override BufferedSink write(byte[] source, int offset, int byteCount); @Override long writeAll(Source source); @Override BufferedSink write(Source source, long byteCount); @Override BufferedSink writeByte(int b); @Override BufferedSink writeShort(int s); @Override BufferedSink writeShortLe(int s); @Override BufferedSink writeInt(int i); @Override BufferedSink writeIntLe(int i); @Override BufferedSink writeLong(long v); @Override BufferedSink writeLongLe(long v); @Override BufferedSink writeDecimalLong(long v); @Override BufferedSink writeHexadecimalUnsignedLong(long v); @Override BufferedSink emitCompleteSegments(); @Override BufferedSink emit(); @Override OutputStream outputStream(); @Override void flush(); @Override void close(); @Override Timeout timeout(); @Override String toString(); final Buffer buffer; final Sink sink; }### Answer:
@Test public void bytesNotEmittedToSinkWithoutFlush() throws Exception { Buffer sink = new Buffer(); BufferedSink bufferedSink = new RealBufferedSink(sink); bufferedSink.writeUtf8("abc"); assertEquals(0, sink.size()); }
@Test public void completeSegmentsEmitted() throws Exception { Buffer sink = new Buffer(); BufferedSink bufferedSink = new RealBufferedSink(sink); bufferedSink.writeUtf8(repeat('a', Segment.SIZE * 3)); assertEquals(Segment.SIZE * 3, sink.size()); }
@Test public void incompleteSegmentsNotEmitted() throws Exception { Buffer sink = new Buffer(); BufferedSink bufferedSink = new RealBufferedSink(sink); bufferedSink.writeUtf8(repeat('a', Segment.SIZE * 3 - 1)); assertEquals(Segment.SIZE * 2, sink.size()); }