ImageDataRetriever { public String getImageURL(final Pair<String, byte[]> imageDetails) { if (imageDetails == null) { logger.error("Cannot fetch the Image URL if the details of the image is not present"); return null; } String imageID = imageDetails.getLeft(); if (imageID == null) { logger.error("Cannot fetch the Image URL if the image ID is not present"); return null; } String template = config.getValue(AuditNotifier.Property.AUDIT_METRIC_IMAGE_URL_TEMPLATE.getName(), AuditNotifier.Property.AUDIT_METRIC_IMAGE_URL_TEMPLATE.getDefaultValue()); return template.replaceAll("\\$imageID\\$", imageID); } @Inject  ImageDataRetriever(ImageService imageService, SystemConfiguration systemConfiguration); String getImageURL(final Pair<String, byte[]> imageDetails); Pair<String, byte[]> getAnnotatedImage(final ImageDataRetrievalContext context);  }
@Test public void testGetImageUrl() { String imageURL = imageDataRetriever.getImageURL(Pair.of(IMAGE_ID, "Test String".getBytes())); assertEquals(imageURL, IMAGE_URL_PREFIX + IMAGE_ID); }
@Test public void testGetImageUrlWhenImageDetailsIsNull() { String imageURL = imageDataRetriever.getImageURL(null); assertEquals(imageURL, null); }
@Test public void testGetImageUrlWhenImageIDIsNull() { String imageURL = imageDataRetriever.getImageURL(Pair.of(null, null)); assertEquals(imageURL, null); }