Search in sources :

Example 1 with PushNodesResult

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

the class PushNodesResultMapperTest method single_failed.

@Test
public void single_failed() throws Exception {
    final PushNodesResult result = PushNodesResult.create().addFailed(createEntry("a"), PushNodesResult.Reason.ACCESS_DENIED).build();
    final JsonMapGenerator jsonGenerator = new JsonMapGenerator();
    new PushNodesResultMapper(result, NodeIds.empty()).serialize(jsonGenerator);
    assertJson("nodeResult/single_failed.json", jsonGenerator);
}
Also used : PushNodesResult(com.enonic.xp.node.PushNodesResult) JsonMapGenerator(com.enonic.xp.script.serializer.JsonMapGenerator) Test(org.junit.jupiter.api.Test)

Example 2 with PushNodesResult

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

the class PublishContentCommand method doPushNodes.

private void doPushNodes(final NodeIds nodesToPush) {
    if (nodesToPush.isEmpty()) {
        return;
    }
    SetPublishInfoCommand.create(this).nodeIds(nodesToPush).contentPublishInfo(contentPublishInfo).pushListener(publishContentListener).build().execute();
    final PushNodesResult pushNodesResult = nodeService.push(nodesToPush, this.target, this);
    commitPushedNodes(pushNodesResult.getSuccessful());
    this.resultBuilder.setFailed(ContentNodeHelper.toContentIds(NodeIds.from(pushNodesResult.getFailed().stream().map(failed -> failed.getNodeBranchEntry().getNodeId()).collect(Collectors.toList()))));
    this.resultBuilder.setPushed(ContentNodeHelper.toContentIds(NodeIds.from(pushNodesResult.getSuccessful().getKeys())));
}
Also used : PushNodesResult(com.enonic.xp.node.PushNodesResult)

Example 3 with PushNodesResult

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

the class PushNodesCommandTest method push_rename_push.

@Test
public void push_rename_push() throws Exception {
    final Node parent = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("parent").setNodeId(NodeId.from("parent")).build());
    final Node child1 = createNode(CreateNodeParams.create().parent(parent.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());
    pushNodes(NodeIds.from(parent.id(), child1.id()), WS_OTHER);
    renameNode(parent, "parent-renamed");
    renameNode(child1, "child1-renamed");
    renameNode(child1_1, "child1_1-renamed");
    final PushNodesResult result = pushNodes(NodeIds.from(parent.id(), child1.id()), WS_OTHER);
    assertEquals(2, result.getSuccessful().getSize());
}
Also used : Node(com.enonic.xp.node.Node) PushNodesResult(com.enonic.xp.node.PushNodesResult) Test(org.junit.jupiter.api.Test)

Example 4 with PushNodesResult

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

the class PushNodesCommandTest method rename_to_name_already_there_but_renamed_in_same_push.

@Test
public void rename_to_name_already_there_but_renamed_in_same_push() throws Exception {
    final Node a = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("a").setNodeId(NodeId.from("a")).build());
    final Node b = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("b").setNodeId(NodeId.from("b")).build());
    pushNodes(NodeIds.from(a.id()), WS_OTHER);
    renameNode(a.id(), "a_old");
    renameNode(b.id(), "a");
    final PushNodesResult result = pushNodes(NodeIds.from(b.id(), a.id()), WS_OTHER);
    assertEquals(0, result.getFailed().size());
    assertEquals(2, result.getSuccessful().getSize());
}
Also used : Node(com.enonic.xp.node.Node) PushNodesResult(com.enonic.xp.node.PushNodesResult) Test(org.junit.jupiter.api.Test)

Example 5 with PushNodesResult

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

the class PushNodesCommandTest method ensure_order_for_publish_with_children.

@Test
public void ensure_order_for_publish_with_children() throws Exception {
    final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build());
    final Node child1 = createNode(CreateNodeParams.create().parent(node.path()).name("my-child").build());
    final Node child2 = createNode(CreateNodeParams.create().parent(node.path()).name("my-child2").build());
    final Node child1_1 = createNode(CreateNodeParams.create().parent(node.path()).name("my-child1_1").build());
    final Node child2_1 = createNode(CreateNodeParams.create().parent(node.path()).name("my-child2_1").build());
    final PushNodesResult result = pushNodes(NodeIds.from(child2_1.id(), child1_1.id(), child1.id(), child2.id(), node.id()), WS_OTHER);
    assertTrue(result.getFailed().isEmpty());
    ctxOther().runWith(() -> {
        assertNotNull(getNodeById(node.id()));
        assertNotNull(getNodeById(child1.id()));
        assertNotNull(getNodeById(child1_1.id()));
        assertNotNull(getNodeById(child2.id()));
        assertNotNull(getNodeById(child2_1.id()));
    });
}
Also used : Node(com.enonic.xp.node.Node) PushNodesResult(com.enonic.xp.node.PushNodesResult) Test(org.junit.jupiter.api.Test)

Aggregations

PushNodesResult (com.enonic.xp.node.PushNodesResult)17 Test (org.junit.jupiter.api.Test)15 Node (com.enonic.xp.node.Node)11 JsonMapGenerator (com.enonic.xp.script.serializer.JsonMapGenerator)4 PushNodesResultMapper (com.enonic.xp.lib.node.mapper.PushNodesResultMapper)1 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)1 NodeIds (com.enonic.xp.node.NodeIds)1 ResolveSyncWorkResult (com.enonic.xp.node.ResolveSyncWorkResult)1 Stopwatch (com.google.common.base.Stopwatch)1 Disabled (org.junit.jupiter.api.Disabled)1