use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RmSiteTypeUnitTest method testAddStandardFilePlanTypeToDODRmSite.
/**
* Given that we try to add one rma:filePlan to DOD rm site,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testAddStandardFilePlanTypeToDODRmSite() {
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_DOD_5015_SITE, true);
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);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN);
ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RmSiteTypeUnitTest method testAddOneDODFilePlanTypeToRmSite.
/**
* Given that we try to add one dod:filePlan to rm site,
* Then operation is successful.
*/
@Test
public void testAddOneDODFilePlanTypeToRmSite() {
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);
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);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class UnfiledRecordFolderTypeUnitTest method testAddContentTypeToUnfiledRecordFolder.
/**
* Given that we try to add "cm:content" sub-type to unfiled record folder,
* Then the operation is successful.
*/
@Test
public void testAddContentTypeToUnfiledRecordFolder() {
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(true);
when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
NodeRef unfiledRecordFolder = generateNodeRef(TYPE_UNFILED_RECORD_FOLDER, true);
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
when(mockedChildAssoc.getParentRef()).thenReturn(unfiledRecordFolder);
unfiledRecordFolderType.onCreateChildAssociation(mockedChildAssoc, true);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class HoldServiceImplUnitTest method getHeldWithResults.
@Test
public void getHeldWithResults() {
// setup record folder in hold
List<ChildAssociationRef> holds = new ArrayList<ChildAssociationRef>(1);
holds.add(new ChildAssociationRef(ASSOC_FROZEN_RECORDS, hold, ASSOC_FROZEN_RECORDS, recordFolder, true, 1));
doReturn(holds).when(mockedNodeService).getChildAssocs(hold, ASSOC_FROZEN_RECORDS, RegexQNamePattern.MATCH_ALL);
List<NodeRef> list = holdService.getHeld(hold);
assertEquals(1, list.size());
assertEquals(recordFolder, list.get(0));
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class HoldServiceImplUnitTest method createHold.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void createHold() {
// setup node service interactions
when(mockedNodeService.createNode(eq(holdContainer), eq(ContentModel.ASSOC_CONTAINS), any(QName.class), eq(TYPE_HOLD), any(Map.class))).thenReturn(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, holdContainer, generateQName(), hold));
// create hold
NodeRef newHold = holdService.createHold(filePlan, HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION);
assertNotNull(newHold);
assertEquals(TYPE_HOLD, mockedNodeService.getType(newHold));
assertEquals(hold, newHold);
// check the node service interactions
ArgumentCaptor<Map> propertyMapCaptor = ArgumentCaptor.forClass(Map.class);
ArgumentCaptor<QName> assocNameCaptor = ArgumentCaptor.forClass(QName.class);
verify(mockedNodeService).createNode(eq(holdContainer), eq(ContentModel.ASSOC_CONTAINS), assocNameCaptor.capture(), eq(TYPE_HOLD), propertyMapCaptor.capture());
// check property map
Map<QName, Serializable> propertyMap = (Map<QName, Serializable>) propertyMapCaptor.getValue();
assertNotNull(propertyMap);
assertEquals(3, propertyMap.size());
assertTrue(propertyMap.containsKey(ContentModel.PROP_NAME));
assertEquals(HOLD_NAME, propertyMap.get(ContentModel.PROP_NAME));
assertTrue(propertyMap.containsKey(ContentModel.PROP_DESCRIPTION));
assertEquals(HOLD_DESCRIPTION, propertyMap.get(ContentModel.PROP_DESCRIPTION));
assertTrue(propertyMap.containsKey(PROP_HOLD_REASON));
assertEquals(HOLD_REASON, propertyMap.get(PROP_HOLD_REASON));
// check assoc name
assertNotNull(assocNameCaptor.getValue());
assertEquals(NamespaceService.CONTENT_MODEL_1_0_URI, assocNameCaptor.getValue().getNamespaceURI());
assertEquals(HOLD_NAME, assocNameCaptor.getValue().getLocalName());
}
Aggregations