Search in sources :

Example 61 with ChildAssociationRef

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

Example 62 with ChildAssociationRef

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

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

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

Example 65 with ChildAssociationRef

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());
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) AlfMock.generateQName(org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateQName) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Map(java.util.Map) 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