Search in sources :

Example 71 with ChildAssociationRef

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);
}
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 72 with ChildAssociationRef

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 73 with ChildAssociationRef

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 74 with ChildAssociationRef

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);
}
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 75 with ChildAssociationRef

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);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest) Test(org.junit.Test)

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