Search in sources :

Example 51 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class CreateNodeHandlerTest method example_1.

@Test
public void example_1() {
    final PropertyTree data = new PropertyTree();
    data.addString("likes", "plywood");
    data.addDouble("numberOfUselessGadgets", 123.0);
    final Node node = Node.create().id(NodeId.from("a-random-node-id")).data(data).permissions(AccessControlList.create().add(AccessControlEntry.create().allowAll().principal(RoleKeys.ADMIN).build()).build()).build();
    mockCreateNode(node);
    Mockito.when(this.repositoryService.get(RepositoryId.from("com.enonic.cms.default"))).thenReturn(Repository.create().id(RepositoryId.from("com.enonic.cms.default")).branches(Branches.from(ContentConstants.BRANCH_DRAFT, ContentConstants.BRANCH_MASTER)).build());
    runScript("/lib/xp/examples/node/create-1.js");
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 52 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class PermissionsFactoryTest method create.

private AccessControlList create(final String json) {
    final JsonNode node = JsonHelper.from(json);
    final PropertyTree properties = JsonToPropertyTreeTranslator.translate(node);
    return new PermissionsFactory(properties.getRoot().getSets("_permissions")).create();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 53 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class ModifyNodeExecutorTest method update_child_order.

@Test
public void update_child_order() throws Exception {
    final Node originalNode = Node.create().name("myNode").childOrder(ChildOrder.manualOrder()).parentPath(NodePath.ROOT).build();
    final EditableNode editableNode = new EditableNode(originalNode);
    final PropertyTree updateScript = new PropertyTree();
    updateScript.setString("_childOrder", ChildOrder.reverseManualOrder().toString());
    ModifyNodeExecutor.create().editableNode(editableNode).propertyTree(updateScript).build().execute();
    assertEquals(ChildOrder.reverseManualOrder(), editableNode.childOrder);
}
Also used : Node(com.enonic.xp.node.Node) EditableNode(com.enonic.xp.node.EditableNode) PropertyTree(com.enonic.xp.data.PropertyTree) EditableNode(com.enonic.xp.node.EditableNode) Test(org.junit.jupiter.api.Test)

Example 54 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class CreateNodeParamsFactoryTest method manual_order_value.

@Test
public void manual_order_value() throws Exception {
    final PropertyTree properties = new PropertyTree();
    properties.setLong(MANUAL_ORDER_VALUE, 3L);
    final CreateNodeParams createNodeParams = new CreateNodeParamsFactory().create(properties, BinaryAttachments.empty());
    assertEquals(3L, createNodeParams.getManualOrderValue().longValue());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) Test(org.junit.jupiter.api.Test)

Example 55 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class CreateNodeParamsFactoryTest method createWithStringProperty.

private CreateNodeParams createWithStringProperty(final String nodeName, final String myNode) {
    final PropertyTree properties = new PropertyTree();
    properties.setString(nodeName, myNode);
    return new CreateNodeParamsFactory().create(new ScriptValueTranslatorResult(properties, BinaryAttachments.empty()));
}
Also used : ScriptValueTranslatorResult(com.enonic.xp.lib.value.ScriptValueTranslatorResult) PropertyTree(com.enonic.xp.data.PropertyTree)

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)660 Test (org.junit.jupiter.api.Test)405 PropertySet (com.enonic.xp.data.PropertySet)150 Content (com.enonic.xp.content.Content)126 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