use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class EditableScheduledJobTest method testNotChanged.
@Test
public void testNotChanged() {
final PrincipalKey user = PrincipalKey.ofUser(IdProviderKey.createDefault(), "user");
final PrincipalKey creator = PrincipalKey.ofUser(IdProviderKey.createDefault(), "creator");
final PrincipalKey modifier = PrincipalKey.ofUser(IdProviderKey.createDefault(), "modifier");
final Instant createdTime = Instant.parse("2021-02-25T10:44:33.170079900Z");
final Instant modifiedTime = Instant.parse("2021-03-25T10:44:33.170079900Z");
final DescriptorKey descriptor = DescriptorKey.from(ApplicationKey.BASE, "descriptor");
final PropertyTree config = new PropertyTree();
config.addString("property", "value");
final String description = "description";
final ScheduledJob source = ScheduledJob.create().name(ScheduledJobName.from("name")).config(config).user(user).descriptor(descriptor).description(description).calendar(mock(ScheduleCalendar.class)).enabled(true).creator(creator).modifier(modifier).createdTime(createdTime).modifiedTime(modifiedTime).build();
final ScheduledJob target = new EditableScheduledJob(source).build();
assertEquals(source.getName(), target.getName());
assertEquals(source.getConfig(), target.getConfig());
assertEquals(source.getUser(), target.getUser());
assertEquals(source.getDescriptor(), target.getDescriptor());
assertEquals(source.getDescription(), target.getDescription());
assertEquals(source.isEnabled(), target.isEnabled());
assertEquals(source.getCreator(), target.getCreator());
assertEquals(source.getCreatedTime(), target.getCreatedTime());
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class TaskServiceImplTest method submitTask_DescriptorKey_offload_to_clustered_wait_success.
@Test
void submitTask_DescriptorKey_offload_to_clustered_wait_success() {
final DescriptorKey descriptorKey = DescriptorKey.from("module:my-admin-tool");
final TaskManager clusteredTaskManager = mock(TaskManager.class);
when(taskConfig.distributable_acceptInbound()).thenReturn(false);
taskService.activate(taskConfig);
CompletableFuture.runAsync(() -> taskService.setClusteredTaskManager(clusteredTaskManager), CompletableFuture.delayedExecutor(1, TimeUnit.SECONDS));
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 TaskDescriptorLoaderTest method testLoad.
@Test
public void testLoad() {
final DescriptorKey descriptorKey = DescriptorKey.from("myapp1:task1");
final ResourceKey resourceKey = this.loader.toResource(descriptorKey);
assertEquals("myapp1:/tasks/task1/task1.xml", resourceKey.toString());
final Resource resource = this.resourceService.getResource(resourceKey);
final TaskDescriptor descriptor = this.loader.load(descriptorKey, resource);
assertEquals("MyTask", descriptor.getDescription());
FormItem formItem = descriptor.getConfig().getFormItem("param1");
assertEquals(" something ", formItem.toInput().getDefaultValue().getRootValue());
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class TaskServiceImplTest method submitTask_DescriptorKey_offload_to_local.
@Test
void submitTask_DescriptorKey_offload_to_local() {
final DescriptorKey descriptorKey = DescriptorKey.from("module:my-admin-tool");
final TaskId taskId = taskService.submitTask(SubmitTaskParams.create().descriptorKey(descriptorKey).build());
verify(taskManager).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 DistributableTaskTest method run.
@Test
void run() {
final NamedTask namedTask = mock(NamedTask.class);
final DescriptorKey descriptorKey = DescriptorKey.from("app:a");
final TaskDescriptor descriptor = TaskDescriptor.create().key(descriptorKey).description("task description").build();
final PropertyTree config = new PropertyTree();
when(namedTaskFactory.create(descriptor, config)).thenReturn(namedTask);
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);
describedTask.run(mock(ProgressReporter.class));
verify(namedTask).run(any(TaskId.class), any(ProgressReporter.class));
}
Aggregations