@Override
  protected void execute() throws RpcException, InterruptedException {
    List<DeploymentEntity> deploymentEntityList =
        step.getTransientResourceEntities(Deployment.KIND);
    Preconditions.checkArgument(deploymentEntityList.size() == 1);

    deploymentEntity = deploymentEntityList.get(0);
    // call deployer
    logger.info("Calling delete deployment  {}", deploymentEntity);
    RemoveDeploymentWorkflowService.State serviceDocument =
        taskCommand.getDeployerXenonClient().removeDeployment(deploymentEntity.getId());
    // pass remoteTaskId to XenonTaskStatusStepCmd
    for (StepEntity nextStep : taskCommand.getTask().getSteps()) {
      nextStep.createOrUpdateTransientResource(
          XenonTaskStatusStepCmd.REMOTE_TASK_LINK_RESOURCE_KEY, serviceDocument.documentSelfLink);
    }
    this.deploymentEntity.setOperationId(serviceDocument.documentSelfLink);
  }
  public void setUpCommon() {
    deployerClient = mock(DeployerClient.class);
    taskCommand = mock(TaskCommand.class);
    when(taskCommand.getDeployerXenonClient()).thenReturn(deployerClient);

    stepBackend = mock(StepBackend.class);
    deploymentBackend = mock(DeploymentXenonBackend.class);
    taskBackend = mock(TaskBackend.class);

    when(deploymentBackend.getDeployerClient()).thenReturn(deployerClient);

    entity = new DeploymentEntity();
    currentStep = new StepEntity();
    currentStep.setId("id");
    currentStep.addResource(entity);

    taskEntity = new TaskEntity();
    taskEntity.setSteps(ImmutableList.of(currentStep));
    when(taskCommand.getTask()).thenReturn(taskEntity);

    poller =
        new DeploymentFinalizeMigrationStatusStepCmd.DeploymentFinalizeMigrationStatusStepPoller(
            taskCommand, taskBackend, deploymentBackend);
    command =
        spy(
            new DeploymentFinalizeMigrationStatusStepCmd(
                taskCommand, stepBackend, currentStep, poller));

    serviceDocument = new FinalizeDeploymentMigrationWorkflowService.State();
    serviceDocument.taskState = new FinalizeDeploymentMigrationWorkflowService.TaskState();
    serviceDocument.taskState.stage =
        FinalizeDeploymentMigrationWorkflowService.TaskState.TaskStage.STARTED;
    remoteTaskLink =
        "http://deployer"
            + FinalizeDeploymentMigrationWorkflowFactoryService.SELF_LINK
            + "/00000000-0000-0000-0000-000000000001";
    serviceDocument.documentSelfLink = remoteTaskLink;
    entity.setOperationId(remoteTaskLink);
  }
 private VmDiskOpStepCmd getVmDiskOpStepCmd(Operation operation) {
   step = new StepEntity();
   step.setId(stepId);
   step.setTask(task);
   step.setSequence(0);
   step.setState(StepEntity.State.QUEUED);
   step.addResource(vm);
   step.addResource(disk1);
   step.addResource(disk2);
   step.setOperation(operation);
   VmDiskOpStepCmd cmd =
       new VmDiskOpStepCmd(taskCommand, stepBackend, step, diskBackend, attachedDiskBackend);
   return spy(cmd);
 }