async function queueGranules(event, testMocks = {}) {
  const granules = event.input.granules || [];
  const updateGranule = testMocks.updateGranuleMock || granulesApi.updateGranule;
  const enqueueGranuleIngestMessageFn
    = testMocks.enqueueGranuleIngestMessageMock || enqueueGranuleIngestMessage;

  const collectionConfigStore = new CollectionConfigStore(
    event.config.internalBucket,
    event.config.stackName
  );

  const arn = buildExecutionArn(
    get(event, 'cumulus_config.state_machine'),
    get(event, 'cumulus_config.execution_name')
  );

  const groupedAndBatchedGranules = groupAndBatchGranules(
    granules,
    event.config.preferredQueueBatchSize
  );

  const pMapConcurrency = get(event, 'config.concurrency', 3);
  const executionArns = await pMap(
    groupedAndBatchedGranules,
    async (granuleBatchIn) => {
      const collectionConfig = await collectionConfigStore.get(
        granuleBatchIn[0].dataType,
        granuleBatchIn[0].version
      );

      const createdAt = Date.now();
      const granuleBatch = updateGranuleBatchCreatedAt(granuleBatchIn, createdAt);
      await pMap(
        granuleBatch,
        (queuedGranule) => updateGranule({
          prefix: event.config.stackName,
          body: {
            collectionId: constructCollectionId(
              queuedGranule.dataType,
              queuedGranule.version
            ),
            granuleId: queuedGranule.granuleId,
            status: 'queued',
            createdAt: queuedGranule.createdAt,
          },
        }),
        { concurrency: pMapConcurrency }
      );
      return await enqueueGranuleIngestMessageFn({
        granules: granuleBatch,
        queueUrl: event.config.queueUrl,
        granuleIngestWorkflow: event.config.granuleIngestWorkflow,
        provider: granuleBatch[0].provider
          ? await fetchGranuleProvider(event.config.stackName, granuleBatch[0].provider)
          : event.config.provider,
        collection: collectionConfig,
        pdr: event.input.pdr,
        parentExecutionArn: arn,
        stack: event.config.stackName,
        systemBucket: event.config.internalBucket,
        executionNamePrefix: event.config.executionNamePrefix,
        additionalCustomMeta: event.config.childWorkflowMeta,
      });
    },
    { concurrency: pMapConcurrency }
  );

  const result = { running: executionArns };
  if (event.input.pdr) result.pdr = event.input.pdr;
  return result;
}
/**
 * See schemas/input.json and schemas/config.json for detailed event description
 *
 * @param {Object} event - Lambda event object
 * @param {Object} testMocks - Object containing mock functions for testing
 * @returns {Promise} - see schemas/output.json for detailed output schema
 *   that is passed to the next task in the workflow
 **/
See schemas/input.json and schemas/config.json for detailed event description
@param {Object} event - Lambda event object
@param {Object} testMocks - Object containing mock functions for testing
@returns {Promise} - see schemas/output.json for detailed output schema
that is passed to the next task in the workflow
See schemas / input . json and schemas / config . json for detailed event description @param { Object } event - Lambda event object @param { Object } testMocks - Object containing mock functions for testing @returns { Promise } - see schemas / output . json for detailed output schema that is passed to the next task in the workflow
async function queueGranules(event, testMocks = {}) {
  const granules = event.input.granules || [];
  const updateGranule = testMocks.updateGranuleMock || granulesApi.updateGranule;
  const enqueueGranuleIngestMessageFn
    = testMocks.enqueueGranuleIngestMessageMock || enqueueGranuleIngestMessage;
  const collectionConfigStore = new CollectionConfigStore(
    event.config.internalBucket,
    event.config.stackName
  );
  const arn = buildExecutionArn(
    get(event, 'cumulus_config.state_machine'),
    get(event, 'cumulus_config.execution_name')
  );
  const groupedAndBatchedGranules = groupAndBatchGranules(
    granules,
    event.config.preferredQueueBatchSize
  );
  const pMapConcurrency = get(event, 'config.concurrency', 3);
  const executionArns = await pMap(
    groupedAndBatchedGranules,
    async (granuleBatchIn) => {
      const collectionConfig = await collectionConfigStore.get(
        granuleBatchIn[0].dataType,
        granuleBatchIn[0].version
      );
      const createdAt = Date.now();
      const granuleBatch = updateGranuleBatchCreatedAt(granuleBatchIn, createdAt);
      await pMap(
        granuleBatch,
        (queuedGranule) => updateGranule({
          prefix: event.config.stackName,
          body: {
            collectionId: constructCollectionId(
              queuedGranule.dataType,
              queuedGranule.version
            ),
            granuleId: queuedGranule.granuleId,
            status: 'queued',
            createdAt: queuedGranule.createdAt,
          },
        }),
        { concurrency: pMapConcurrency }
      );
      return await enqueueGranuleIngestMessageFn({
        granules: granuleBatch,
        queueUrl: event.config.queueUrl,
        granuleIngestWorkflow: event.config.granuleIngestWorkflow,
        provider: granuleBatch[0].provider
          ? await fetchGranuleProvider(event.config.stackName, granuleBatch[0].provider)
          : event.config.provider,
        collection: collectionConfig,
        pdr: event.input.pdr,
        parentExecutionArn: arn,
        stack: event.config.stackName,
        systemBucket: event.config.internalBucket,
        executionNamePrefix: event.config.executionNamePrefix,
        additionalCustomMeta: event.config.childWorkflowMeta,
      });
    },
    { concurrency: pMapConcurrency }
  );
  const result = { running: executionArns };
  if (event.input.pdr) result.pdr = event.input.pdr;
  return result;
}
async function queueGranules ( event , testMocks = { } ) { const granules = event . input . granules || [ ] ; const updateGranule = testMocks . updateGranuleMock || granulesApi . updateGranule ; const enqueueGranuleIngestMessageFn = testMocks . enqueueGranuleIngestMessageMock || enqueueGranuleIngestMessage ; const collectionConfigStore = new CollectionConfigStore ( event . config . internalBucket , event . config . stackName ) ; const arn = buildExecutionArn ( get ( event , 'cumulus_config.state_machine' ) , get ( event , 'cumulus_config.execution_name' ) ) ; const groupedAndBatchedGranules = groupAndBatchGranules ( granules , event . config . preferredQueueBatchSize ) ; const pMapConcurrency = get ( event , 'config.concurrency' , 3 ) ; const executionArns = await pMap ( groupedAndBatchedGranules , async ( granuleBatchIn ) => { const collectionConfig = await collectionConfigStore . get ( granuleBatchIn [ 0 ] . dataType , granuleBatchIn [ 0 ] . version ) ; const createdAt = Date . now ( ) ; const granuleBatch = updateGranuleBatchCreatedAt ( granuleBatchIn , createdAt ) ; await pMap ( granuleBatch , ( queuedGranule ) => updateGranule ( { prefix : event . config . stackName , body : { collectionId : constructCollectionId ( queuedGranule . dataType , queuedGranule . version ) , granuleId : queuedGranule . granuleId , status : 'queued' , createdAt : queuedGranule . createdAt , } , } ) , { concurrency : pMapConcurrency } ) ; return await enqueueGranuleIngestMessageFn ( { granules : granuleBatch , queueUrl : event . config . queueUrl , granuleIngestWorkflow : event . config . granuleIngestWorkflow , provider : granuleBatch [ 0 ] . provider ? await fetchGranuleProvider ( event . config . stackName , granuleBatch [ 0 ] . provider ) : event . config . provider , collection : collectionConfig , pdr : event . input . pdr , parentExecutionArn : arn , stack : event . config . stackName , systemBucket : event . config . internalBucket , executionNamePrefix : event . config . executionNamePrefix , additionalCustomMeta : event . config . childWorkflowMeta , } ) ; } , { concurrency : pMapConcurrency } ) ; const result = { running : executionArns } ; if ( event . input . pdr ) result . pdr = event . input . pdr ; return result ; }
See schemas/input.json and schemas/config.json for detailed event description
 @param {Object} event - Lambda event object
 @param {Object} testMocks - Object containing mock functions for testing
 @returns {Promise} - see schemas/output.json for detailed output schema
   that is passed to the next task in the workflow
See schemas / input . json and schemas / config . json for detailed event description @param { Object } event - Lambda event object @param { Object } testMocks - Object containing mock functions for testing @returns { Promise } - see schemas / output . json for detailed output schema that is passed to the next task in the workflow