### Question:
CloudFoundryMetadataContributor implements MetadataContributor { @Override public Map<String, String> getMetadata() { if (StringUtils.hasText(this.cfApplicationProperties.getApplicationId()) && StringUtils.hasText(this.cfApplicationProperties.getInstanceIndex())) { Map<String, String> map = new HashMap<>(); map.put("applicationId", this.cfApplicationProperties.getApplicationId()); map.put("instanceId", this.cfApplicationProperties.getInstanceIndex()); return map; } return Collections.emptyMap(); } CloudFoundryMetadataContributor(CloudFoundryApplicationProperties cfApplicationProperties); @Override Map<String, String> getMetadata();  }### Answer:
@Test public void should_return_empty_metadata() { CloudFoundryMetadataContributor contributor = new CloudFoundryMetadataContributor( new CloudFoundryApplicationProperties()); assertThat(contributor.getMetadata()).isEmpty(); }
@Test public void should_return_metadata() { CloudFoundryApplicationProperties cfApplicationProperties = new CloudFoundryApplicationProperties(); cfApplicationProperties.setApplicationId("appId"); cfApplicationProperties.setInstanceIndex("1"); CloudFoundryMetadataContributor contributor = new CloudFoundryMetadataContributor(cfApplicationProperties); assertThat(contributor.getMetadata()).containsEntry("applicationId", "appId").containsEntry("instanceId", "1"); }