private void configureClient(
        FinalizeDeploymentMigrationWorkflowService.TaskState.TaskStage stage) throws Throwable {
      FinalizeDeploymentMigrationWorkflowService.State state =
          new FinalizeDeploymentMigrationWorkflowService.State();
      state.taskState = new FinalizeDeploymentMigrationWorkflowService.TaskState();
      state.taskState.stage = stage;
      state.destinationDeploymentId = DeploymentServiceFactory.SELF_LINK + "/" + UUID.randomUUID();
      if (stage == TaskState.TaskStage.FAILED) {
        state.taskState.failure = new ServiceErrorResponse();
        state.taskState.failure.message = "";
      }

      when(deployerClient.getFinalizeMigrateDeploymentStatus(any(String.class))).thenReturn(state);
    }
  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);
  }