ByteArrayUploadDataProvider extends UploadDataProvider { @Override public void read(UploadDataSink uploadDataSink, ByteBuffer byteBuffer) throws IOException { int readLength = Math.min(byteBuffer.remaining(), data.length - position); byteBuffer.put(data, position, readLength); position += readLength; uploadDataSink.onReadSucceeded(false); } ByteArrayUploadDataProvider(byte[] data); @Override long getLength(); @Override void read(UploadDataSink uploadDataSink, ByteBuffer byteBuffer); @Override void rewind(UploadDataSink uploadDataSink);  }
@Test public void testReadFullBuffer() throws IOException { byteArrayUploadDataProvider.read(mockUploadDataSink, byteBuffer); assertThat(byteBuffer.array()).isEqualTo(TEST_DATA); }