@SuppressWarnings("unchecked")
    @VisibleForTesting
    Pair<List<WorkflowTask>, Map<String, Map<String, Object>>> getDynamicForkTasksAndInput(WorkflowTask taskToSchedule, Workflow workflowInstance,
                                                                                           String dynamicForkTaskParam) throws TerminateWorkflowException {

        Map<String, Object> input = parametersUtils.getTaskInput(taskToSchedule.getInputParameters(), workflowInstance, null, null);
        Object dynamicForkTasksJson = input.get(dynamicForkTaskParam);
        List<WorkflowTask> dynamicForkWorkflowTasks = objectMapper.convertValue(dynamicForkTasksJson, ListOfWorkflowTasks);
        for (WorkflowTask workflowTask : dynamicForkWorkflowTasks) {
            if (MetadataMapperService.shouldPopulateDefinition(workflowTask)) {
                workflowTask.setTaskDefinition(metadataDAO.getTaskDef(workflowTask.getName()));
            }
        }
        Object dynamicForkTasksInput = input.get(taskToSchedule.getDynamicForkTasksInputParamName());
        if (!(dynamicForkTasksInput instanceof Map)) {
            throw new TerminateWorkflowException("Input to the dynamically forked tasks is not a map -> expecting a map of K,V  but found " + dynamicForkTasksInput);
        }
        return new ImmutablePair<>(dynamicForkWorkflowTasks, (Map<String, Map<String, Object>>) dynamicForkTasksInput);
    }
@ SuppressWarnings ( "unchecked" ) @ VisibleForTesting Pair < List < WorkflowTask > , Map < String , Map < String , Object > > > getDynamicForkTasksAndInput ( WorkflowTask taskToSchedule , Workflow workflowInstance , String dynamicForkTaskParam ) throws TerminateWorkflowException { Map < String , Object > input = parametersUtils . getTaskInput ( taskToSchedule . getInputParameters ( ) , workflowInstance , null , null ) ; Object dynamicForkTasksJson = input . get ( dynamicForkTaskParam ) ; List < WorkflowTask > dynamicForkWorkflowTasks = objectMapper . convertValue ( dynamicForkTasksJson , ListOfWorkflowTasks ) ; for ( WorkflowTask workflowTask : dynamicForkWorkflowTasks ) { if ( MetadataMapperService . shouldPopulateDefinition ( workflowTask ) ) { workflowTask . setTaskDefinition ( metadataDAO . getTaskDef ( workflowTask . getName ( ) ) ) ; } } Object dynamicForkTasksInput = input . get ( taskToSchedule . getDynamicForkTasksInputParamName ( ) ) ; if ( ! ( dynamicForkTasksInput instanceof Map ) ) { throw new TerminateWorkflowException ( "Input to the dynamically forked tasks is not a map -> expecting a map of K,V  but found " + dynamicForkTasksInput ) ; } return new ImmutablePair < > ( dynamicForkWorkflowTasks , ( Map < String , Map < String , Object > > ) dynamicForkTasksInput ) ; }
This method is used to get the List of dynamic workflow tasks and their input based on the {@link WorkflowTask#getDynamicForkTasksParam()}

@param taskToSchedule:       The Task of type FORK_JOIN_DYNAMIC that needs to scheduled, which has the input parameters
@param workflowInstance:     The instance of the {@link Workflow} which represents the workflow being executed.
@param dynamicForkTaskParam: The key representing the dynamic fork join json payload which is available in {@link WorkflowTask#getInputParameters()}
@throws TerminateWorkflowException : In case of input parameters of the dynamic fork tasks not represented as {@link Map}
@return a {@link Pair} representing the list of dynamic fork tasks in {@link Pair#getLeft()} and the input for the dynamic fork tasks in {@link Pair#getRight()}