Search in sources :

Example 16 with PushNodesResult

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

the class PushNodesResultMapperTest method complex.

@Test
public void complex() throws Exception {
    final PushNodesResult result = PushNodesResult.create().addSuccess(createEntry("a")).addSuccess(createEntry("b")).addSuccess(createEntry("c")).addFailed(createEntry("d"), PushNodesResult.Reason.ACCESS_DENIED).addFailed(createEntry("e"), PushNodesResult.Reason.PARENT_NOT_FOUND).addFailed(createEntry("f"), PushNodesResult.Reason.PARENT_NOT_FOUND).build();
    final JsonMapGenerator jsonGenerator = new JsonMapGenerator();
    new PushNodesResultMapper(result, NodeIds.from("g", "h", "i")).serialize(jsonGenerator);
    assertJson("nodeResult/full.json", jsonGenerator);
}
Also used : PushNodesResult(com.enonic.xp.node.PushNodesResult) JsonMapGenerator(com.enonic.xp.script.serializer.JsonMapGenerator) Test(org.junit.jupiter.api.Test)

Example 17 with PushNodesResult

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

the class PushNodeHandler method execute.

@Override
public Object execute() {
    final NodeIds.Builder toBePushed = NodeIds.create();
    final NodeIds.Builder toBeDeleted = NodeIds.create();
    final NodeIds nodeIds = getNodeIds();
    if (resolve) {
        doResolve(nodeIds, toBePushed, toBeDeleted);
    } else {
        toBePushed.addAll(getNodeIds());
    }
    final PushNodesResult push = this.nodeService.push(toBePushed.build(), targetBranch);
    final NodeIds deletedNodes = doDelete(toBeDeleted);
    return new PushNodesResultMapper(push, deletedNodes);
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) PushNodesResult(com.enonic.xp.node.PushNodesResult) PushNodesResultMapper(com.enonic.xp.lib.node.mapper.PushNodesResultMapper)

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