use of com.enonic.xp.page.Page in project xp by enonic.
the class MappingHandlerTest 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();
}
use of com.enonic.xp.page.Page in project xp by enonic.
the class MappingHandlerTest method createSite.
private Site createSite(final String id, final String path, final String contentTypeName) {
PropertyTree rootDataSet = new PropertyTree();
rootDataSet.addString("property1", "value1");
Page page = Page.create().template(PageTemplateKey.from("my-page")).config(rootDataSet).build();
final SiteConfig siteConfig = SiteConfig.create().application(ApplicationKey.from("myapplication")).config(new PropertyTree()).build();
return Site.create().siteConfigs(SiteConfigs.from(siteConfig)).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)).page(page).build();
}
use of com.enonic.xp.page.Page in project xp by enonic.
the class RenderBaseHandlerTest 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();
}
use of com.enonic.xp.page.Page in project xp by enonic.
the class ComponentHandlerTest method createSite.
private Site createSite(final String id, final String path, final String contentTypeName) {
PropertyTree rootDataSet = new PropertyTree();
rootDataSet.addString("property1", "value1");
Page page = Page.create().template(PageTemplateKey.from("my-page")).config(rootDataSet).build();
return Site.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)).page(page).build();
}
use of com.enonic.xp.page.Page in project xp by enonic.
the class PageResolverTest method given_Content_without_Page_then_effective_Page_is_same_as_in_Template.
@Test
public void given_Content_without_Page_then_effective_Page_is_same_as_in_Template() {
// setup
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").page(Page.create().descriptor(DescriptorKey.from("myapp:my-descriptor")).config(configA).regions(regionsA).build()).build();
Content content = Content.create().parentPath(site.getPath()).name("my-content").build();
when(pageTemplateService.getDefault(notNull())).thenReturn(template);
// exercise
PageResolverResult result = pageResolver.resolve(RenderMode.LIVE, content, site);
final Page effectivePage = result.getEffectivePage();
// verify
assertEquals(configA, effectivePage.getConfig());
assertEquals(regionsA, effectivePage.getRegions());
assertNull(effectivePage.getDescriptor());
assertEquals(template.getKey(), effectivePage.getTemplate());
assertEquals(DescriptorKey.from("myapp:my-descriptor"), result.getController());
}
Aggregations