use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class ImportNodeCommandTest method created_nodes_with_id_and_timestamp_should_be_equal.
@Test
public void created_nodes_with_id_and_timestamp_should_be_equal() throws Exception {
ctxDefault().callWith(() -> importNode(Node.create().id(NodeId.from("abc")).name("myNode").parentPath(NodePath.ROOT).data(new PropertyTree()).timestamp(Instant.parse("2014-01-01T10:00:00Z")).build()));
ctxOther().callWith(() -> importNode(Node.create().id(NodeId.from("abc")).name("myNode").parentPath(NodePath.ROOT).data(new PropertyTree()).timestamp(Instant.parse("2014-01-01T10:00:00Z")).build()));
final NodeComparison comparison = CompareNodeCommand.create().nodeId(NodeId.from("abc")).target(WS_OTHER).storageService(this.storageService).build().execute();
assertEquals(CompareStatus.EQUAL, comparison.getCompareStatus());
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class UndoPendingDeleteContentCommand method ensureValidParent.
private void ensureValidParent(final NodeComparison nodeComparison) {
final NodePath parentPath = nodeComparison.getSourcePath().getParentPath();
if (ContentNodeHelper.translateNodePathToContentPath(parentPath).isRoot()) {
return;
}
final Node parentNode = this.nodeService.getByPath(parentPath);
if (parentNode == null) {
throw new IllegalArgumentException("Parent with path [" + parentPath + "] does not exists");
}
final NodeComparison parentState = this.nodeService.compare(parentNode.id(), this.params.getTarget());
if (CompareStatus.PENDING_DELETE == parentState.getCompareStatus()) {
removePendingDeleteState(parentState);
}
ensureValidParent(parentState);
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class PushNodeHandlerTest method testExample2.
@Test
public void testExample2() {
Mockito.when(nodeService.resolveSyncWork(Mockito.isA(SyncWorkResolverParams.class))).thenReturn(ResolveSyncWorkResult.create().add(new NodeComparison(createEntry("a"), createEntry("a"), CompareStatus.NEW)).add(new NodeComparison(createEntry("b"), createEntry("b"), CompareStatus.NEW)).add(new NodeComparison(createEntry("c"), createEntry("c"), CompareStatus.NEW)).build());
Mockito.when(nodeService.push(Mockito.isA(NodeIds.class), Mockito.eq(Branch.from("otherBranch")))).thenReturn(PushNodesResult.create().addSuccess(createEntry("a")).addSuccess(createEntry("b")).addSuccess(createEntry("c")).addFailed(createEntry("d"), PushNodesResult.Reason.ACCESS_DENIED).build());
runScript("/lib/xp/examples/node/push-2.js");
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class ResolveSyncWorkResultMapperTest method full.
@Test
public void full() throws Exception {
final ResolveSyncWorkResult result = ResolveSyncWorkResult.create().add(new NodeComparison(createEntry("a"), createEntry("a"), CompareStatus.NEW)).add(new NodeComparison(createEntry("b"), createEntry("b"), CompareStatus.MOVED)).add(new NodeComparison(createEntry("c"), createEntry("c"), CompareStatus.NEWER)).build();
final JsonMapGenerator jsonGenerator = new JsonMapGenerator();
new ResolveSyncWorkResultMapper(result).serialize(jsonGenerator);
assertJson("resolveSyncWork/full.json", jsonGenerator);
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class DiffBranchesHandlerTest method testExample1.
@Test
public void testExample1() {
Mockito.when(nodeService.resolveSyncWork(Mockito.isA(SyncWorkResolverParams.class))).thenReturn(ResolveSyncWorkResult.create().add(new NodeComparison(createEntry("a"), createEntry("a"), CompareStatus.NEW)).add(new NodeComparison(createEntry("b"), createEntry("b"), CompareStatus.MOVED)).add(new NodeComparison(createEntry("c"), createEntry("c"), CompareStatus.OLDER)).build());
runScript("/lib/xp/examples/node/diff-1.js");
}
Aggregations