use of com.enonic.xp.node.EditableNode in project xp by enonic.
the class ModifyNodeHandlerTest method getEditedNode.
private EditableNode getEditedNode(final Node node) {
final NodeEditor editor = updateCaptor.getValue().getEditor();
assertNotNull(editor);
final EditableNode editableNode = new EditableNode(node);
editor.edit(editableNode);
return editableNode;
}
use of com.enonic.xp.node.EditableNode in project xp by enonic.
the class ModifyNodeExecutorTest method update_permissions.
@Test
public void update_permissions() throws Exception {
final Node originalNode = Node.create().name("myNode").parentPath(NodePath.ROOT).permissions(AccessControlList.empty()).build();
final EditableNode editableNode = new EditableNode(originalNode);
final PropertyTree updateScript = new PropertyTree();
final PropertySet propertySet = new PropertySet();
propertySet.setString("principal", "role:newRole");
propertySet.addString("allow", "READ");
propertySet.addString("allow", "MODIFY");
updateScript.addSet("_permissions", propertySet);
ModifyNodeExecutor.create().editableNode(editableNode).propertyTree(updateScript).build().execute();
final AccessControlList newPermissions = AccessControlList.create().add(AccessControlEntry.create().principal(PrincipalKey.from("role:newRole")).allow(Permission.READ, Permission.MODIFY).build()).build();
assertEquals(newPermissions, editableNode.permissions);
}
use of com.enonic.xp.node.EditableNode in project xp by enonic.
the class ModifyNodeExecutorTest method modify_user_properties.
@Test
public void modify_user_properties() throws Exception {
final PropertyTree data = new PropertyTree();
data.setString("notChanged", "originalValue");
data.setString("myString", "originalValue");
final PropertySet mySet = data.addSet("mySet");
mySet.setGeoPoint("myGeoPoint", new GeoPoint(30, -30));
final Node originalNode = Node.create().name("myNode").parentPath(NodePath.ROOT).data(data).build();
final EditableNode editableNode = new EditableNode(originalNode);
final PropertyTree updateScript = createUpdateScript();
ModifyNodeExecutor.create().editableNode(editableNode).propertyTree(updateScript).build().execute();
assertEquals(new GeoPoint(0, 0), editableNode.data.getGeoPoint("mySet.myGeoPoint"));
assertEquals("updatedValue", editableNode.data.getString("myString"));
}
use of com.enonic.xp.node.EditableNode in project xp by enonic.
the class ModifyNodeExecutorTest method remove_not_in_new_tree.
@Test
public void remove_not_in_new_tree() throws Exception {
final PropertyTree data = new PropertyTree();
data.setString("toBeRemoved", "removeMe");
final Node originalNode = Node.create().name("myNode").parentPath(NodePath.ROOT).data(data).build();
final EditableNode editableNode = new EditableNode(originalNode);
final PropertyTree updateScript = new PropertyTree();
ModifyNodeExecutor.create().editableNode(editableNode).propertyTree(updateScript).build().execute();
assertNull(editableNode.data.getString("toBeRemoved"));
}
Aggregations