Search in sources :

Example 56 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RecordFolderTypeUnitTest method testCreateNonFolderSubTypeOnCommit.

/**
 * Given that we try to add non cm:folder sub-type to a record folder,
 * Then the operation is successful.
 */
@Test
public void testCreateNonFolderSubTypeOnCommit() throws Exception {
    NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
    QName type = AlfMock.generateQName();
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
    when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(false);
    ChildAssociationRef mockedPrimaryParentAssoc = mock(ChildAssociationRef.class);
    when(mockedNodeService.getPrimaryParent(nodeRef)).thenReturn(mockedPrimaryParentAssoc);
    ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
    recordFolderType.onCreateChildAssociationOnCommit(childAssocRef, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 57 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RecordFolderTypeUnitTest method testCreateContent.

/**
 * Given that we try to add cm:content sub-type to a record folder,
 * Then the operation is successful.
 */
public void testCreateContent() throws Exception {
    NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
    QName type = AlfMock.generateQName();
    when(mockedDictionaryService.isSubClass(type, TYPE_CONTENT)).thenReturn(true);
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
    ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
    recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 58 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RmSiteTypeUnitTest method testAddTwoFolderTypeToRmSite.

/**
 * Given that we try to add two cm:folder to rm site,
 * Then operation is successful.
 */
@Test
public void testAddTwoFolderTypeToRmSite() {
    NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
    ArrayList<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
    when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
    // create first folder
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
    ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
    // create second cm:folder
    nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
    mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 59 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RmSiteTypeUnitTest method testAddOneFilePlanTypeToRmSite.

/**
 * Given that we try to add one rma:filePlan to rm site,
 * Then operation is successful.
 */
@Test
public void testAddOneFilePlanTypeToRmSite() {
    NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
    ArrayList<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
    when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN);
    ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FILE_PLAN))).thenReturn(assocs);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 60 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RmSiteTypeUnitTest method testAddMoreThanOneDODFilePlanTypeToRmSite.

/**
 * Given that we try to add more than one dod:filePlan to rm site,
 * Then IntegrityException is thrown.
 */
@Test(expected = IntegrityException.class)
public void testAddMoreThanOneDODFilePlanTypeToRmSite() {
    NodeRef rmSiteNodeRef = generateNodeRef(TYPE_DOD_5015_SITE, true);
    ArrayList<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>();
    SiteInfo mockedSiteInfo = mock(SiteInfo.class);
    when(mockedSiteInfo.getNodeRef()).thenReturn(rmSiteNodeRef);
    when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
    when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
    when(mockedDictionaryService.isSubClass(TYPE_DOD_5015_SITE, TYPE_RM_SITE)).thenReturn(true);
    when(mockedDictionaryService.isSubClass(TYPE_DOD_5015_FILE_PLAN, TYPE_FILE_PLAN)).thenReturn(true);
    rmSiteType.registerFilePlanType(TYPE_DOD_5015_SITE, TYPE_DOD_5015_FILE_PLAN);
    // first dod:filePlan creation
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_DOD_5015_FILE_PLAN);
    ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_DOD_5015_FILE_PLAN))).thenReturn(assocs);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
    // second dod:filePlan creation
    nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_DOD_5015_FILE_PLAN);
    mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
    assocs.add(mockedChildAssoc);
    when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_DOD_5015_FILE_PLAN))).thenReturn(assocs);
    rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Aggregations

ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)260 NodeRef (org.alfresco.service.cmr.repository.NodeRef)204 QName (org.alfresco.service.namespace.QName)110 Test (org.junit.Test)57 HashMap (java.util.HashMap)54 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)53 ArrayList (java.util.ArrayList)52 Serializable (java.io.Serializable)42 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)25 FacesContext (javax.faces.context.FacesContext)22 Map (java.util.Map)19 UserTransaction (javax.transaction.UserTransaction)18 Node (org.alfresco.web.bean.repository.Node)17 Date (java.util.Date)15 StoreRef (org.alfresco.service.cmr.repository.StoreRef)13 NodeService (org.alfresco.service.cmr.repository.NodeService)12 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)12 List (java.util.List)11 StringPropertyValue (org.alfresco.solr.client.StringPropertyValue)11 IOException (java.io.IOException)10