@VisibleForTesting
    TaskDef getDynamicTaskDefinition(WorkflowTask workflowTask)
            throws TerminateWorkflowException { // TODO this is a common pattern in code base can
        // be moved to DAO
        return Optional.ofNullable(workflowTask.getTaskDefinition())
                .orElseGet(
                        () ->
                                Optional.ofNullable(metadataDAO.getTaskDef(workflowTask.getName()))
                                        .orElseThrow(
                                                () -> {
                                                    String reason =
                                                            String.format(
                                                                    "Invalid task specified.  Cannot find task by name %s in the task definitions",
                                                                    workflowTask.getName());
                                                    return new TerminateWorkflowException(reason);
                                                }));
    }
This method gets the TaskDefinition for a specific {@link WorkflowTask}

@param workflowTask: An instance of {@link WorkflowTask} which has the name of the using
    which the {@link TaskDef} can be retrieved.
@return An instance of TaskDefinition
@throws TerminateWorkflowException : in case of no workflow definition available
core/src/main/java/com/netflix/conductor/core/execution/mapper/DynamicTaskMapper.java