vAppTemplateApi.disableDownload(vAppTemplateUrn);
final Task task = vAppTemplateApi.enableDownload(vAppTemplateUrn);
assertTaskDoneEventually(task);
// Ask the VAppTemplate for its tasks, and the status of the matching task if it exists
VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn);
List<Task> tasks = vAppTemplate.getTasks();
for (Task contender : tasks) {
if (task.getId().equals(contender.getId())) {
Task.Status status = contender.getStatus();
if (EnumSet.of(Task.Status.QUEUED, Task.Status.PRE_RUNNING, Task.Status.RUNNING).contains(status)) {
fail("Task " + contender + " reported complete, but is included in VAppTemplate in status " + status);