ByteArrayUploadDataProvider extends UploadDataProvider { @Override public void rewind(UploadDataSink uploadDataSink) throws IOException { position = 0; uploadDataSink.onRewindSucceeded(); } ByteArrayUploadDataProvider(byte[] data); @Override long getLength(); @Override void read(UploadDataSink uploadDataSink, ByteBuffer byteBuffer); @Override void rewind(UploadDataSink uploadDataSink);  }
@Test public void testRewind() throws IOException { byteArrayUploadDataProvider.read(mockUploadDataSink, byteBuffer); assertThat(byteBuffer.array()).isEqualTo(TEST_DATA); byteBuffer.clear(); byteArrayUploadDataProvider.rewind(mockUploadDataSink); byteArrayUploadDataProvider.read(mockUploadDataSink, byteBuffer); assertThat(byteBuffer.array()).isEqualTo(TEST_DATA); verify(mockUploadDataSink).onRewindSucceeded(); }