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));
}
Aggregations