checkMetadataKeyAbsentFor(VM, newMetadata, key);
}
@Test(description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" })
public void testMergeMetadata() {
Metadata oldMetadata = context.getApi().getMetadataApi(vmUrn).get();
Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata);
// Store a value, to be removed
String key = name("key-");
String value = name("value-");
Task task = context.getApi().getMetadataApi(vmUrn).putAll(ImmutableMap.of(key, value));
retryTaskSuccess.apply(task);
// Confirm the entry contains everything that was there, and everything that was being added
Metadata newMetadata = context.getApi().getMetadataApi(vmUrn).get();
Map<String, String> expectedMetadataMap = ImmutableMap.<String, String> builder().putAll(oldMetadataMap)
.put(key, value).build();
// Check the retrieved object is well formed
checkMetadataFor(VM, newMetadata, expectedMetadataMap);