Search in sources :

Example 66 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class FilePlanTypeUnitTest method testCreateMultipleHoldContainers.

/**
 * Having the Fileplan container with a child of type TYPE_HOLD_CONTAINER
 * When adding another child of type TYPE_HOLD_CONTAINER
 * Then an error should be thrown
 */
@Test(expected = IntegrityException.class)
public void testCreateMultipleHoldContainers() {
    ChildAssociationRef existingHoldAssoc = createFileplanContainerChild(TYPE_HOLD_CONTAINER);
    ChildAssociationRef childAssoc = createFileplanContainerChild(TYPE_HOLD_CONTAINER);
    when(mockedNodeService.getChildAssocs(filePlanContainer, Sets.newHashSet(TYPE_HOLD_CONTAINER))).thenReturn(Arrays.asList(existingHoldAssoc, childAssoc));
    filePlanType.onCreateChildAssociation(childAssoc, true);
}
Also used : ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 67 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class FilePlanTypeUnitTest method testCreateMultipleUnfiledRecordsContainers.

/**
 * Having the Fileplan container with a child of type TYPE_UNFILED_RECORD_CONTAINER
 * When adding another child of type TYPE_UNFILED_RECORD_CONTAINER
 * Then an error should be thrown
 */
@Test(expected = IntegrityException.class)
public void testCreateMultipleUnfiledRecordsContainers() {
    ChildAssociationRef existingHoldAssoc = createFileplanContainerChild(TYPE_UNFILED_RECORD_CONTAINER);
    ChildAssociationRef childAssoc = createFileplanContainerChild(TYPE_UNFILED_RECORD_CONTAINER);
    when(mockedNodeService.getChildAssocs(filePlanContainer, Sets.newHashSet(TYPE_UNFILED_RECORD_CONTAINER))).thenReturn(Arrays.asList(existingHoldAssoc, childAssoc));
    filePlanType.onCreateChildAssociation(childAssoc, true);
}
Also used : ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 68 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class FilePlanTypeUnitTest method testAddCategoriesToFileplan.

/**
 * Having the Fileplan container
 * When adding multiple child of type TYPE_RECORD_CATEGORY
 * Then child associations should be created
 */
@Test
public void testAddCategoriesToFileplan() {
    // add the first child
    ChildAssociationRef childAssoc1 = createFileplanContainerChild(TYPE_RECORD_CATEGORY);
    filePlanType.onCreateChildAssociation(childAssoc1, true);
    // add the second child
    ChildAssociationRef childAssoc2 = createFileplanContainerChild(TYPE_RECORD_CATEGORY);
    filePlanType.onCreateChildAssociation(childAssoc2, true);
}
Also used : ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) BaseUnitTest(org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)

Example 69 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class HoldContainerTypeUnitTest method testAddNonHoldTypeToHoldContainer.

/**
 * Given that we try to add a non "rma:hold" type to hold container,
 * Then IntegrityException is thrown.
 */
@Test(expected = IntegrityException.class)
public void testAddNonHoldTypeToHoldContainer() {
    QName type = AlfMock.generateQName();
    when(mockedDictionaryService.isSubClass(type, TYPE_HOLD)).thenReturn(false);
    NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
    NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER, true);
    ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
    when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
    when(mockedChildAssoc.getParentRef()).thenReturn(holdContainer);
    holdContainerType.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 70 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class HoldContainerTypeUnitTest method testAddHoldTypeToHoldContainer.

/**
 * Given that we try to add "rma:hold" type to hold container,
 * Then the operation is successful.
 */
@Test
public void testAddHoldTypeToHoldContainer() {
    QName type = AlfMock.generateQName();
    when(mockedDictionaryService.isSubClass(type, TYPE_HOLD)).thenReturn(true);
    NodeRef holdFolder = AlfMock.generateNodeRef(mockedNodeService, type);
    NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER, true);
    ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
    when(mockedChildAssoc.getChildRef()).thenReturn(holdFolder);
    when(mockedChildAssoc.getParentRef()).thenReturn(holdContainer);
    holdContainerType.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)

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