use of com.enonic.xp.node.NodeVersionQueryResult in project xp by enonic.
the class DumpServiceImplTest method different_versions_in_different_branches_not_duplicated.
@Test
public void different_versions_in_different_branches_not_duplicated() throws Exception {
final Node node = createNode(NodePath.ROOT, "myNode");
updateNode(node);
this.nodeService.push(NodeIds.from(node.id()), WS_OTHER);
updateNode(node);
updateNode(node);
refresh();
final NodeVersionQueryResult versionsBeforeDump = this.nodeService.findVersions(GetNodeVersionsParams.create().nodeId(node.id()).build());
NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
refresh();
final NodeVersionQueryResult versionsAfterLoad = this.nodeService.findVersions(GetNodeVersionsParams.create().nodeId(node.id()).build());
assertEquals(versionsBeforeDump.getTotalHits(), versionsAfterLoad.getTotalHits());
}
use of com.enonic.xp.node.NodeVersionQueryResult in project xp by enonic.
the class DumpServiceImplTest method same_version_in_different_branches_not_duplicated.
@Test
public void same_version_in_different_branches_not_duplicated() throws Exception {
final Node node = createNode(NodePath.ROOT, "myNode");
this.nodeService.push(NodeIds.from(node.id()), WS_OTHER);
refresh();
final NodeVersionQueryResult versionsBeforeDump = this.nodeService.findVersions(GetNodeVersionsParams.create().nodeId(node.id()).build());
assertEquals(1, versionsBeforeDump.getTotalHits());
NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
refresh();
final NodeVersionQueryResult versionsAfterLoad = this.nodeService.findVersions(GetNodeVersionsParams.create().nodeId(node.id()).build());
versionsAfterLoad.getNodeVersionsMetadata().forEach((e) -> System.out.println(e.getNodeVersionId() + " - " + e.getTimestamp()));
assertEquals(1, versionsAfterLoad.getTotalHits());
}
use of com.enonic.xp.node.NodeVersionQueryResult in project xp by enonic.
the class DumpServiceImplTest method binaries_in_versions.
@Test
public void binaries_in_versions() throws Exception {
final PropertyTree data = new PropertyTree();
final BinaryReference binaryRef = BinaryReference.from("binaryRef");
data.addBinaryReference("myBinary", binaryRef);
final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("myNode").data(data).attachBinary(binaryRef, ByteSource.wrap("this is binary data".getBytes())).build());
final BinaryReference binaryRef2 = BinaryReference.from("anotherBinary");
final Node updatedNode = updateNode(UpdateNodeParams.create().id(node.id()).editor(n -> n.data.setBinaryReference("myBinary", binaryRef2)).attachBinary(binaryRef2, ByteSource.wrap("anotherBinary".getBytes())).build());
NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
final NodeVersionQueryResult versions = this.nodeService.findVersions(GetNodeVersionsParams.create().nodeId(node.id()).build());
assertEquals(2, versions.getHits());
verifyBinaries(node, updatedNode, versions);
}
use of com.enonic.xp.node.NodeVersionQueryResult in project xp by enonic.
the class DumpServiceImplTest method active_versions_in_versions_list.
@Test
public void active_versions_in_versions_list() throws Exception {
final Node node = createNode(NodePath.ROOT, "myNode");
this.nodeService.push(NodeIds.from(node.id()), WS_OTHER);
updateNode(node);
refresh();
NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
refresh();
final GetActiveNodeVersionsResult activeVersions = this.nodeService.getActiveVersions(GetActiveNodeVersionsParams.create().branches(Branches.from(WS_DEFAULT, WS_OTHER)).nodeId(node.id()).build());
final ImmutableMap<Branch, NodeVersionMetadata> activeVersionsMap = activeVersions.getNodeVersions();
final NodeVersionQueryResult versionsAfterLoad = this.nodeService.findVersions(GetNodeVersionsParams.create().nodeId(node.id()).build());
activeVersionsMap.values().forEach(key -> assertTrue(versionsAfterLoad.getNodeVersionsMetadata().getAllVersionIds().contains(key.getNodeVersionId())));
}
use of com.enonic.xp.node.NodeVersionQueryResult in project xp by enonic.
the class ApplyNodePermissionsCommandTest method assertVersions.
private void assertVersions(final Node node) {
final NodeVersionQuery query = NodeVersionQuery.create().size(100).from(0).nodeId(node.id()).addOrderBy(FieldOrderExpr.create(VersionIndexPath.TIMESTAMP, OrderExpr.Direction.DESC)).build();
final NodeVersionQueryResult versions = FindNodeVersionsCommand.create().query(query).searchService(this.searchService).build().execute();
assertEquals(2, versions.getHits());
final Iterator<NodeVersionMetadata> iterator = versions.getNodeVersionsMetadata().iterator();
assertTrue(iterator.next().getTimestamp().isAfter(iterator.next().getTimestamp()));
}
Aggregations