### Question:
DownloadUriOutputStream implements DownloadOutputStream { @Override public void flushAndSync() throws IOException { out.flush(); pdf.getFileDescriptor().sync(); } DownloadUriOutputStream(Context context, Uri uri, int bufferSize);   DownloadUriOutputStream(@NonNull FileChannel channel, @NonNull ParcelFileDescriptor pdf,
                            @NonNull FileOutputStream fos,
                            @NonNull BufferedOutputStream out); @Override void write(byte[] b, int off, int len); @Override void close(); @Override void flushAndSync(); @Override void seek(long offset); @Override void setLength(long newLength);  }### Answer:
@Test public void flushAndSync() throws Exception { when(pdf.getFileDescriptor()).thenReturn(fd); thrown.expect(SyncFailedException.class); thrown.expectMessage("sync failed"); outputStream.flushAndSync(); verify(out).flush(); }