Search in sources :

Example 6 with NodeVersionQueryResult

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());
}
Also used : Node(com.enonic.xp.node.Node) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 7 with NodeVersionQueryResult

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());
}
Also used : Node(com.enonic.xp.node.Node) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 8 with NodeVersionQueryResult

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);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) RepositoryIds(com.enonic.xp.repository.RepositoryIds) BranchDumpResult(com.enonic.xp.dump.BranchDumpResult) UpgradeListener(com.enonic.xp.upgrade.UpgradeListener) Version(com.enonic.xp.util.Version) RenameNodeCommand(com.enonic.xp.repo.impl.node.RenameNodeCommand) Branch(com.enonic.xp.branch.Branch) NodeHelper(com.enonic.xp.repo.impl.node.NodeHelper) NodeCommitId(com.enonic.xp.node.NodeCommitId) RepositoryId(com.enonic.xp.repository.RepositoryId) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ContextAccessor(com.enonic.xp.context.ContextAccessor) ContextBuilder(com.enonic.xp.context.ContextBuilder) URI(java.net.URI) Bundle(org.osgi.framework.Bundle) SystemConstants(com.enonic.xp.security.SystemConstants) Path(java.nio.file.Path) BinaryReference(com.enonic.xp.util.BinaryReference) FileDumpReader(com.enonic.xp.repo.impl.dump.reader.FileDumpReader) Pre5ContentConstants(com.enonic.xp.repo.impl.dump.upgrade.obsoletemodel.pre5.Pre5ContentConstants) ImmutableMap(com.google.common.collect.ImmutableMap) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) Assertions.assertIterableEquals(org.junit.jupiter.api.Assertions.assertIterableEquals) Predicate(java.util.function.Predicate) Instant(java.time.Instant) AccessControlList(com.enonic.xp.security.acl.AccessControlList) BundleContext(org.osgi.framework.BundleContext) NodeId(com.enonic.xp.node.NodeId) RenameNodeParams(com.enonic.xp.node.RenameNodeParams) CreateRepositoryParams(com.enonic.xp.repository.CreateRepositoryParams) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) List(java.util.List) Repositories(com.enonic.xp.repository.Repositories) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) NodeVersion(com.enonic.xp.node.NodeVersion) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) NodeCommitQuery(com.enonic.xp.node.NodeCommitQuery) SystemDumpParams(com.enonic.xp.dump.SystemDumpParams) RepositoryConstants(com.enonic.xp.repository.RepositoryConstants) SystemLoadResult(com.enonic.xp.dump.SystemLoadResult) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) Repository(com.enonic.xp.repository.Repository) Mockito.mock(org.mockito.Mockito.mock) ChildOrder(com.enonic.xp.index.ChildOrder) RefreshMode(com.enonic.xp.node.RefreshMode) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) NodeVersionQuery(com.enonic.xp.node.NodeVersionQuery) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ContentConstants(com.enonic.xp.content.ContentConstants) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) SystemDumpListener(com.enonic.xp.dump.SystemDumpListener) GetActiveNodeVersionsParams(com.enonic.xp.node.GetActiveNodeVersionsParams) Node(com.enonic.xp.node.Node) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) IndexConfig(com.enonic.xp.index.IndexConfig) NodeCommitQueryResult(com.enonic.xp.node.NodeCommitQueryResult) TreeSet(java.util.TreeSet) RepoLoadResult(com.enonic.xp.dump.RepoLoadResult) GetActiveNodeVersionsResult(com.enonic.xp.node.GetActiveNodeVersionsResult) NodeVersionIds(com.enonic.xp.node.NodeVersionIds) ImmutableList(com.google.common.collect.ImmutableList) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeVersionId(com.enonic.xp.node.NodeVersionId) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) RepoDumpResult(com.enonic.xp.dump.RepoDumpResult) StreamSupport(java.util.stream.StreamSupport) PropertyPath(com.enonic.xp.data.PropertyPath) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) PropertyTree(com.enonic.xp.data.PropertyTree) DumpUpgradeResult(com.enonic.xp.dump.DumpUpgradeResult) AttachedBinaries(com.enonic.xp.node.AttachedBinaries) InternalContext(com.enonic.xp.repo.impl.InternalContext) PropertySet(com.enonic.xp.data.PropertySet) NodePath(com.enonic.xp.node.NodePath) SystemLoadListener(com.enonic.xp.dump.SystemLoadListener) Mockito.when(org.mockito.Mockito.when) Branches(com.enonic.xp.branch.Branches) SystemDumpUpgradeParams(com.enonic.xp.dump.SystemDumpUpgradeParams) UpdateRepositoryEntryParams(com.enonic.xp.repo.impl.repository.UpdateRepositoryEntryParams) GetNodeVersionsParams(com.enonic.xp.node.GetNodeVersionsParams) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) AtomicLong(java.util.concurrent.atomic.AtomicLong) Mockito(org.mockito.Mockito) SystemDumpResult(com.enonic.xp.dump.SystemDumpResult) NodeName(com.enonic.xp.node.NodeName) Reference(com.enonic.xp.util.Reference) SystemLoadParams(com.enonic.xp.dump.SystemLoadParams) DumpMeta(com.enonic.xp.repo.impl.dump.model.DumpMeta) VersionsLoadResult(com.enonic.xp.dump.VersionsLoadResult) NodeIds(com.enonic.xp.node.NodeIds) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) BinaryReference(com.enonic.xp.util.BinaryReference) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 9 with NodeVersionQueryResult

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())));
}
Also used : GetActiveNodeVersionsResult(com.enonic.xp.node.GetActiveNodeVersionsResult) Branch(com.enonic.xp.branch.Branch) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) Node(com.enonic.xp.node.Node) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 10 with NodeVersionQueryResult

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()));
}
Also used : NodeVersionQuery(com.enonic.xp.node.NodeVersionQuery) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult)

Aggregations

NodeVersionQueryResult (com.enonic.xp.node.NodeVersionQueryResult)22 Node (com.enonic.xp.node.Node)12 Test (org.junit.jupiter.api.Test)11 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)9 NodeVersionQuery (com.enonic.xp.node.NodeVersionQuery)8 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)8 NodeId (com.enonic.xp.node.NodeId)5 Instant (java.time.Instant)4 Branch (com.enonic.xp.branch.Branch)3 GetActiveNodeVersionsResult (com.enonic.xp.node.GetActiveNodeVersionsResult)3 NodeVersionsMetadata (com.enonic.xp.node.NodeVersionsMetadata)3 Context (com.enonic.xp.context.Context)2 ContextAccessor (com.enonic.xp.context.ContextAccessor)2 ContextBuilder (com.enonic.xp.context.ContextBuilder)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 GetNodeVersionsParams (com.enonic.xp.node.GetNodeVersionsParams)2 NodeVersionId (com.enonic.xp.node.NodeVersionId)2 InternalContext (com.enonic.xp.repo.impl.InternalContext)2 Repository (com.enonic.xp.repository.Repository)2 RepositoryConstants (com.enonic.xp.repository.RepositoryConstants)2