use of com.enonic.xp.impl.task.distributed.DescribedTask in project xp by enonic.
the class TaskServiceImplTest method submitTask_DescriptorKey_offload_to_clustered.
@Test
void submitTask_DescriptorKey_offload_to_clustered() {
final DescriptorKey descriptorKey = DescriptorKey.from("module:my-admin-tool");
final TaskManager clusteredTaskManager = mock(TaskManager.class);
taskService.setClusteredTaskManager(clusteredTaskManager);
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());
}
use of com.enonic.xp.impl.task.distributed.DescribedTask in project xp by enonic.
the class TaskServiceImplTest method submitTask_DescriptorKey.
@Test
void submitTask_DescriptorKey() {
final DescriptorKey descriptorKey = DescriptorKey.from("module:my-admin-tool");
final PropertyTree config = new PropertyTree();
final NamedTask namedTask = mock(NamedTask.class);
when(namedTaskFactory.createLegacy(descriptorKey, config)).thenReturn(namedTask);
when(namedTask.getTaskDescriptor()).thenReturn(TaskDescriptor.create().key(descriptorKey).description("task description").build());
final TaskId taskId = taskService.submitTask(descriptorKey, config);
verify(taskManager).submitTask(describedTaskCaptor.capture());
describedTaskCaptor.getValue();
final DescribedTask argument = describedTaskCaptor.getValue();
assertEquals(taskId, argument.getTaskId());
}
use of com.enonic.xp.impl.task.distributed.DescribedTask in project xp by enonic.
the class TaskServiceImplTest method submitTask_runnableTask.
@Test
void submitTask_runnableTask() {
when(bundle.getSymbolicName()).thenReturn("some.app");
final TaskId taskId = taskService.submitTask(mock(RunnableTask.class), "someDescription");
verify(taskManager).submitTask(describedTaskCaptor.capture());
final DescribedTask argument = describedTaskCaptor.getValue();
assertEquals("someDescription", argument.getDescription());
assertEquals(taskId, argument.getTaskId());
}
use of com.enonic.xp.impl.task.distributed.DescribedTask in project xp by enonic.
the class TaskServiceImplTest method submitTask_DescriptorKey_offload_to_local.
@Test
void submitTask_DescriptorKey_offload_to_local() {
final DescriptorKey descriptorKey = DescriptorKey.from("module:my-admin-tool");
final TaskId taskId = taskService.submitTask(SubmitTaskParams.create().descriptorKey(descriptorKey).build());
verify(taskManager).submitTask(describedTaskCaptor.capture());
describedTaskCaptor.getValue();
final DescribedTask argument = describedTaskCaptor.getValue();
assertEquals(taskId, argument.getTaskId());
}
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());
}
Aggregations