Search in sources :

Example 61 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class ServiceDescriptorServiceImpl method getByKey.

@Override
public ServiceDescriptor getByKey(final DescriptorKey descriptorKey) {
    final ResourceProcessor<DescriptorKey, ServiceDescriptor> processor = newRootProcessor(descriptorKey);
    final ServiceDescriptor descriptor = this.resourceService.processResource(processor);
    if (descriptor != null) {
        return descriptor;
    }
    return createDefaultDescriptor(descriptorKey);
}
Also used : ServiceDescriptor(com.enonic.xp.service.ServiceDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey)

Example 62 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class PageRegionsConfigProcessorTest method test_part_component.

@Test
public void test_part_component() throws Exception {
    final DescriptorKey partDescriptorKey = DescriptorKey.from("part1AppKey:name");
    final String htmlarea = "htmlarea";
    final Page page = Page.create().regions(PageRegions.create().add(Region.create().name("region1").add(PartComponent.create().descriptor(partDescriptorKey).build()).build()).build()).build();
    final PatternIndexConfigDocument result = processPage(page, Arrays.asList(configFormWithHtmlArea).listIterator(), null);
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(COMPONENTS, PartComponentType.INSTANCE.toString(), CONFIG, partDescriptorKey.getApplicationKey().toString(), partDescriptorKey.getName(), htmlarea)).getIndexValueProcessors().get(0).getName());
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey) Page(com.enonic.xp.page.Page) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 63 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class PageRegionsConfigProcessorTest method test_layout_component.

@Test
public void test_layout_component() throws Exception {
    final DescriptorKey layoutDescriptorKey = DescriptorKey.from("layoutAppKey:name");
    final String htmlarea = "htmlarea";
    final Page page = Page.create().regions(PageRegions.create().add(Region.create().name("region1").add(LayoutComponent.create().descriptor(layoutDescriptorKey).regions(LayoutRegions.create().build()).build()).build()).build()).build();
    final PatternIndexConfigDocument result = processPage(page, null, Arrays.asList(configFormWithHtmlArea).listIterator());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(COMPONENTS, LayoutComponentType.INSTANCE.toString(), CONFIG, layoutDescriptorKey.getApplicationKey().toString(), layoutDescriptorKey.getName(), htmlarea)).getIndexValueProcessors().get(0).getName());
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey) Page(com.enonic.xp.page.Page) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 64 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class RegionDataSerializerTest method region.

@Test
public void region() {
    final PropertyTree myPartConfig = new PropertyTree();
    myPartConfig.addString("some", "config");
    final String layoutName = "MyOtherPart";
    final DescriptorKey layoutDescriptorKey = DescriptorKey.from("app-descr:layout-name");
    final Region region = Region.create().name("main").add(createPartComponent("MyPart", "app-descr:part-name", myPartConfig)).add(ImageComponent.create().build()).add(LayoutComponent.create().descriptor(layoutDescriptorKey).build()).build();
    Mockito.when(layoutDescriptorService.getByKey(layoutDescriptorKey)).thenReturn(LayoutDescriptor.create().key(layoutDescriptorKey).displayName(layoutName).config(Form.create().build()).regions(RegionDescriptors.create().build()).build());
    final PropertyTree regionAsData = new PropertyTree();
    // exercise
    regionSerializer.toData(region, regionAsData.getRoot());
    final RegionDescriptor regionDescriptor = RegionDescriptor.create().name("main").build();
    final List<PropertySet> components = regionAsData.getProperties(ComponentDataSerializer.COMPONENTS).stream().map(item -> item.getSet()).collect(Collectors.toList());
    final Region parsedRegion = regionSerializer.fromData(regionDescriptor, ComponentPath.DIVIDER, components);
    // verify
    assertEquals(region, parsedRegion);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) PropertySet(com.enonic.xp.data.PropertySet) RegionDescriptors(com.enonic.xp.region.RegionDescriptors) Collectors(java.util.stream.Collectors) ComponentPath(com.enonic.xp.region.ComponentPath) LayoutDescriptor(com.enonic.xp.region.LayoutDescriptor) Test(org.junit.jupiter.api.Test) Form(com.enonic.xp.form.Form) Region(com.enonic.xp.region.Region) Mockito(org.mockito.Mockito) List(java.util.List) LayoutComponent(com.enonic.xp.region.LayoutComponent) DescriptorKey(com.enonic.xp.page.DescriptorKey) AbstractDataSerializerTest(com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest) ImageComponent(com.enonic.xp.region.ImageComponent) RegionDescriptor(com.enonic.xp.region.RegionDescriptor) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PropertyTree(com.enonic.xp.data.PropertyTree) RegionDescriptor(com.enonic.xp.region.RegionDescriptor) PropertyTree(com.enonic.xp.data.PropertyTree) DescriptorKey(com.enonic.xp.page.DescriptorKey) Region(com.enonic.xp.region.Region) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test) AbstractDataSerializerTest(com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest)

Example 65 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class AbstractDataSerializerTest method createPartComponent.

protected PartComponent createPartComponent(final String partName, final String descriptorKey, final PropertyTree partConfig) {
    final DescriptorKey descriptor = DescriptorKey.from(descriptorKey);
    Mockito.when(partDescriptorService.getByKey(descriptor)).thenReturn(PartDescriptor.create().key(descriptor).displayName(partName).config(Form.create().build()).build());
    return PartComponent.create().descriptor(descriptor).config(partConfig).build();
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey)

Aggregations

DescriptorKey (com.enonic.xp.page.DescriptorKey)73 Test (org.junit.jupiter.api.Test)45 PropertyTree (com.enonic.xp.data.PropertyTree)25 PrincipalKey (com.enonic.xp.security.PrincipalKey)11 ScheduledJob (com.enonic.xp.scheduler.ScheduledJob)10 TaskId (com.enonic.xp.task.TaskId)10 Page (com.enonic.xp.page.Page)7 ScheduledJobName (com.enonic.xp.scheduler.ScheduledJobName)7 TaskDescriptor (com.enonic.xp.task.TaskDescriptor)7 Instant (java.time.Instant)7 PropertySet (com.enonic.xp.data.PropertySet)6 ServiceDescriptor (com.enonic.xp.service.ServiceDescriptor)6 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)5 CronCalendar (com.enonic.xp.scheduler.CronCalendar)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 ApplicationKey (com.enonic.xp.app.ApplicationKey)4 AbstractDescriptorServiceTest (com.enonic.xp.core.impl.content.page.AbstractDescriptorServiceTest)4 DescribedTask (com.enonic.xp.impl.task.distributed.DescribedTask)4 PortalRequest (com.enonic.xp.portal.PortalRequest)4 PortalResponse (com.enonic.xp.portal.PortalResponse)4