BitmapHelper { boolean compressBitmap(@Nullable Bitmap bitmap, String filename) { if (bitmap == null) { return false; } OutputStream out = null; boolean saved = false; try { out = new BufferedOutputStream(new FileOutputStream(filename)); saved = bitmap.compress(Bitmap.CompressFormat.JPEG, QUALITY_FULL, out); } catch (FileNotFoundException e) { Timber.e(e); } finally { fileHelper.close(out); } return saved; } @Inject  BitmapHelper(FileHelper fileHelper);   }
@Test public void compressBitmapShouldReturnFalseForNullBitmap() { boolean compressed = bitmapHelper.compressBitmap(null, "abc"); assertFalse(compressed); }
@Test public void compressBitmapShouldReturnFalseForFileNotFound() { boolean compressed = bitmapHelper.compressBitmap(mockBitmap, ""); assertFalse(compressed); }
@Test public void compressBitmapShouldReturnTrue() { boolean compressed = bitmapHelper.compressBitmap(mockBitmap, "abc"); assertTrue(compressed); }