### Question:
ImageUtil { public static String convertToBase64(Bitmap bitmap, int maxWidth, int maxHeight) { if (bitmap == null) { return null; } long startTime = System.currentTimeMillis(); int[] targetSize = computeTargetSize(bitmap, maxWidth, maxHeight); Bitmap thumbnail = ThumbnailUtils.extractThumbnail(bitmap, targetSize[0], targetSize[1]); ByteArrayOutputStream baos = new ByteArrayOutputStream(); thumbnail.compress(Bitmap.CompressFormat.PNG, 100, baos); String result = Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT); return result; }  static String convertToBase64(Bitmap bitmap, int maxWidth, int maxHeight);  }### Answer:
@Test public void convertToBase64() { String base642 = ImageUtil.convertToBase64(null, 5, 5); Assert.assertNull(base642); Bitmap bitmap = ShadowBitmapFactory.create("AndroidGodEye-Image", null, new Point(10, 10)); String base64 = ImageUtil.convertToBase64(bitmap, 5, 5); Assert.assertNotNull(base64); }