use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class NamedTaskFactoryImplTest method createExisting.
@Test
void createExisting() {
final DescriptorKey descriptorKey = DescriptorKey.from("myapplication:mytask");
final TaskDescriptor descriptor = TaskDescriptor.create().key(descriptorKey).build();
when(taskDescriptorService.getTask(descriptorKey)).thenReturn(descriptor);
final RunnableTask runnableTask = namedTaskScriptFactory.create(descriptor, new PropertyTree());
assertNotNull(runnableTask);
runnableTask.run(TaskId.from("123"), null);
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class DistributableTaskTest method fields.
@Test
void fields() {
final DescriptorKey descriptorKey = DescriptorKey.from("app:a");
final TaskDescriptor descriptor = TaskDescriptor.create().key(descriptorKey).description("task description").config(Form.create().build()).build();
final PropertyTree config = new PropertyTree();
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);
assertAll(() -> assertEquals("app:a", describedTask.getName()), () -> assertNotNull(describedTask.getTaskId()), () -> assertNotNull(describedTask.getTaskContext()), () -> assertEquals("task description", describedTask.getDescription()), () -> assertEquals(descriptorKey.getApplicationKey(), describedTask.getApplicationKey()));
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class TaskDescriptorServiceImplTest method getTask.
@Test
void getTask() {
final DescriptorKey key = DescriptorKey.from("app:a");
final TaskDescriptor desc = TaskDescriptor.create().key(key).build();
when(this.descriptorService.get(TaskDescriptor.class, key)).thenReturn(desc);
final TaskDescriptor result = this.service.getTask(key);
assertNotNull(result);
}
use of com.enonic.xp.page.DescriptorKey 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.page.DescriptorKey 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());
}
Aggregations