use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RecordCategoryTypeUnitTest method testCreateNonAceptedTypes.
/**
* Given that we try to add types different than "rma:recordCategory" and "rma:recordFolder" to a record category,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testCreateNonAceptedTypes() throws Exception {
NodeRef recordCategoryNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_CATEGORY);
QName type = AlfMock.generateQName();
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordCategoryNodeRef, nodeRef);
recordCategoryType.onCreateChildAssociation(childAssocRef, true);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RecordsManagementContainerTypeUnitTest method testAddFolderInRecordCategory.
/**
* Having a record category and a non RM folder node
* When adding a child association between the record category and the folder
* Then the new folder should be converted to a record folder
*/
@Test
public void testAddFolderInRecordCategory() {
NodeRef category = generateNodeRef();
when(mockedNodeService.getType(category)).thenReturn(TYPE_RECORD_CATEGORY);
NodeRef folder = generateNonRmFolderNode();
ChildAssociationRef childAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, category, ContentModel.ASSOC_CONTAINS, folder);
recordManagementContainerType.onCreateChildAssociation(childAssoc, true);
verify(mockedNodeService).setType(folder, TYPE_RECORD_FOLDER);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RecordsManagementContainerTypeUnitTest method testAddFolderInUnfiledRecordFolder.
/**
* Having an unfiled record folder and a non RM folder node
* When adding a child association between the unfiled record folder and the regular folder
* Then the new folder should be converted to a unfiled record folder
*/
@Test
public void testAddFolderInUnfiledRecordFolder() {
NodeRef unfiledRecordFolder = generateNodeRef();
when(mockedNodeService.getType(unfiledRecordFolder)).thenReturn(TYPE_UNFILED_RECORD_FOLDER);
NodeRef folder = generateNonRmFolderNode();
ChildAssociationRef childAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, unfiledRecordFolder, ContentModel.ASSOC_CONTAINS, folder);
recordManagementContainerType.onCreateChildAssociation(childAssoc, true);
verify(mockedNodeService).setType(folder, TYPE_UNFILED_RECORD_FOLDER);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class UnfiledRecordContainerTypeUnitTest method testNonElectronicDocumentTypeToUnfiledRecordContainer.
/**
* Given that we try to add "rma:nonElectronicDocument" sub-type to unfiled record container,
* Then the operation is successful.
*/
@Test
public void testNonElectronicDocumentTypeToUnfiledRecordContainer() {
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
NodeRef unfiledRecordContainer = generateNodeRef(TYPE_UNFILED_RECORD_CONTAINER, true);
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
when(mockedChildAssoc.getParentRef()).thenReturn(unfiledRecordContainer);
unfiledRecordContainerType.onCreateChildAssociation(mockedChildAssoc, true);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RecordServiceImplUnitTest method onCreateChildAssociationExistingRecord.
/**
* Given that an existing record is linked
* When the behaviour is triggered
* Then the record is not stored for later reference in the transaction
*/
@SuppressWarnings("unchecked")
@Test
public void onCreateChildAssociationExistingRecord() {
// standard content node
NodeRef nodeRef = generateCmContent("test.txt");
ChildAssociationRef assoc = generateChildAssociationRef(generateNodeRef(), nodeRef);
doNothing().when(recordService).file(nodeRef);
// doesn't have no content aspect
when(mockedNodeService.hasAspect(nodeRef, ContentModel.ASPECT_NO_CONTENT)).thenReturn(false);
Set<Object> values = mock(HashSet.class);
when(mockedTransactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS)).thenReturn(values);
// trigger behaviour
recordService.onCreateChildAssociation(assoc, false);
// verify
verify(values, never()).add(nodeRef);
}
Aggregations