@SuppressWarnings("unchecked")
@Test
public void testTaskToDomain() {

    //Given
    WorkflowDef workflowDef = new WorkflowDef();
    Workflow workflowInstance = new Workflow();
    workflowInstance.setWorkflowDefinition(workflowDef);
    WorkflowTask taskToSchedule = new WorkflowTask();
    Map<String, String> taskToDomain = new HashMap<String, String>() {{put("*", "unittest"); }};
    SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
    subWorkflowParams.setName("Foo");
    subWorkflowParams.setVersion(2);
    subWorkflowParams.setTaskToDomain(taskToDomain);
    taskToSchedule.setSubWorkflowParam(subWorkflowParams);
    Map<String, Object> taskInput = new HashMap<>();
    Map<String, Object> subWorkflowParamMap = new HashMap<>();
    subWorkflowParamMap.put("name", "FooWorkFlow");
    subWorkflowParamMap.put("version", 2);
    when(parametersUtils.getTaskInputV2(anyMap(), any(Workflow.class), any(), any()))
            .thenReturn(subWorkflowParamMap);
    //When
    TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder()
            .withWorkflowDefinition(workflowDef)
            .withWorkflowInstance(workflowInstance)
            .withTaskToSchedule(taskToSchedule)
            .withTaskInput(taskInput)
            .withRetryCount(0)
            .withTaskId(IDGenerator.generate())
            .withDeciderService(deciderService)
            .build();
    List<Task> mappedTasks = subWorkflowTaskMapper.getMappedTasks(taskMapperContext);
    //Then
    assertTrue(!mappedTasks.isEmpty());
    assertEquals(1, mappedTasks.size());
    Task subWorkFlowTask = mappedTasks.get(0);
    assertEquals(Task.Status.SCHEDULED, subWorkFlowTask.getStatus());
    assertEquals(SubWorkflow.NAME, subWorkFlowTask.getTaskType());
}