code: @VisibleForTesting
      String getDynamicTaskName(Map<String, Object> taskInput, String taskNameParam) throws TerminateWorkflowException {
          return Optional.ofNullable(taskInput.get(taskNameParam))
                  .map(String::valueOf)
                  .orElseThrow(() -> {
                      String reason = String.format("Cannot map a dynamic task based on the parameter and input. " +
                              "Parameter= %s, input= %s", taskNameParam, taskInput);
                      return new TerminateWorkflowException(reason);
                  });
      }
docs: Helper method that looks into the input params and returns the dynamic task name
  
  @param taskInput:     a map which contains different input parameters and
  also contains the mapping between the dynamic task name param and the actual name representing the dynamic task
  @param taskNameParam: the key that is used to look up the dynamic task name.
  @return The name of the dynamic task
  @throws TerminateWorkflowException : In case is there is no value dynamic task name in the input parameters.