use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class CompareNodeCommandTest method status_moved_source.
@Test
public void status_moved_source() throws Exception {
ctxDefault().callWith(this::createDefaultRootNode);
final Node createdNode = ctxDefault().callWith(() -> createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build()));
final Node mySecondNode = ctxDefault().callWith(() -> createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-second-node").build()));
ctxDefault().runWith(() -> doPushNode(WS_OTHER, createdNode));
refresh();
ctxDefault().runWith(() -> MoveNodeCommand.create().id(createdNode.id()).newParent(mySecondNode.path()).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute());
final NodeComparison comparison = ctxDefault().callWith(() -> doCompare(WS_OTHER, createdNode));
assertEquals(CompareStatus.MOVED, comparison.getCompareStatus());
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class CompareNodeCommandTest method status_capital_node_id.
@Test
public void status_capital_node_id() throws Exception {
ctxOther().callWith(this::createDefaultRootNode);
final Node createdNode = ctxOther().callWith(() -> createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").setNodeId(NodeId.from("MyNodeId")).build()));
final NodeComparison comparison = ctxDefault().callWith(() -> doCompare(WS_OTHER, createdNode));
assertEquals(CompareStatus.NEW_TARGET, comparison.getCompareStatus());
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class CompareNodeCommandTest method status_older.
@Test
public void status_older() throws Exception {
ctxDefault().callWith(this::createDefaultRootNode);
final Node createdNode = ctxDefault().callWith(() -> createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build()));
ctxDefault().runWith(() -> doPushNode(WS_OTHER, createdNode));
refresh();
ctxOther().runWith(() -> doUpdateNode(createdNode));
refresh();
final NodeComparison comparison = ctxDefault().callWith(() -> doCompare(WS_OTHER, createdNode));
assertEquals(CompareStatus.OLDER, comparison.getCompareStatus());
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class CompareNodeCommandTest method status_equal.
@Test
public void status_equal() throws Exception {
ctxDefault().callWith(this::createDefaultRootNode);
final Node createdNode = ctxDefault().callWith(() -> createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build()));
ctxDefault().runWith(() -> doPushNode(WS_OTHER, createdNode));
final NodeComparison comparison = ctxDefault().callWith(() -> doCompare(WS_OTHER, createdNode));
assertEquals(CompareStatus.EQUAL, comparison.getCompareStatus());
}
use of com.enonic.xp.node.NodeComparison in project xp by enonic.
the class CompareNodesCommand method execute.
public NodeComparisons execute() {
Set<NodeId> allNodeIds = new HashSet<>();
final Context context = ContextAccessor.current();
final NodeComparisons.Builder builder = NodeComparisons.create();
final NodeBranchEntries sourceVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, InternalContext.from(context));
final NodeBranchEntries targetVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, InternalContext.create(context).branch(this.target).build());
allNodeIds.addAll(sourceVersions.getKeys());
allNodeIds.addAll(targetVersions.getKeys());
for (final NodeId id : allNodeIds) {
final CompareStatus compareStatus = CompareStatusResolver.create().source(sourceVersions.get(id)).target(targetVersions.get(id)).storageService(this.nodeStorageService).build().resolve();
builder.add(new NodeComparison(sourceVersions.get(id), targetVersions.get(id), compareStatus));
}
return builder.build();
}
Aggregations