OverviewSupplier implements BiFunction<Metacard, Map<String, Serializable>, Optional<BufferedImage>> { @Override public Optional<BufferedImage> apply(Metacard metacard, Map<String, Serializable> arguments) { try { final Map<String, Serializable> resourceTransformerArguments = new HashMap<>(); resourceTransformerArguments.put(ContentItem.QUALIFIER_KEYWORD, "overview"); final BinaryContent overviewContent = resourceMetacardTransformer.transform(metacard, resourceTransformerArguments); try (final InputStream inputStream = overviewContent.getInputStream()) { return Optional.ofNullable(ImageIO.read(inputStream)); } } catch (IOException | CatalogTransformerException e) { LOGGER.debug("Could not get the overview image.", e); } return Optional.empty(); } OverviewSupplier(MetacardTransformer resourceMetacardTransformer); @Override Optional<BufferedImage> apply(Metacard metacard, Map<String, Serializable> arguments);  }
@Test public void testOverview() { final Metacard metacard = new MetacardImpl(); metacard.setAttribute(new AttributeImpl(Core.DERIVED_RESOURCE_URI, "content:abc123#overview")); assertThat(supplier.apply(metacard, null).isPresent(), is(true)); }
@Test public void testNoOverview() { assertThat(supplier.apply(new MetacardImpl(), null).isPresent(), is(false)); }