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