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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations