Search in sources :

Example 16 with Page

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

the class PageResolverTest method page_with_own_descriptor.

@Test
public void page_with_own_descriptor() {
    Site site = Site.create().id(ContentId.from("site-id")).path(ContentPath.from("/site")).displayName("My Site").type(ContentTypeName.from("portal:site")).build();
    final Page page = Page.create().descriptor(DescriptorKey.from("myapp:my-descriptor")).config(configB).build();
    Content content = Content.create().parentPath(site.getPath()).name("my-content").page(page).type(ContentTypeName.templateFolder()).build();
    PageResolverResult result = pageResolver.resolve(RenderMode.LIVE, content, site);
    final Page effectivePage = result.getEffectivePage();
    assertSame(page, effectivePage);
    assertEquals(DescriptorKey.from("myapp:my-descriptor"), result.getController());
    verifyNoInteractions(pageTemplateService);
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Page(com.enonic.xp.page.Page) Test(org.junit.jupiter.api.Test)

Example 17 with Page

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

the class PageResolverTest method content_is_Fragment.

@Test
public void content_is_Fragment() {
    Site site = Site.create().id(ContentId.from("site-id")).path(ContentPath.from("/site")).displayName("My Site").type(ContentTypeName.from("portal:site")).build();
    final Page page = Page.create().fragment(FragmentComponent.create().build()).build();
    Content content = Content.create().parentPath(site.getPath()).name("my-content").page(page).type(ContentTypeName.templateFolder()).build();
    PageResolverResult result = pageResolver.resolve(RenderMode.LIVE, content, site);
    final Page effectivePage = result.getEffectivePage();
    assertSame(page, effectivePage);
    assertNull(result.getController());
    verifyNoInteractions(pageTemplateService);
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Page(com.enonic.xp.page.Page) Test(org.junit.jupiter.api.Test)

Example 18 with Page

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

the class PageResolverTest method content_without_Page_and_Template_withoutPage.

@Test
public void content_without_Page_and_Template_withoutPage() {
    Site site = Site.create().id(ContentId.from("site-id")).path(ContentPath.from("/site")).displayName("My Site").type(ContentTypeName.from("portal:site")).build();
    PageTemplate template = PageTemplate.newPageTemplate().key(PageTemplateKey.from("t-1")).parentPath(site.getPath()).name("my-template").build();
    Content content = Content.create().parentPath(site.getPath()).name("my-content").build();
    when(pageTemplateService.getDefault(notNull())).thenReturn(template);
    PageResolverResult result = pageResolver.resolve(RenderMode.EDIT, content, site);
    final Page effectivePage = result.getEffectivePage();
    assertNull(effectivePage.getDescriptor());
    assertEquals(template.getKey(), effectivePage.getTemplate());
}
Also used : Site(com.enonic.xp.site.Site) PageTemplate(com.enonic.xp.page.PageTemplate) Content(com.enonic.xp.content.Content) Page(com.enonic.xp.page.Page) Test(org.junit.jupiter.api.Test)

Example 19 with Page

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

the class ServiceHandlerTest 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().descriptor("myapp:mypart").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)

Example 20 with Page

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

the class HtmlAreaContentProcessorTest method page_config_data.

@Test
public void page_config_data() throws IOException {
    final PropertyTree data = new PropertyTree();
    data.addProperty("htmlData", ValueFactory.newString("<img data-src=\"image://image-id\"/>"));
    final Form form = Form.create().addFormItem(Input.create().name("htmlData").label("htmlData").inputType(InputTypeName.HTML_AREA).build()).build();
    final PageDescriptor pageDescriptor = PageDescriptor.create().config(form).regions(RegionDescriptors.create().build()).key(DescriptorKey.from("aaa:bbb")).build();
    Mockito.when(pageDescriptorService.getByKey(Mockito.isA(DescriptorKey.class))).thenReturn(pageDescriptor);
    final Page page = Page.create().config(data).descriptor(pageDescriptor.getKey()).build();
    final EditableContent editableContent = new EditableContent(Media.create().name("myContentName").type(contentTypeName).page(page).parentPath(ContentPath.ROOT).data(new PropertyTree()).build());
    result.getEditor().edit(editableContent);
    assertEquals(1, editableContent.processedReferences.build().getSize());
    assertTrue(editableContent.processedReferences.build().contains(ContentId.from("image-id")));
}
Also used : PageDescriptor(com.enonic.xp.page.PageDescriptor) Form(com.enonic.xp.form.Form) PropertyTree(com.enonic.xp.data.PropertyTree) EditableContent(com.enonic.xp.content.EditableContent) DescriptorKey(com.enonic.xp.page.DescriptorKey) Page(com.enonic.xp.page.Page) Test(org.junit.jupiter.api.Test)

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