use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method moved_nodes_yields_reindex_of_children.
@Test
public void moved_nodes_yields_reindex_of_children() throws Exception {
final Node node1 = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node1").setNodeId(NodeId.from("node1")).build());
final Node node2 = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node2").setNodeId(NodeId.from("node2")).build());
final Node child1 = createNode(CreateNodeParams.create().parent(node1.path()).name("child1").setNodeId(NodeId.from("child1")).build());
final Node child2 = createNode(CreateNodeParams.create().parent(node1.path()).name("child2").setNodeId(NodeId.from("child2")).build());
final Node child1_1 = createNode(CreateNodeParams.create().parent(child1.path()).name("child1_1").setNodeId(NodeId.from("child1_1")).build());
final Node child1_1_1 = createNode(CreateNodeParams.create().parent(child1_1.path()).name("child1_1_1").setNodeId(NodeId.from("child1_1_1")).build());
final Node child2_1 = createNode(CreateNodeParams.create().parent(child2.path()).name("child2_1").setNodeId(NodeId.from("child2_1")).build());
final PushNodesResult result = pushNodes(NodeIds.from(node1.id(), node2.id(), child1.id(), child1_1.id(), child1_1_1.id(), child2.id(), child2_1.id()), WS_OTHER);
assertNotNull(getNodeByPathInOther(NodePath.create(node1.path(), child1.name().toString()).build()));
final Node movedNode = MoveNodeCommand.create().id(node1.id()).newParent(node2.path()).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute().getMovedNodes().get(0).getNode();
pushNodes(NodeIds.from(node1.id()), WS_OTHER);
assertNotNull(getNodeByPathInOther(NodePath.create(movedNode.path(), child1.name().toString()).build()));
assertNull(getNodeByPathInOther(NodePath.create(node1.path(), child1.name().toString()).build()));
Node child1Node = ctxOther().callWith(() -> getNodeById(child1.id()));
assertNotNull(getNodeByPathInOther(NodePath.create(child1Node.path(), child1_1.name().toString()).build()));
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method push_after_rename.
@Test
public void push_after_rename() throws Exception {
final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node1").setNodeId(NodeId.from("node1")).build());
final Node child1 = createNode(CreateNodeParams.create().parent(node.path()).name("child1").setNodeId(NodeId.from("child1")).build());
final Node child1_1 = createNode(CreateNodeParams.create().parent(child1.path()).name("child1_1").setNodeId(NodeId.from("child1_1")).build());
final Node child1_1_1 = createNode(CreateNodeParams.create().parent(child1_1.path()).name("child1_1_1").setNodeId(NodeId.from("child1_1_1")).build());
final Node node2 = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node2").setNodeId(NodeId.from("node2")).build());
final Node child2 = createNode(CreateNodeParams.create().parent(node.path()).name("child2").setNodeId(NodeId.from("child2")).build());
final Node child2_1 = createNode(CreateNodeParams.create().parent(child2.path()).name("child2_1").setNodeId(NodeId.from("child2_1")).build());
pushNodes(NodeIds.from(node.id(), node2.id(), child1.id(), child1_1.id(), child1_1_1.id(), child2.id(), child2_1.id()), WS_OTHER);
renameNode(node, "node1-renamed");
renameNode(child1, "child1-renamed");
renameNode(child1_1, "child1_1-renamed");
renameNode(child1_1_1, "child1_1_1-renamed");
renameNode(node2, "node2-renamed");
renameNode(child2, "child2-renamed");
renameNode(child2_1, "child2_1-renamed");
final PushNodesResult result = pushNodes(NodeIds.from(child1_1_1.id(), child1_1.id(), node.id(), child2_1.id(), node2.id(), child1.id(), child2.id()), WS_OTHER);
assertEquals(7, result.getSuccessful().getSize());
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method only_selected_node_pushed.
@Test
public void only_selected_node_pushed() throws Exception {
final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build());
createNode(CreateNodeParams.create().parent(node.path()).name("my-child").build());
createNode(CreateNodeParams.create().parent(node.path()).name("my-child2").build());
final PushNodesResult result = pushNodes(NodeIds.from(node.id()), WS_OTHER);
assertEquals(1, result.getSuccessful().getSize());
final FindNodesByQueryResult allNodesInOther = ctxOther().callWith(() -> FindNodesByQueryCommand.create().query(NodeQuery.create().build()).indexServiceInternal(this.indexServiceInternal).searchService(this.searchService).storageService(this.storageService).build().execute());
assertEquals(2L, allNodesInOther.getTotalHits());
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesResultMapperTest method single_deleted.
@Test
public void single_deleted() throws Exception {
final PushNodesResult result = PushNodesResult.create().build();
final JsonMapGenerator jsonGenerator = new JsonMapGenerator();
new PushNodesResultMapper(result, NodeIds.from("a")).serialize(jsonGenerator);
assertJson("nodeResult/single_deleted.json", jsonGenerator);
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesResultMapperTest method single_successful.
@Test
public void single_successful() throws Exception {
final PushNodesResult result = PushNodesResult.create().addSuccess(createEntry("a")).build();
final JsonMapGenerator jsonGenerator = new JsonMapGenerator();
new PushNodesResultMapper(result, NodeIds.empty()).serialize(jsonGenerator);
assertJson("nodeResult/single_successful.json", jsonGenerator);
}
Aggregations