Search in sources :

Example 36 with Page

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);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) DescriptorKey(com.enonic.xp.page.DescriptorKey) Page(com.enonic.xp.page.Page) Test(org.junit.jupiter.api.Test) AbstractDataSerializerTest(com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest)

Example 37 with Page

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());
}
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 38 with Page

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()));
}
Also used : Page(com.enonic.xp.page.Page) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 39 with Page

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());
}
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 40 with Page

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();
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Page(com.enonic.xp.page.Page)

Aggregations

Page (com.enonic.xp.page.Page)58 PropertyTree (com.enonic.xp.data.PropertyTree)30 Test (org.junit.jupiter.api.Test)28 Content (com.enonic.xp.content.Content)25 Site (com.enonic.xp.site.Site)12 DescriptorKey (com.enonic.xp.page.DescriptorKey)9 PageRegions (com.enonic.xp.page.PageRegions)9 AbstractDataSerializerTest (com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest)7 PageDescriptor (com.enonic.xp.page.PageDescriptor)7 PageTemplate (com.enonic.xp.page.PageTemplate)7 PropertySet (com.enonic.xp.data.PropertySet)6 Form (com.enonic.xp.form.Form)5 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)5 LayoutComponent (com.enonic.xp.region.LayoutComponent)5 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)4 EditableContent (com.enonic.xp.content.EditableContent)4 Component (com.enonic.xp.region.Component)4 PartComponent (com.enonic.xp.region.PartComponent)4 ContentId (com.enonic.xp.content.ContentId)3 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)3