use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class PageHandlerTest method getContentShortcutWithParams.
@Test
public void getContentShortcutWithParams() throws Exception {
final PropertyTree rootDataSet = new PropertyTree();
rootDataSet.addReference("target", Reference.from("ref"));
final PropertySet shortcutParam1 = new PropertySet();
shortcutParam1.addString("name", "product");
shortcutParam1.addString("value", "123456");
final PropertySet shortcutParam2 = new PropertySet();
shortcutParam2.addString("name", "order");
shortcutParam2.addString("value", "abcdef");
rootDataSet.addSet("parameters", shortcutParam1);
rootDataSet.addSet("parameters", shortcutParam2);
final Content content = Content.create().id(ContentId.from("id")).path(ContentPath.from("site/somepath/shortcut")).owner(PrincipalKey.from("user:myStore:me")).displayName("My Content").modifier(PrincipalKey.from("user:system:admin")).type(ContentTypeName.shortcut()).data(rootDataSet).build();
when(this.contentService.getByPath(content.getPath().asAbsolute())).thenReturn(content);
when(this.portalUrlService.pageUrl(any(PageUrlParams.class))).thenReturn("/master/site/otherpath?product=123456&order=abcdef");
this.request.setContentPath(ContentPath.from("/site/somepath/shortcut"));
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.TEMPORARY_REDIRECT, res.getStatus());
assertEquals("/master/site/otherpath?product=123456&order=abcdef", res.getHeaders().get("Location"));
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class PageHandlerTest method getContentShortcut.
@Test
public void getContentShortcut() throws Exception {
final PropertyTree rootDataSet = new PropertyTree();
rootDataSet.addReference("target", Reference.from("ref"));
final Content content = Content.create().id(ContentId.from("id")).path(ContentPath.from("site/somepath/shortcut")).owner(PrincipalKey.from("user:myStore:me")).displayName("My Content").modifier(PrincipalKey.from("user:system:admin")).type(ContentTypeName.shortcut()).data(rootDataSet).build();
when(this.contentService.getByPath(content.getPath().asAbsolute())).thenReturn(content);
when(this.portalUrlService.pageUrl(any(PageUrlParams.class))).thenReturn("/master/site/otherpath");
this.request.setContentPath(ContentPath.from("/site/somepath/shortcut"));
final WebResponse res = this.handler.handle(this.request, PortalResponse.create().build(), null);
assertNotNull(res);
assertEquals(HttpStatus.TEMPORARY_REDIRECT, res.getStatus());
assertEquals("/master/site/otherpath", res.getHeaders().get("Location"));
}
use of com.enonic.xp.data.PropertyTree 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.data.PropertyTree 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.data.PropertyTree in project xp by enonic.
the class ServiceHandlerTest 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("demo")).config(new PropertyTree()).build();
return Site.create().addSiteConfig(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();
}
Aggregations