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