use of com.enonic.xp.node.ImportNodeResult in project xp by enonic.
the class ImportNodeCommandTest method import_existing_node.
@Test
public void import_existing_node() {
PropertyTree data = new PropertyTree();
data.addString("name", "value");
final Node importNode = Node.create().id(NodeId.from("abc")).name("myNode").parentPath(NodePath.ROOT).data(data).build();
importNode(importNode);
final Node abc = getNodeById(NodeId.from("abc"));
assertNotNull(abc);
assertEquals(data, abc.data());
PropertyTree data2 = new PropertyTree();
data2.addString("name", "valueUpdated");
final Node importNode2 = Node.create().id(NodeId.from("abc")).name("myNode").parentPath(NodePath.ROOT).data(data2).build();
final ImportNodeResult importNodeResult = importNode(importNode2);
final Node abc2 = getNodeById(NodeId.from("abc"));
assertNotNull(abc2);
assertEquals(data2, abc2.data());
assertEquals(importNodeResult.getNode().data(), abc2.data());
assertTrue(importNodeResult.isPreExisting());
}
use of com.enonic.xp.node.ImportNodeResult in project xp by enonic.
the class ImportNodeCommandTest method permissions_on_root_create.
@Test
public void permissions_on_root_create() throws Exception {
final AccessControlList aclList = AccessControlList.create().add(AccessControlEntry.create().principal(PrincipalKey.ofAnonymous()).allowAll().deny(Permission.DELETE).build()).add(AccessControlEntry.create().principal(TEST_DEFAULT_USER.getKey()).allowAll().deny(Permission.DELETE).build()).build();
final Node rootNode = Node.create().id(Node.ROOT_UUID).name("rootNode").parentPath(NodePath.ROOT).data(new PropertyTree()).permissions(aclList).build();
this.nodeRepositoryService.create(CreateRepositoryParams.create().repositoryId(RepositoryId.from("test")).build());
final ImportNodeResult importNodeResult = ContextBuilder.from(ContextAccessor.current()).repositoryId("test").build().callWith(() -> importNode(rootNode, false, true));
assertEquals(aclList, importNodeResult.getNode().getPermissions());
}
use of com.enonic.xp.node.ImportNodeResult in project xp by enonic.
the class ImportNodeCommandTest method keep_permissions_on_create.
@Test
public void keep_permissions_on_create() throws Exception {
final AccessControlList aclList = AccessControlList.create().add(AccessControlEntry.create().principal(PrincipalKey.ofAnonymous()).allowAll().deny(Permission.DELETE).build()).add(AccessControlEntry.create().principal(TEST_DEFAULT_USER.getKey()).allowAll().deny(Permission.DELETE).build()).build();
final Node importNode = Node.create().id(NodeId.from("abc")).name("myNode").parentPath(NodePath.ROOT).data(new PropertyTree()).permissions(aclList).build();
final ImportNodeResult importNodeResult = importNode(importNode);
final Node abc = getNodeById(NodeId.from("abc"));
assertNotNull(abc);
assertEquals(aclList, abc.getPermissions());
assertEquals(importNodeResult.getNode().getPermissions(), abc.getPermissions());
assertFalse(importNodeResult.isPreExisting());
}
Aggregations