use of org.alfresco.repo.virtual.ref.GetActualNodeRefMethod in project alfresco-repository by Alfresco.
the class VirtualVersionServiceExtensionTest method testCreateVersion.
@Test
public void testCreateVersion() throws Exception {
ChildAssociationRef contentWithVersionsAssocRef = createContent(node2_1, "ContentWithVersions");
NodeRef contentWithVersionsNodeRef = contentWithVersionsAssocRef.getChildRef();
Reference reference = Reference.fromNodeRef(contentWithVersionsNodeRef);
assertNotNull(reference);
NodeRef actualContentWithVersionsNodeRef = reference.execute(new GetActualNodeRefMethod(environment));
VersionHistory versionHistory = versionService.getVersionHistory(contentWithVersionsNodeRef);
assertNull(versionHistory);
VersionHistory actualVersionHistory = versionService.getVersionHistory(actualContentWithVersionsNodeRef);
assertNull(actualVersionHistory);
Version newVersion = versionService.createVersion(contentWithVersionsNodeRef, null);
NodeRef newVersionNodeRef = newVersion.getVersionedNodeRef();
assertNotNull(Reference.fromNodeRef(newVersionNodeRef));
versionHistory = versionService.getVersionHistory(newVersionNodeRef);
assertNotNull(versionHistory);
Collection<Version> allVersions = versionHistory.getAllVersions();
assertEquals(1, allVersions.size());
actualVersionHistory = versionService.getVersionHistory(actualContentWithVersionsNodeRef);
assertNotNull(actualVersionHistory);
Collection<Version> allActualVersions = versionHistory.getAllVersions();
assertEquals(1, allActualVersions.size());
Version actualVersion = actualVersionHistory.getHeadVersion();
NodeRef newActualVersionNodeRef = actualVersion.getVersionedNodeRef();
assertNull(Reference.fromNodeRef(newActualVersionNodeRef));
assertEquals(newActualVersionNodeRef, actualContentWithVersionsNodeRef);
}
use of org.alfresco.repo.virtual.ref.GetActualNodeRefMethod in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtensionTest method testCreate_NodeProtocolParent.
@Test
public void testCreate_NodeProtocolParent() throws Exception {
NodeRef assocNode2 = nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "Node2");
NodeRef assocNode2_1 = nodeService.getChildByName(assocNode2, ContentModel.ASSOC_CONTAINS, "Node2_1");
ChildAssociationRef childAssocRef = createContent(assocNode2_1, "Content");
NodeRef node = childAssocRef.getChildRef();
Reference reference = Reference.fromNodeRef(node);
assertNotNull(reference);
assertTrue(reference.getProtocol().equals(Protocols.NODE.protocol));
QName nodeTypeQName = ContentModel.TYPE_THUMBNAIL;
QName assocQName = QName.createQName("cm", "contentThumbnail", environment.getNamespacePrefixResolver());
QName assocTypeQName = RenditionModel.ASSOC_RENDITION;
ChildAssociationRef assoc = nodeService.createNode(node, assocTypeQName, assocQName, nodeTypeQName);
NodeRef virtualRenditionNode = assoc.getChildRef();
NodeRef virtualRenditionParent = assoc.getParentRef();
assertEquals(node, virtualRenditionParent);
Reference child = Reference.fromNodeRef(virtualRenditionNode);
Reference parent = Reference.fromNodeRef(virtualRenditionParent);
NodeRef physicalRenditionNode = child.execute(new GetActualNodeRefMethod(environment));
NodeRef physicalRenditionParent = parent.execute(new GetActualNodeRefMethod(environment));
List<ChildAssociationRef> refs = nodeService.getChildAssocs(physicalRenditionParent);
// the association exists for the physical nodes
assertEquals(physicalRenditionNode, refs.get(0).getChildRef());
List<ChildAssociationRef> virtualRefs = nodeService.getChildAssocs(virtualRenditionParent);
// the association exists for the virtual nodes
assertEquals(physicalRenditionNode, virtualRefs.get(0).getChildRef());
}
Aggregations