Search in sources :

Example 16 with ResolveSyncWorkResult

use of com.enonic.xp.node.ResolveSyncWorkResult in project xp by enonic.

the class ResolveSyncWorkCommandTest method reference_to_another_branch_with_another_branch_reference.

/*
    - Node1
      - Node1_1 -> Ref2_1_1
    - Node2 -> Ref3
      - Node2_1
        - Node2_1_1
    - Node3 -> Ref:2_1
  */
@Test
public void reference_to_another_branch_with_another_branch_reference() throws Exception {
    final Node node1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).name("node1").build());
    final PropertyTree node1_1_data = new PropertyTree();
    node1_1_data.addReference("myRef", Reference.from("node2_1_1"));
    final Node node1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1_1")).parent(node1.path()).name("node1_1").data(node1_1_data).build());
    final PropertyTree node2_data = new PropertyTree();
    node2_data.addReference("myRef", Reference.from("node3"));
    final Node node2 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2")).parent(NodePath.ROOT).name("node2").data(node2_data).build());
    final Node node2_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2_1")).parent(node2.path()).name("node2_1").build());
    final Node node2_1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2_1_1")).parent(node2_1.path()).name("node2_1_1").build());
    final PropertyTree node3_data = new PropertyTree();
    node1_1_data.addReference("myRef", Reference.from("node2_1"));
    final Node node3 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node3")).parent(NodePath.ROOT).name("node3").data(node3_data).build());
    final ResolveSyncWorkResult result = ResolveSyncWorkCommand.create().includeChildren(true).nodeId(node1.id()).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
    assertNodes(result, ExpectedNodes.create().implicit(node1.id()).child(node1_1.id()).referred(node2_1_1.id(), node3.id()).parent(node2_1.id(), node2.id()));
}
Also used : Node(com.enonic.xp.node.Node) PropertyTree(com.enonic.xp.data.PropertyTree) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 17 with ResolveSyncWorkResult

use of com.enonic.xp.node.ResolveSyncWorkResult in project xp by enonic.

the class ResolveSyncWorkCommandTest method ignore_nodes_without_diff.

@Test
public void ignore_nodes_without_diff() throws Exception {
    final Node node1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).name("node1").build());
    final Node node1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1_1")).parent(node1.path()).name("node1_1").build());
    final Node node2 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2")).parent(NodePath.ROOT).name("node2").build());
    final Node node2_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2_1")).parent(node2.path()).name("node2_1").build());
    final Node node3 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node3")).parent(NodePath.ROOT).name("node3").build());
    pushNodes(WS_OTHER, node1.id(), node2.id(), node3.id());
    final ResolveSyncWorkResult result = ResolveSyncWorkCommand.create().includeChildren(true).nodeId(getNodeByPath(NodePath.ROOT).id()).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
    assertEquals(3, result.getSize());
}
Also used : Node(com.enonic.xp.node.Node) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 18 with ResolveSyncWorkResult

use of com.enonic.xp.node.ResolveSyncWorkResult in project xp by enonic.

the class ResolveSyncWorkCommandTest method detect_children_marked_for_deletion.

@Test
public void detect_children_marked_for_deletion() throws Exception {
    final Node node1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).name("node1").build());
    final Node node1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1_1")).parent(node1.path()).name("node1_1").build());
    final Node node2 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2")).parent(NodePath.ROOT).name("node2").build());
    final Node node2_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2_1")).parent(node2.path()).name("node2_1").build());
    final Node node3 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node3")).parent(NodePath.ROOT).name("node3").build());
    pushNodes(WS_OTHER, node1.id(), node1_1.id(), node2.id(), node2_1.id(), node3.id());
    markAsDelete(node2_1.id());
    markAsDelete(node3.id());
    final ResolveSyncWorkResult result = ResolveSyncWorkCommand.create().nodeId(ROOT_UUID).includeChildren(true).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
    assertEquals(3, result.getSize());
}
Also used : Node(com.enonic.xp.node.Node) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 19 with ResolveSyncWorkResult

use of com.enonic.xp.node.ResolveSyncWorkResult in project xp by enonic.

the class ResolveSyncWorkCommandTest method exclude_all.

@Test
public void exclude_all() {
    createS1S2Tree();
    refresh();
    ResolveSyncWorkResult result = resolveSyncWorkResult(NodeId.from("s1"), NodeIds.from("s1", "a1", "a2", "a2_1", "a2_1_1", "b2_1", "b2", "s2"), true);
    assertEquals(0, result.getNodeComparisons().getSize());
}
Also used : ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 20 with ResolveSyncWorkResult

use of com.enonic.xp.node.ResolveSyncWorkResult in project xp by enonic.

the class ResolveSyncWorkCommandTest method do_publish_new_dependencies_of_moved_parent.

@Test
public void do_publish_new_dependencies_of_moved_parent() throws Exception {
    createS1S2Tree();
    pushAllNodesInS1S2Tree();
    updateNode("a2_1_1");
    renameNode("a2_1", "newName");
    createNode(NodePath.ROOT, "s3");
    // Update parent node with new reference
    updateNode(UpdateNodeParams.create().id(NodeId.from("a2_1")).editor((node) -> {
        node.data.addReference("newRef", Reference.from("s3"));
    }).build());
    updateNode("b2_1");
    final ResolveSyncWorkResult result = resolveSyncWorkResult("a2_1_1");
    assertNodes(result, ExpectedNodes.create().parent("a2_1").referred("s3").implicit("a2_1_1"));
}
Also used : ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Aggregations

ResolveSyncWorkResult (com.enonic.xp.node.ResolveSyncWorkResult)44 Test (org.junit.jupiter.api.Test)39 Node (com.enonic.xp.node.Node)14 PropertyTree (com.enonic.xp.data.PropertyTree)3 NodeId (com.enonic.xp.node.NodeId)3 ContentId (com.enonic.xp.content.ContentId)2 NodeIds (com.enonic.xp.node.NodeIds)2 Stopwatch (com.google.common.base.Stopwatch)2 Disabled (org.junit.jupiter.api.Disabled)2 Branch (com.enonic.xp.branch.Branch)1 CompareContentResults (com.enonic.xp.content.CompareContentResults)1 CompareStatus (com.enonic.xp.content.CompareStatus)1 ContentIds (com.enonic.xp.content.ContentIds)1 ResolveSyncWorkResultMapper (com.enonic.xp.lib.node.mapper.ResolveSyncWorkResultMapper)1 NodeComparison (com.enonic.xp.node.NodeComparison)1 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)1 PushNodesResult (com.enonic.xp.node.PushNodesResult)1 SyncWorkResolverParams (com.enonic.xp.node.SyncWorkResolverParams)1 JsonMapGenerator (com.enonic.xp.script.serializer.JsonMapGenerator)1 Preconditions (com.google.common.base.Preconditions)1