Search in sources :

Example 26 with PropertyTree

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"));
}
Also used : WebResponse(com.enonic.xp.web.WebResponse) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PageUrlParams(com.enonic.xp.portal.url.PageUrlParams) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 27 with PropertyTree

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"));
}
Also used : WebResponse(com.enonic.xp.web.WebResponse) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PageUrlParams(com.enonic.xp.portal.url.PageUrlParams) Test(org.junit.jupiter.api.Test)

Example 28 with PropertyTree

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();
}
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 29 with PropertyTree

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

Example 30 with PropertyTree

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

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)639 Test (org.junit.jupiter.api.Test)404 PropertySet (com.enonic.xp.data.PropertySet)134 Content (com.enonic.xp.content.Content)125 Node (com.enonic.xp.node.Node)112 CreateContentParams (com.enonic.xp.content.CreateContentParams)64 Form (com.enonic.xp.form.Form)37 Page (com.enonic.xp.page.Page)32 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)31 DescriptorKey (com.enonic.xp.page.DescriptorKey)30 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)30 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)28 PrincipalKey (com.enonic.xp.security.PrincipalKey)28 BinaryReference (com.enonic.xp.util.BinaryReference)28 Property (com.enonic.xp.data.Property)26 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)24 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)23 ByteSource (com.google.common.io.ByteSource)22 ExtraData (com.enonic.xp.content.ExtraData)21 Instant (java.time.Instant)21