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