public List<RunResponse> startBatch(
      String workflowId, String version, List<RunRequest> requests) {
    if (ObjectHelper.isCollectionEmptyOrNull(requests)) {
      return Collections.emptyList();
    }
    Checks.checkTrue(
        requests.size() <= Constants.START_BATCH_LIMIT,
        "The size of Requests is greater than the batch limit");
    WorkflowDefinition definition = workflowDao.getWorkflowDefinition(workflowId, version);

    // Fail the whole batch if any request is invalid
    requests.forEach(request -> validateRequest(version, definition, request));

    RunProperties runProperties = RunProperties.from(definition.getPropertiesSnapshot());

    List<WorkflowInstance> instances =
        createWorkflowInstances(
            definition.getWorkflow(),
            definition.getInternalId(),
            definition.getMetadata().getWorkflowVersionId(),
            runProperties,
            requests);
    RunStrategy runStrategy = definition.getRunStrategyOrDefault();
    int[] results = runStrategyDao.startBatchWithRunStrategy(workflowId, runStrategy, instances);
    List<RunResponse> responses = new ArrayList<>();
    int idx = 0;
    for (WorkflowInstance instance : instances) {
      responses.add(RunResponse.from(instance, results[idx]));
      idx++;
    }
    LOG.debug(
        "Created {} of workflow instances for workflow id {} to start",
        requests.size(),
        workflowId);
    return responses;
  }
@Test
  public void testStartBatch() {
    when(runStrategyDao.startBatchWithRunStrategy(any(), any(), any()))
        .thenReturn(new int[] {1, 0});
    RunRequest request =
        RunRequest.builder()
            .initiator(new ManualInitiator())
            .requestId(UUID.fromString("41f0281e-41a2-468d-b830-56141b2f768b"))
            .currentPolicy(RunPolicy.START_FRESH_NEW_RUN)
            .build();
    List<RunResponse> responses =
        actionHandler.startBatch("sample-minimal-wf", "active", Arrays.asList(request, request));
    verify(workflowDao, times(1)).getWorkflowDefinition("sample-minimal-wf", "active");
    verify(runStrategyDao, times(1)).startBatchWithRunStrategy(any(), any(), any());
    assertEquals(2, responses.size());
    assertEquals(1L, responses.get(0).getWorkflowVersionId());
    assertEquals("41f0281e-41a2-468d-b830-56141b2f768b", responses.get(0).getWorkflowUuid());
    assertEquals(RunResponse.Status.WORKFLOW_RUN_CREATED, responses.get(0).getStatus());
    assertEquals(1L, responses.get(1).getWorkflowVersionId());
    assertEquals("41f0281e-41a2-468d-b830-56141b2f768b", responses.get(1).getWorkflowUuid());
    assertEquals(RunResponse.Status.DUPLICATED, responses.get(1).getStatus());
  }