use of com.enonic.xp.page.Page in project xp by enonic.
the class PageDataSerializerTest method page_with_regions_as_null.
@Test
public void page_with_regions_as_null() {
final PropertyTree pageConfig = new PropertyTree();
pageConfig.addString("some", "config");
final DescriptorKey pageDescriptorKey = DescriptorKey.from("app-key:d-name");
final Page page = Page.create().config(pageConfig).descriptor(pageDescriptorKey).regions(null).build();
Mockito.when(pageDescriptorService.getByKey(pageDescriptorKey)).thenReturn(PageDescriptor.create().config(Form.create().build()).key(pageDescriptorKey).regions(RegionDescriptors.create().build()).build());
final PropertyTree pageAsData = new PropertyTree();
pageDataSerializer.toData(page, pageAsData.getRoot());
final Page parsedPage = pageDataSerializer.fromData(pageAsData.getRoot());
// verify
assertEquals(page, parsedPage);
}
use of com.enonic.xp.page.Page 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.Page in project xp by enonic.
the class PageRegionsConfigProcessorTest method test_fragment_component.
@Test
public void test_fragment_component() throws Exception {
final Page page = Page.create().regions(PageRegions.create().add(Region.create().name("region1").add(FragmentComponent.create().fragment(ContentId.from("content-id")).build()).build()).build()).build();
final PatternIndexConfigDocument result = processPage(page, singletonList(configFormWithHtmlArea).listIterator(), null);
assertTrue(result.getPathIndexConfigs().contains(PathIndexConfig.create().path(PropertyPath.from(COMPONENTS, FragmentComponentType.INSTANCE.toString(), ID)).indexConfig(IndexConfig.MINIMAL).build()));
}
use of com.enonic.xp.page.Page 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.Page in project xp by enonic.
the class WidgetHandlerTest method createPage.
private Content createPage(final String id, final String path, final String contentTypeName, final boolean withPage) {
PropertyTree rootDataSet = new PropertyTree();
rootDataSet.addString("property1", "value1");
final Content.Builder content = Content.create().id(ContentId.from(id)).path(ContentPath.from(path)).owner(PrincipalKey.from("user:myStore:me")).displayName("My Content").modifier(PrincipalKey.from("user:system:admin")).type(ContentTypeName.from(contentTypeName));
if (withPage) {
PageRegions pageRegions = PageRegions.create().add(Region.create().name("main-region").add(PartComponent.create().build()).build()).build();
Page page = Page.create().template(PageTemplateKey.from("my-page")).regions(pageRegions).config(rootDataSet).build();
content.page(page);
}
return content.build();
}
Aggregations