Search in sources :

Example 36 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method publish_duplicate_of_original_do_not_publish_original.

/*
         - S1 (New)
           - A1 (New)
           - A2 (New)
              - A2_1 - Ref:B2_1 (New)
                - A2_1_1
         - S2 (New)
           - B1 (New)
           - B2 (New)
              - B2_1 (New)
         - S1d (New)
           - A1d (New)
           - A2d (New)
             - A2_1d - Ref:B2_1 (New)
         */
@Test
public void publish_duplicate_of_original_do_not_publish_original() throws Exception {
    createS1S2Tree();
    final Node s1d = duplicateNode(getNodeById(NodeId.from("s1")));
    getNodeByPath(NodePath.create("/s1-copy/a1").build());
    getNodeByPath(NodePath.create("/s1-copy/a2").build());
    getNodeByPath(NodePath.create("/s1-copy/a2/a2_1").build());
    refresh();
    final ResolveSyncWorkResult result = resolveSyncWorkResult(s1d.id(), true);
    assertEquals(8, result.getSize());
}
Also used : Node(com.enonic.xp.node.Node) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 37 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method reference_moved_must_be_pushed.

/*
   - S1 (E)
      - A1 (E)
      - A2 (M)
        - A2_1 - Ref:B2_1 (M)
   - S2 (Moved)
      - B1 (E)
      - B2 (E)
        - B2_1 (Moved to S2)

     Resolve A2_1
  */
@Test
public void reference_moved_must_be_pushed() throws Exception {
    createS1S2Tree();
    pushAllNodesInS1S2Tree();
    updateNode("a2_1");
    moveNode("b2_1", NodePath.create("/s2").build(), "b2_1");
    final ResolveSyncWorkResult result = resolveSyncWorkResult("a2_1");
    assertEquals(2, result.getSize());
}
Also used : ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 38 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method resolveDependenciesOfMovedNodes2.

/**
 * 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 node1_1_1 and two of its parents 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 resolveDependenciesOfMovedNodes2() {
    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.id(), true);
    final ResolveSyncWorkResult resultChildrenNotIncluded = resolveSyncWorkResult(node1_1_1.id(), false);
    assertEquals(4, resultChildrenIncluded.getSize());
    // Should be 4 IMO. Has been discussed internally and left as it is for now
    assertEquals(3, resultChildrenNotIncluded.getSize());
}
Also used : Node(com.enonic.xp.node.Node) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 39 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method exclude_child_with_refs.

/*
        - S1 (New)
          - A1 (New)
          - A2 (New)
             - A2_1 - Ref:B2_1 (New)
        - S2 (New)
          - B1 (New)
          - B2 (New)
             - B2_1 (New)
        - S1d (New)
          - A1d (New)
          - A2d (New)
            - A2_1d - Ref:B2_1 (New)
        */
@Test
public void exclude_child_with_refs() {
    createS1S2Tree();
    refresh();
    final ResolveSyncWorkResult result = resolveSyncWorkResult(NodeId.from("s1"), NodeIds.from("a2_1_1", "a2_1"), true);
    assertNodes(result, ExpectedNodes.create().implicit("s1").child("a1", "a2"));
}
Also used : ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 40 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method publish_root_all_new.

/*
        - S1 (N)
            - A1 (N)
            - A2 (N)
                - A2_1 - Ref:B2_1 (N)
        - S2 (N)
            - B1 (N)
            - B2 (N)
                - B2_1 (N)

        Resolve: Root
     */
@Test
public void publish_root_all_new() {
    createS1S2Tree();
    final ResolveSyncWorkResult results = resolveSyncWorkResult(getNodeByPath(NodePath.ROOT).id(), true);
    assertEquals(10, results.getSize());
/*
        final String rootNodeId = RootNode.UUID.toString();
        assertRequested( requests, rootNodeId );
        assertChildOf( requests, "s1", rootNodeId );
        assertChildOf( requests, "a1", "s1" );
        assertChildOf( requests, "a2", "s1" );
        assertChildOf( requests, "a2_1", "a2" );
        assertChildOf( requests, "s2", rootNodeId );
        assertChildOf( requests, "b1", "s2" );
        assertChildOf( requests, "b2", "s2" );
        assertChildOf( requests, "b2_1", "b2" );
        */
}
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