Search in sources :

Example 6 with DescribedTask

use of com.enonic.xp.impl.task.distributed.DescribedTask in project xp by enonic.

the class TaskServiceImplTest method submitTask_DescriptorKey_offload_to_clustered_wait_success.

@Test
void submitTask_DescriptorKey_offload_to_clustered_wait_success() {
    final DescriptorKey descriptorKey = DescriptorKey.from("module:my-admin-tool");
    final TaskManager clusteredTaskManager = mock(TaskManager.class);
    when(taskConfig.distributable_acceptInbound()).thenReturn(false);
    taskService.activate(taskConfig);
    CompletableFuture.runAsync(() -> taskService.setClusteredTaskManager(clusteredTaskManager), CompletableFuture.delayedExecutor(1, TimeUnit.SECONDS));
    final TaskId taskId = taskService.submitTask(SubmitTaskParams.create().descriptorKey(descriptorKey).build());
    verify(clusteredTaskManager).submitTask(describedTaskCaptor.capture());
    describedTaskCaptor.getValue();
    final DescribedTask argument = describedTaskCaptor.getValue();
    assertEquals(taskId, argument.getTaskId());
}
Also used : TaskManager(com.enonic.xp.impl.task.distributed.TaskManager) TaskId(com.enonic.xp.task.TaskId) DescriptorKey(com.enonic.xp.page.DescriptorKey) DescribedTask(com.enonic.xp.impl.task.distributed.DescribedTask) Test(org.junit.jupiter.api.Test)

Aggregations

DescribedTask (com.enonic.xp.impl.task.distributed.DescribedTask)6 Test (org.junit.jupiter.api.Test)6 TaskId (com.enonic.xp.task.TaskId)5 DescriptorKey (com.enonic.xp.page.DescriptorKey)4 TaskManager (com.enonic.xp.impl.task.distributed.TaskManager)2 PropertyTree (com.enonic.xp.data.PropertyTree)1 OffloadedTaskCallable (com.enonic.xp.impl.task.distributed.OffloadedTaskCallable)1 NamedTask (com.enonic.xp.impl.task.script.NamedTask)1 RunnableTask (com.enonic.xp.task.RunnableTask)1 Member (com.hazelcast.core.Member)1 MemberSelector (com.hazelcast.core.MemberSelector)1 TimeUnit (java.util.concurrent.TimeUnit)1