### Question:
CompositeMetadataContributor implements MetadataContributor { @Override public Map<String, String> getMetadata() { Map<String, String> metadata = new LinkedHashMap<>(); delegates.forEach((delegate) -> metadata.putAll(delegate.getMetadata())); return metadata; } CompositeMetadataContributor(List<MetadataContributor> delegates); @Override Map<String, String> getMetadata();  }### Answer:
@Test public void should_merge_metadata() { CompositeMetadataContributor contributor = new CompositeMetadataContributor( asList(() -> singletonMap("a", "first"), () -> singletonMap("b", "second"), () -> singletonMap("b", "second-new"))); Map<String, String> metadata = contributor.getMetadata(); assertThat(metadata).containsExactly(entry("a", "first"), entry("b", "second-new")); }
@Test public void should_return_empty_metadata() { CompositeMetadataContributor contributor = new CompositeMetadataContributor(emptyList()); Map<String, String> metadata = contributor.getMetadata(); assertThat(metadata).isEmpty(); }