/** @see VmApi#remove(String) */ @Test(description = "DELETE /vApp/{id}") public void testRemoveVm() { // Create a temporary VApp to remove VApp remove = instantiateVApp(); DeployVAppParams params = DeployVAppParams.builder() .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)) .notForceCustomization() .powerOn() .build(); Task deployVApp = vAppApi.deploy(remove.getId(), params); assertTaskSucceedsLong(deployVApp); // Get the edited VApp and the Vm remove = vAppApi.get(remove.getId()); List<Vm> vms = remove.getChildren().getVms(); Vm temp = Iterables.get(vms, 0); // otherwise it's impossible to stop a running vApp with no vms if (vms.size() == 1) { UndeployVAppParams undeployParams = UndeployVAppParams.builder().build(); Task shutdownVapp = vAppApi.undeploy(remove.getId(), undeployParams); assertTaskSucceedsLong(shutdownVapp); } else { powerOffVm(temp.getId()); } // The method under test Task removeVm = vmApi.remove(temp.getId()); assertTrue(retryTaskSuccess.apply(removeVm), String.format(TASK_COMPLETE_TIMELY, "removeVm")); Vm removed = vmApi.get(temp.getId()); assertNull(removed, "The Vm " + temp.getName() + " should have been removed"); }