}
@Test(groups = { "live", "user" }, description = "PUT /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetLeaseSettingsSection" })
public void testEditLeaseSettingsSection() {
// Copy existing section
LeaseSettingsSection oldSection = vAppApi.getLeaseSettingsSection(vAppUrn);
Integer twoHours = (int) TimeUnit.SECONDS.convert(2L, TimeUnit.HOURS);
LeaseSettingsSection newSection = oldSection.toBuilder().deploymentLeaseInSeconds(twoHours).build();
// The method under test
Task editLeaseSettingsSection = vAppApi.editLeaseSettingsSection(vAppUrn, newSection);
assertTrue(retryTaskSuccess.apply(editLeaseSettingsSection),
String.format(TASK_COMPLETE_TIMELY, "editLeaseSettingsSection"));
// Retrieve the modified section
LeaseSettingsSection modified = vAppApi.getLeaseSettingsSection(vAppUrn);
// Check the retrieved object is well formed
checkLeaseSettingsSection(modified);
// Check the date fields
if (modified.getDeploymentLeaseExpiration() != null && newSection.getDeploymentLeaseExpiration() != null) {
assertTrue(modified.getDeploymentLeaseExpiration().after(newSection.getDeploymentLeaseExpiration()),
String.format("The new deploymentLeaseExpiration timestamp must be later than the original: %s > %s",
dateService.iso8601DateFormat(modified.getDeploymentLeaseExpiration()),
dateService.iso8601DateFormat(newSection.getDeploymentLeaseExpiration())));
}
if (modified.getStorageLeaseExpiration() != null && newSection.getStorageLeaseExpiration() != null) {
assertTrue(modified.getStorageLeaseExpiration().after(newSection.getStorageLeaseExpiration()), String.format(
"The new storageLeaseExpiration timestamp must be later than the original: %s > %s",
dateService.iso8601DateFormat(modified.getStorageLeaseExpiration()),
dateService.iso8601DateFormat(newSection.getStorageLeaseExpiration())));
}
// Reset the date fields
modified = modified.toBuilder().deploymentLeaseExpiration(null).storageLeaseExpiration(null).build();
newSection = newSection.toBuilder().deploymentLeaseExpiration(null).storageLeaseExpiration(null).build();
// Check the section was modified correctly
assertEquals(
modified.getDeploymentLeaseInSeconds(),
twoHours,
String.format(OBJ_FIELD_EQ, "LeaseSettingsSection", "DeploymentLeaseInSeconds",
Integer.toString(twoHours), modified.getDeploymentLeaseInSeconds().toString()));
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "LeaseSettingsSection"));
}