Search in sources :

Example 11 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method make_missing_parents_references_parents_nodes_included.

/*
    - S1 (New)
     - A1 (New)
     - A2 (New)
         - A2_1 - Ref:B2_1 (New)
           - A2_1_1
    - S2 (New)
     - B1 (New)
     - B2 (New)
         - B2_1 (New)
    */
@Test
public void make_missing_parents_references_parents_nodes_included() {
    createS1S2Tree();
    final ResolveSyncWorkResult result = resolveSyncWorkResult(NodeId.from("a2_1_1"), true);
    assertNodes(result, ExpectedNodes.create().implicit("a2_1_1").parent("a2_1", "a2", "s1").referred("b2_1").parent("b2", "s2"));
}
Also used : ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 12 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method exclude_all_children.

@Test
public void exclude_all_children() {
    createS1S2Tree();
    refresh();
    final NodeIds children = NodeIds.from("a1", "a2", "a2_1", "a2_1_1", "b2_1", "b2", "s2");
    ResolveSyncWorkResult result = resolveSyncWorkResult(NodeId.from("s1"), children, false);
    assertNodes(result, ExpectedNodes.create().implicit("s1"));
    result = resolveSyncWorkResult(NodeId.from("s1"), children, true);
    assertNodes(result, ExpectedNodes.create().implicit("s1"));
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 13 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method resolve_with_include_children_a_2.

/*
         - S1 (New)
          - A1 (New)
          - A2 (New)
              - A2_1 - Ref:B2_1 (New)
                - A2_1_1
         - S2 (New)
          - B1 (New)
          - B2 (New)
              - B2_1 (New)
         Resolve: A1
     */
@Test
public void resolve_with_include_children_a_2() throws Exception {
    createS1S2Tree();
    final ResolveSyncWorkResult result = resolveSyncWorkResult(NodeId.from("a2"), true);
    assertEquals(7, result.getSize());
}
Also used : ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 14 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method resolveDependenciesOfMovedNodes.

/**
 * node2
 * .....|
 * .....node1                                   (Moved)
 * ..........|
 * ..........node1_1                            (Moved)
 * .................|
 * ..................node1_1_1                  (Moved)
 * ...........................|
 * ............................node1_1_1_1      (Moved)
 *
 * <p>
 * Contents created below look like pic above.
 * ResolveSyncWorkCommand will return all four when called both with includeChildren=true and with includeChildren=false
 * 1) FindNodesWithVersionDifferenceCommand will returns only actual nodes that have Moved status (such like node1)...
 * 2) ... though CompareContentCommand will return status Moved for all children of Moved content.
 * 3) When includeChildren=false ResolveSyncWorkCommand will resolve all parents against the passed node.
 * So ResolveSyncWorkCommand will return only "Moved" parents of passed node and passed node itself when includeChildren=false
 */
@Test
public void resolveDependenciesOfMovedNodes() {
    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 node1_1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1_1_1")).parent(node1_1.path()).name("node1_1_1").build());
    final Node node1_1_1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1_1_1_1")).parent(node1_1_1.path()).name("node1_1_1_1").build());
    final Node node2 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2")).parent(NodePath.ROOT).name("node2").build());
    pushNodes(WS_OTHER, node1.id(), node2.id(), node1_1.id(), node1_1_1.id(), node1_1_1_1.id());
    moveNode(node1, node2.path());
    final ResolveSyncWorkResult resultChildrenIncluded = resolveSyncWorkResult(node1_1_1_1.id(), true);
    final ResolveSyncWorkResult resultChildrenNotIncluded = resolveSyncWorkResult(node1_1_1_1.id(), false);
    assertEquals(resultChildrenIncluded.getSize(), 4);
    assertEquals(resultChildrenNotIncluded.getSize(), 4);
}
Also used : Node(com.enonic.xp.node.Node) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 15 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method resolve_with_include_children.

/*
        - S1 (New)
         - A1 (New)
         - A2 (New)
             - A2_1 - Ref:B2_1 (New)
               - A2_1_1
        - S2 (New)
         - B1 (New)
         - B2 (New)
             - B2_1 (New)
        Resolve: S1
    */
@Test
public void resolve_with_include_children() throws Exception {
    createS1S2Tree();
    final ResolveSyncWorkResult result = resolveSyncWorkResult(NodeId.from("s1"), true);
    assertEquals(8, result.getSize());
}
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