ImageService { @Nullable public static Bitmap asBitmap(@NonNull final DownloadResponse downloadResponse, final int requestedWidth) { final byte[] bytes = downloadResponse.getByteArray(); return byteArrayToBitmap(bytes, requestedWidth); }  @Nullable static Bitmap asBitmap(@NonNull final DownloadResponse downloadResponse, final int requestedWidth); @Nullable static Bitmap byteArrayToBitmap(@NonNull final byte[] bytes, final int requestedWidth); static long getMemBytes(@NonNull Options options); static int calculateInSampleSize(final int nativeWidth, int requestedWidth);  }
@Test public void asBitmap_withMaxSize_shouldReturnBitmap() { String imageData = "fake_bitmap_data"; when(downloadResponse.getByteArray()).thenReturn(imageData.getBytes()); final Bitmap bitmap = ImageService.asBitmap(downloadResponse, 30); assertThat(bitmap).isNotNull(); assertThat(bitmap).isInstanceOf(Bitmap.class); }
@Test(expected = NullPointerException.class) public void asBitmap_withNullResponse_shouldThrowNullPointerException() throws Exception { ImageService.asBitmap(null, 30); }