use of com.enonic.xp.impl.task.script.NamedTask in project xp by enonic.
the class TaskServiceImpl method submitTask.
@Override
public TaskId submitTask(final DescriptorKey key, final PropertyTree config) {
final NamedTask namedTask = namedTaskFactory.createLegacy(key, config);
final DescribedTaskImpl task = new DescribedTaskImpl(namedTask, buildContext());
return submitLocal(task);
}
use of com.enonic.xp.impl.task.script.NamedTask 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.script.NamedTask in project xp by enonic.
the class DistributableTaskTest method run.
@Test
void run() {
final NamedTask namedTask = mock(NamedTask.class);
final DescriptorKey descriptorKey = DescriptorKey.from("app:a");
final TaskDescriptor descriptor = TaskDescriptor.create().key(descriptorKey).description("task description").build();
final PropertyTree config = new PropertyTree();
when(namedTaskFactory.create(descriptor, config)).thenReturn(namedTask);
when(taskDescriptorService.getTask(descriptorKey)).thenReturn(descriptor);
when(propertyTreeMarshallerService.marshal(eq(config.toMap()), eq(descriptor.getConfig()), Mockito.anyBoolean())).thenReturn(config);
final DistributableTask describedTask = new DistributableTask(descriptorKey, config, TEST_TASK_CONTEXT);
describedTask.run(mock(ProgressReporter.class));
verify(namedTask).run(any(TaskId.class), any(ProgressReporter.class));
}
Aggregations