### Question:
RealBufferedSink implements BufferedSink { @Override public long writeAll(Source source) throws IOException { if (source == null) throw new IllegalArgumentException("source == null"); long totalBytesRead = 0; for (long readCount; (readCount = source.read(buffer, Segment.SIZE)) != -1; ) { totalBytesRead += readCount; emitCompleteSegments(); } return totalBytesRead; } 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 writeAll() throws IOException { MockSink mockSink = new MockSink(); BufferedSink bufferedSink = Okio.buffer(mockSink); bufferedSink.buffer().writeUtf8("abc"); assertEquals(3, bufferedSink.writeAll(new Buffer().writeUtf8("def"))); assertEquals(6, bufferedSink.buffer().size()); assertEquals("abcdef", bufferedSink.buffer().readUtf8(6)); mockSink.assertLog(); }