private static void startWorkflow()

in src/main/java/com/uber/cadence/internal/testservice/StateMachines.java [519:568]


  private static void startWorkflow(
      RequestContext ctx, WorkflowData data, StartWorkflowExecutionRequest request, long notUsed)
      throws BadRequestError {
    WorkflowExecutionStartedEventAttributes a = new WorkflowExecutionStartedEventAttributes();
    if (request.isSetIdentity()) {
      a.setIdentity(request.getIdentity());
    }
    if (!request.isSetTaskStartToCloseTimeoutSeconds()) {
      throw new BadRequestError("missing taskStartToCloseTimeoutSeconds");
    }
    a.setTaskStartToCloseTimeoutSeconds(request.getTaskStartToCloseTimeoutSeconds());
    if (!request.isSetWorkflowType()) {
      throw new BadRequestError("missing workflowType");
    }
    a.setWorkflowType(request.getWorkflowType());
    if (!request.isSetTaskList()) {
      throw new BadRequestError("missing taskList");
    }
    a.setTaskList(request.getTaskList());
    if (!request.isSetExecutionStartToCloseTimeoutSeconds()) {
      throw new BadRequestError("missing executionStartToCloseTimeoutSeconds");
    }
    a.setExecutionStartToCloseTimeoutSeconds(request.getExecutionStartToCloseTimeoutSeconds());
    if (request.isSetInput()) {
      a.setInput(request.getInput());
    }
    if (data.retryState.isPresent()) {
      a.setAttempt(data.retryState.get().getAttempt());
    }
    a.setOriginalExecutionRunId(data.originalExecutionRunId);
    if (data.continuedExecutionRunId.isPresent()) {
      a.setContinuedExecutionRunId(data.continuedExecutionRunId.get());
    }
    a.setCronSchedule(data.cronSchedule);
    a.setLastCompletionResult(data.lastCompletionResult);
    a.setMemo(request.getMemo());
    a.setSearchAttributes((request.getSearchAttributes()));
    a.setHeader(request.getHeader());
    Optional<TestWorkflowMutableState> parent = ctx.getWorkflowMutableState().getParent();
    if (parent.isPresent()) {
      ExecutionId parentExecutionId = parent.get().getExecutionId();
      a.setParentWorkflowDomain(parentExecutionId.getDomain());
      a.setParentWorkflowExecution(parentExecutionId.getExecution());
    }
    HistoryEvent event =
        new HistoryEvent()
            .setEventType(EventType.WorkflowExecutionStarted)
            .setWorkflowExecutionStartedEventAttributes(a);
    ctx.addEvent(event);
  }