/**
   * This method creates a new State object which is sufficient to create a new
   * FinishDeploymentWorkflowService instance.
   */
  private InitializeDeploymentMigrationWorkflowService.State buildValidStartState(
      @Nullable InitializeDeploymentMigrationWorkflowService.TaskState.TaskStage startStage,
      @Nullable InitializeDeploymentMigrationWorkflowService.TaskState.SubStage startSubStage)
      throws Throwable {
    InitializeDeploymentMigrationWorkflowService.State startState =
        new InitializeDeploymentMigrationWorkflowService.State();
    startState.controlFlags = ControlFlags.CONTROL_FLAG_OPERATION_PROCESSING_DISABLED;
    startState.sourceLoadBalancerAddress = "lbLink1";
    startState.destinationDeploymentId = "deployment1";
    startState.taskPollDelay = 1;

    if (null != startStage) {
      startState.taskState = new InitializeDeploymentMigrationWorkflowService.TaskState();
      startState.taskState.stage = startStage;
      startState.taskState.subStage = startSubStage;

      if (TaskState.TaskStage.STARTED == startStage) {
        switch (startSubStage) {
          case CONTIONUS_MIGRATE_DATA:
          case UPLOAD_VIBS:
            startState.sourceZookeeperQuorum = "quorum";
            // fall through
          case PAUSE_DESTINATION_SYSTEM:
            startState.sourceDeploymentId = "deployment1";
            break;
        }
      }
    }

    return startState;
  }
    @Test(dataProvider = "TerminalStartStages")
    public void testTerminalStartState(
        InitializeDeploymentMigrationWorkflowService.TaskState.TaskStage startStage,
        InitializeDeploymentMigrationWorkflowService.TaskState.SubStage startSubStage)
        throws Throwable {
      InitializeDeploymentMigrationWorkflowService.State startState =
          buildValidStartState(startStage, startSubStage);
      startState.controlFlags = null;
      startService(startState);

      InitializeDeploymentMigrationWorkflowService.State serviceState =
          testHost.getServiceState(InitializeDeploymentMigrationWorkflowService.State.class);

      assertThat(serviceState.taskState.stage, is(startStage));
      assertThat(serviceState.taskState.subStage, nullValue());
    }
    @BeforeClass
    public void setUpClass() throws Throwable {
      listeningExecutorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1));

      startState =
          buildValidStartState(
              InitializeDeploymentMigrationWorkflowService.TaskState.TaskStage.CREATED, null);
      startState.controlFlags = null;
      startState.taskPollDelay = 10;

      sourceCloudStore =
          com.vmware.photon.controller.cloudstore.dcp.helpers.TestEnvironment.create(1);
      destinationCloudStore =
          com.vmware.photon.controller.cloudstore.dcp.helpers.TestEnvironment.create(1);

      FileUtils.deleteDirectory(storageDirectory);
      vibDirectory.mkdirs();
      TestHelper.createSourceFile(null, vibDirectory);
    }