@Test
public void testTaskPollDomain() {

    TaskClient taskClient = Mockito.mock(TaskClient.class);
    String testDomain = "foo";
    Map<String, String> taskToDomain = new HashMap<>();
    taskToDomain.put(TEST_TASK_DEF_NAME, testDomain);
    TaskPollExecutor taskPollExecutor = new TaskPollExecutor(null, taskClient, 1, 1, taskToDomain, "test-worker-");
    String workerName = "test-worker";
    Worker worker = mock(Worker.class);
    when(worker.getTaskDefName()).thenReturn(TEST_TASK_DEF_NAME);
    when(worker.getIdentity()).thenReturn(workerName);
    CountDownLatch latch = new CountDownLatch(1);
    doAnswer(invocation -> {
            latch.countDown();
            return null;
        }
    ).when(taskClient).pollTask(TEST_TASK_DEF_NAME, workerName, testDomain);
    Executors.newSingleThreadScheduledExecutor()
        .scheduleAtFixedRate(() -> taskPollExecutor.pollAndExecute(worker), 0, 1, TimeUnit.SECONDS);
    Uninterruptibles.awaitUninterruptibly(latch);
    verify(taskClient).pollTask(TEST_TASK_DEF_NAME, workerName, testDomain);
}