@Test
public void testTaskToDomainOverrides() {

    Workflow workflow = generateSampleWorkflow();
    List<Task> tasks = generateSampleTasks(4);
    Map<String, String> taskToDomain = new HashMap<>();
    taskToDomain.put("*", "mydomain");
    taskToDomain.put("task2", "someInactiveDomain, NO_DOMAIN");
    taskToDomain.put("task3", "someActiveDomain, NO_DOMAIN");
    taskToDomain.put("task4", "someInactiveDomain, someInactiveDomain2");
    workflow.setTaskToDomain(taskToDomain);
    PollData pollData1 = new PollData("queue1", "mydomain", "worker1", System.currentTimeMillis() - 99 * 100);
    PollData pollData2 = new PollData("queue2", "someActiveDomain", "worker2", System.currentTimeMillis() - 99 * 100);
    when(executionDAOFacade.getTaskPollDataByDomain(anyString(), eq("mydomain"))).thenReturn(pollData1);
    when(executionDAOFacade.getTaskPollDataByDomain(anyString(), eq("someInactiveDomain"))).thenReturn(null);
    when(executionDAOFacade.getTaskPollDataByDomain(anyString(), eq("someActiveDomain"))).thenReturn(pollData2);
    when(executionDAOFacade.getTaskPollDataByDomain(anyString(), eq("someInactiveDomain"))).thenReturn(null);
    workflowExecutor.setTaskDomains(tasks, workflow);
    assertEquals("mydomain", tasks.get(0).getDomain());
    assertNull(tasks.get(1).getDomain());
    assertEquals("someActiveDomain", tasks.get(2).getDomain());
    assertEquals("someInactiveDomain2", tasks.get(3).getDomain());
}