Search in sources :

Example 1 with TaskDescriptor

use of com.enonic.xp.task.TaskDescriptor in project xp by enonic.

the class SubmitTaskHandlerTest method initialize.

@Override
public void initialize() throws Exception {
    super.initialize();
    taskService = Mockito.mock(TaskService.class);
    addService(TaskService.class, taskService);
    final TaskDescriptorService taskDescriptorService = Mockito.mock(TaskDescriptorService.class);
    addService(TaskDescriptorService.class, taskDescriptorService);
    final MixinService mixinService = Mockito.mock(MixinService.class);
    addService(MixinService.class, mixinService);
    final Form cfg1 = Form.create().addFormItem(Input.create().name("count").label("Count").inputType(InputTypeName.LONG).required(true).build()).build();
    final Form cfg2 = Form.create().addFormItem(Input.create().name("values").label("Values").inputType(InputTypeName.TEXT_LINE).required(true).multiple(true).build()).build();
    final TaskDescriptor desc1 = TaskDescriptor.create().key(DescriptorKey.from("myapplication:job42")).config(cfg1).build();
    final TaskDescriptor desc2 = TaskDescriptor.create().key(DescriptorKey.from("myapplication:my-task")).config(cfg2).build();
    final TaskDescriptor desc3 = TaskDescriptor.create().key(DescriptorKey.from("other-app:some-task")).build();
    Mockito.when(taskDescriptorService.getTasks()).thenReturn(Descriptors.from(desc1, desc2, desc3));
    Mockito.when(mixinService.inlineFormItems(any(Form.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
    addService(PropertyTreeMarshallerService.class, PropertyTreeMarshallerServiceFactory.newInstance(mixinService));
}
Also used : TaskDescriptorService(com.enonic.xp.task.TaskDescriptorService) TaskDescriptor(com.enonic.xp.task.TaskDescriptor) Form(com.enonic.xp.form.Form) TaskService(com.enonic.xp.task.TaskService) MixinService(com.enonic.xp.schema.mixin.MixinService)

Example 2 with TaskDescriptor

use of com.enonic.xp.task.TaskDescriptor in project xp by enonic.

the class TaskDescriptorLoaderTest method testCreateDefault.

@Test
public void testCreateDefault() {
    final DescriptorKey key = DescriptorKey.from("myapp1:task1");
    final TaskDescriptor descriptor = this.loader.createDefault(key);
    assertEquals(key, descriptor.getKey());
    assertEquals("task1", descriptor.getName());
}
Also used : TaskDescriptor(com.enonic.xp.task.TaskDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey) Test(org.junit.jupiter.api.Test)

Example 3 with TaskDescriptor

use of com.enonic.xp.task.TaskDescriptor in project xp by enonic.

the class TaskDescriptorServiceImplTest method getTasksByApp.

@Test
void getTasksByApp() {
    final TaskDescriptor desc1 = TaskDescriptor.create().key(DescriptorKey.from("app:a")).build();
    final TaskDescriptor desc2 = TaskDescriptor.create().key(DescriptorKey.from("app:b")).build();
    final Descriptors<TaskDescriptor> real = Descriptors.from(desc1, desc2);
    when(this.descriptorService.get(TaskDescriptor.class, ApplicationKeys.from("app"))).thenReturn(real);
    final Descriptors<TaskDescriptor> result = this.service.getTasks(ApplicationKey.from("app"));
    assertNotNull(result);
    assertEquals(2, result.getSize());
}
Also used : TaskDescriptor(com.enonic.xp.task.TaskDescriptor) Test(org.junit.jupiter.api.Test)

Example 4 with TaskDescriptor

use of com.enonic.xp.task.TaskDescriptor 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);
}
Also used : TaskDescriptor(com.enonic.xp.task.TaskDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey) Test(org.junit.jupiter.api.Test)

Example 5 with TaskDescriptor

use of com.enonic.xp.task.TaskDescriptor in project xp by enonic.

the class XmlTaskDescriptorParserTest method assertResult.

private void assertResult() throws Exception {
    final TaskDescriptor result = this.builder.build();
    assertEquals("myapplication:mytask", result.getKey().toString());
    assertEquals("mytask", result.getName());
    assertEquals("My task", result.getDescription());
    final Form config = result.getConfig();
    assertNotNull(config);
    final Input input = config.getInput("param1");
    assertNotNull(input);
}
Also used : TaskDescriptor(com.enonic.xp.task.TaskDescriptor) Input(com.enonic.xp.form.Input) Form(com.enonic.xp.form.Form)

Aggregations

TaskDescriptor (com.enonic.xp.task.TaskDescriptor)15 Test (org.junit.jupiter.api.Test)11 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 PropertyTree (com.enonic.xp.data.PropertyTree)6 Form (com.enonic.xp.form.Form)2 ProgressReporter (com.enonic.xp.task.ProgressReporter)2 TaskDescriptorService (com.enonic.xp.task.TaskDescriptorService)2 TaskId (com.enonic.xp.task.TaskId)2 ApplicationKey (com.enonic.xp.app.ApplicationKey)1 OsgiSupport (com.enonic.xp.core.internal.osgi.OsgiSupport)1 FormItem (com.enonic.xp.form.FormItem)1 Input (com.enonic.xp.form.Input)1 PropertyTreeMarshallerService (com.enonic.xp.form.PropertyTreeMarshallerService)1 NamedTask (com.enonic.xp.impl.task.script.NamedTask)1 NamedTaskFactory (com.enonic.xp.impl.task.script.NamedTaskFactory)1 Resource (com.enonic.xp.resource.Resource)1 ResourceKey (com.enonic.xp.resource.ResourceKey)1 MixinService (com.enonic.xp.schema.mixin.MixinService)1 RunnableTask (com.enonic.xp.task.RunnableTask)1 TaskService (com.enonic.xp.task.TaskService)1