use of org.alfresco.repo.virtual.ref.Reference 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