Search in sources :

Example 1 with TaskDescriptorService

use of com.enonic.xp.task.TaskDescriptorService 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)

Aggregations

Form (com.enonic.xp.form.Form)1 MixinService (com.enonic.xp.schema.mixin.MixinService)1 TaskDescriptor (com.enonic.xp.task.TaskDescriptor)1 TaskDescriptorService (com.enonic.xp.task.TaskDescriptorService)1 TaskService (com.enonic.xp.task.TaskService)1