Search in sources :

Example 26 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method not_include_dependencies.

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

Example 27 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommand method execute.

public ResolveSyncWorkResult execute() {
    RefreshCommand.create().indexServiceInternal(this.indexServiceInternal).refreshMode(RefreshMode.ALL).build().execute();
    getAllPossibleNodesToBePublished();
    final ResolveSyncWorkResult result = this.result.build();
    return result;
}
Also used : ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult)

Example 28 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method publish_original_with_duplicate_do_not_publish_duplicate.

/*
     - S1 (New) s
         - 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)

        Duplicate S1, then publish S1
        Should publish S1, A1, A2, A2_1, B2_1, B2, S2
     */
@Test
public void publish_original_with_duplicate_do_not_publish_duplicate() throws Exception {
    createS1S2Tree();
    duplicateNode(getNodeById(NodeId.from("s1")));
    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)

Example 29 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method resolveDependenciesOfMovedNodes3.

/**
 * node1                          (Equal)
 * .....|
 * .....node1_1                   (Equal)
 * node2                          (Equal)
 * .....|
 * .....node1_1_1                 (Moved)
 * ..............|
 * ..............node1_1_1_1      (Moved)
 * <p>
 * Contents created below look like pic above.
 * ResolveSyncWorkCommand will return node1_1_1 for node1_1_1.id() 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 resolveDependenciesOfMovedNodes3() {
    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_1_1, node2.path());
    refresh();
    final ResolveSyncWorkResult resultChildrenIncluded = resolveSyncWorkResult(node1_1_1.id(), true);
    final ResolveSyncWorkResult resultChildrenNotIncluded = resolveSyncWorkResult(node1_1_1.id(), false);
    assertEquals(2, resultChildrenIncluded.getSize());
    // Should be 2 IMO. Has been discussed internally and left as it is for now
    assertEquals(1, resultChildrenNotIncluded.getSize());
}
Also used : Node(com.enonic.xp.node.Node) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 30 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method exclude_empty.

@Test
public void exclude_empty() {
    createS1S2Tree();
    refresh();
    ResolveSyncWorkResult result = resolveSyncWorkResult(NodeId.from("s1"), NodeIds.empty(), false);
    assertEquals(1, result.getSize());
    assertNodes(result, ExpectedNodes.create().implicit("s1"));
    result = resolveSyncWorkResult(NodeId.from("s1"), NodeIds.empty(), 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