MediaResolverHelper { @Nullable public ParcelFileDescriptor openFileDescriptor(@NonNull Uri uri) { try { return context.getContentResolver().openFileDescriptor(uri, "r"); } catch (FileNotFoundException e) { Timber.e(e); return null; } } @Inject  MediaResolverHelper(Context context, ExifHelper exifHelper, FileHelper fileHelper); @Nullable InputStream getInputStreamFromUri(@NonNull Uri uri); @Nullable ParcelFileDescriptor openFileDescriptor(@NonNull Uri uri); boolean removeDuplicateImage(@NonNull Uri uri);  }
@Test public void openFileDescriptorShouldReturnNullWhenUriNotFound() throws FileNotFoundException { when(mockContentResolver.openFileDescriptor(any(Uri.class), anyString())) .thenThrow(FileNotFoundException.class); ParcelFileDescriptor fileDescriptor = helper.openFileDescriptor(mockUri); assertNull(fileDescriptor); }