@Test
public void getMappedTasksException() {

    //Given
    WorkflowTask taskToSchedule = new WorkflowTask();
    taskToSchedule.setName("user_task");
    taskToSchedule.setType(TaskType.USER_DEFINED.name());
    String taskId = IDGenerator.generate();
    String retriedTaskId = IDGenerator.generate();
    Workflow workflow = new Workflow();
    WorkflowDef workflowDef = new WorkflowDef();
    workflow.setWorkflowDefinition(workflowDef);
    TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder()
            .withWorkflowDefinition(workflowDef)
            .withWorkflowInstance(workflow)
            .withTaskToSchedule(taskToSchedule)
            .withTaskInput(new HashMap<>())
            .withRetryCount(0)
            .withRetryTaskId(retriedTaskId)
            .withTaskId(taskId)
            .build();
    //then
    expectedException.expect(TerminateWorkflowException.class);
    expectedException.expectMessage(String.format("Invalid task specified. Cannot find task by name %s in the task definitions", taskToSchedule.getName()));
    //when
    userDefinedTaskMapper.getMappedTasks(taskMapperContext);
}