use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method push_rename_push_test.
@Test
public void push_rename_push_test() throws Exception {
PushNodesResult result;
// Creates and pushes a content
final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build());
result = pushNodes(NodeIds.from(node.id()), WS_OTHER);
assertEquals(1, result.getSuccessful().getSize());
assertNotNull(getNodeByPath(NodePath.create("/my-node").build()));
assertNotNull(getNodeByPathInOther(NodePath.create("/my-node").build()));
// Renames the content
renameNode(node, "my-node-renamed");
assertNull(getNodeByPath(NodePath.create("/my-node").build()));
assertNotNull(getNodeByPath(NodePath.create("/my-node-renamed").build()));
assertNotNull(getNodeByPathInOther(NodePath.create("/my-node").build()));
// Pushed the renames content
result = pushNodes(NodeIds.from(node.id()), WS_OTHER);
assertEquals(1, result.getSuccessful().getSize());
assertNull(getNodeByPathInOther(NodePath.create("/my-node").build()));
assertNotNull(getNodeByPathInOther(NodePath.create("/my-node-renamed").build()));
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method push_child_fail_if_parent_does_not_exists.
@Test
public void push_child_fail_if_parent_does_not_exists() throws Exception {
final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build());
final Node child = createNode(CreateNodeParams.create().parent(node.path()).name("my-child").build());
final PushNodesResult result = pushNodes(NodeIds.from(child.id()), WS_OTHER);
assertEquals(1, result.getFailed().size());
assertEquals(PushNodesResult.Reason.PARENT_NOT_FOUND, result.getFailed().iterator().next().getReason());
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandPerformanceTest method testReferencePerformance.
@Disabled
@Test
public void testReferencePerformance() throws Exception {
final Node rootNode = createNode(CreateNodeParams.create().name("rootNode").parent(NodePath.ROOT).build(), false);
createNodes(rootNode, 20, 3, 1);
refresh();
final ResolveSyncWorkResult syncWork = ResolveSyncWorkCommand.create().nodeId(rootNode.id()).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
final Stopwatch started = Stopwatch.createStarted();
final PushNodesResult result = PushNodesCommand.create().ids(syncWork.getNodeComparisons().getNodeIds()).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
started.stop();
final long elapsed = started.elapsed(TimeUnit.SECONDS);
final int number = result.getSuccessful().getSize();
System.out.println("Pushed : " + number + " in " + started + ", " + (elapsed == 0 ? "n/a" : (number / elapsed) + "/s"));
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method push_child_missing_permission.
@Test
public void push_child_missing_permission() throws Exception {
final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build());
final Node child = createNode(CreateNodeParams.create().parent(node.path()).name("my-child").permissions(AccessControlList.create().add(AccessControlEntry.create().allowAll().deny(Permission.PUBLISH).principal(TEST_DEFAULT_USER.getKey()).build()).build()).build());
final PushNodesResult result = pushNodes(NodeIds.from(node.id(), child.id()), WS_OTHER);
assertEquals(1, result.getSuccessful().getSize());
assertEquals(1, result.getFailed().size());
assertEquals(PushNodesResult.Reason.ACCESS_DENIED, result.getFailed().iterator().next().getReason());
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method push_fail_if_node_already_exists.
@Test
public void push_fail_if_node_already_exists() throws Exception {
final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build());
ctxOther().callWith(() -> createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build()));
final PushNodesResult result = pushNodes(NodeIds.from(node.id()), WS_OTHER);
assertEquals(1, result.getFailed().size());
assertEquals(0, result.getSuccessful().getSize());
assertEquals(PushNodesResult.Reason.ALREADY_EXIST, result.getFailed().iterator().next().getReason());
}
Aggregations