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