result = new ArrayList<>(nodeInfos.size());
for (Node nodeInfo : nodeInfos)
@@ -85,10 +80,6 @@ public class FileplanComponentChildrenRelation implements RelationshipResourceAc
@Override
public Node create(String parentFolderNodeId, FormData formData, Parameters parameters, WithResponse withResponse)
{
- if(nodes.isRMSite(parentFolderNodeId))
- {
- throw new PermissionDeniedException("POST request not allowed in RM site.");
- }
return nodes.upload(parentFolderNodeId, formData, parameters);
}
}
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java
index daa9ab1818..f2b55655b2 100644
--- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java
@@ -205,4 +205,33 @@ public class MultipleSchedulesTest extends BaseRMTestCase
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
.because("Record should follow largest rentention schedule period, which is one week.");
}
+
+ /**
+ * RM-4292
+ *
+ * Given a record subject to a mixed disposition schedule
+ * When the record is unlinked from one of its secondary parents
+ * Then the next disposition action is recalculated.
+ *
+ */
+ public void testRecalculateDispositionWhenUnlinking()
+ {
+ test()
+ .given(() -> {
+ setUpFilePlan();
+ // Create a record filed under category A and linked to category B.
+ record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef();
+ recordService.link(record, folderB);
+ })
+ .when(() -> {
+ // Cut off the record.
+ dispositionService.cutoffDisposableItem(record);
+ // Unlink the record from folder B.
+ recordService.unlink(record, folderB);
+ })
+ .then()
+ .expect(true)
+ .from(() -> dispositionService.isNextDispositionActionEligible(record))
+ .because("Destroy action should be available, as the record should follow its origin disposition schedule.");
+ }
}
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java
index 355d9c7eef..76b478e18c 100644
--- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/UpdateNextDispositionActionTest.java
@@ -34,13 +34,11 @@ import static org.alfresco.util.GUID.generate;
import java.io.Serializable;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
-import org.alfresco.module.org_alfresco_module_rm.action.impl.EditDispositionActionAsOfDateAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java
new file mode 100644
index 0000000000..a9483509ad
--- /dev/null
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteTypeUnitTest.java
@@ -0,0 +1,338 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * -
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ * -
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+
+package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+
+import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
+import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
+import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper;
+import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.site.SiteInfo;
+import org.alfresco.service.cmr.site.SiteService;
+import org.alfresco.service.namespace.QName;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import com.google.common.collect.Sets;
+
+/**
+ * Unit test for RmSiteType
+ *
+ * @author Silviu Dinuta
+ * @since 2.6
+ *
+ */
+public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
+{
+ @Mock
+ private AuthenticationUtil mockAuthenticationUtil;
+
+ @Mock
+ private SiteService mockedSiteService;
+
+ private @InjectMocks RmSiteType rmSiteType;
+
+ @Before
+ public void setup()
+ {
+ MockitoAnnotations.initMocks(this);
+ MockAuthenticationUtilHelper.setup(mockAuthenticationUtil);
+ }
+
+ /**
+ * Given that we try to add non allowed type to rm site,
+ * Then InvalidParameterException is thrown.
+ */
+ @Test(expected = InvalidParameterException.class)
+ public void testAddNonAcceptedTypeToRmSite()
+ {
+ NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
+
+ QName type = AlfMock.generateQName();
+ NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
+
+ ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
+ when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
+ when(mockedChildAssoc.getParentRef()).thenReturn(rmSiteNodeRef);
+ SiteInfo mockedSiteInfo = mock(SiteInfo.class);
+ when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
+ when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+
+ /**
+ * Given that we try to add one cm:folder to rm site,
+ * Then operation is successful.
+ */
+ @Test
+ public void testAddOneFolderTypeToRmSite()
+ {
+ NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
+ ArrayList assocs = new ArrayList();
+
+ SiteInfo mockedSiteInfo = mock(SiteInfo.class);
+ when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
+ when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
+
+ NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
+ ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
+
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+
+ /**
+ * Given that we try to add two cm:folder to rm site,
+ * Then operation is successful.
+ */
+ @Test
+ public void testAddTwoFolderTypeToRmSite()
+ {
+ NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
+ ArrayList assocs = new ArrayList();
+
+ SiteInfo mockedSiteInfo = mock(SiteInfo.class);
+ when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
+ when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
+
+ //create first folder
+ NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
+ ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+
+ //create second cm:folder
+ nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
+ mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+
+ /**
+ * Given that we try to add more than two cm:folder to rm site,
+ * Then InvalidParameterException is thrown.
+ */
+ @Test(expected = InvalidParameterException.class)
+ public void testAddMoreThanTwhoFolderTypeToRmSite()
+ {
+ NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
+ ArrayList assocs = new ArrayList();
+
+ SiteInfo mockedSiteInfo = mock(SiteInfo.class);
+ when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
+ when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(new ArrayList());
+
+ //create first folder
+ NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
+ ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
+
+ //create second cm:folder
+ nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
+ mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+
+ //create third cm:folder
+ nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FOLDER);
+ mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FOLDER))).thenReturn(assocs);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+
+ /**
+ * Given that we try to add one rma:filePlan to rm site,
+ * Then operation is successful.
+ */
+ @Test
+ public void testAddOneFilePlanTypeToRmSite()
+ {
+ NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
+ ArrayList assocs = new ArrayList();
+
+ SiteInfo mockedSiteInfo = mock(SiteInfo.class);
+ when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
+ when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
+
+ NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN);
+ ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FILE_PLAN))).thenReturn(assocs);
+
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+
+ /**
+ * Given that we try to add one dod:filePlan to standard rm site,
+ * Then InvalidParameterException is thrown.
+ */
+ @Test(expected = InvalidParameterException.class)
+ public void testAddDODFilePlanTypeToStandardRmSite()
+ {
+ NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
+ SiteInfo mockedSiteInfo = mock(SiteInfo.class);
+ when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
+ when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
+
+ NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_DOD_5015_FILE_PLAN);
+ ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+
+ /**
+ * Given that we try to add more than one rma:filePlan to rm site,
+ * Then InvalidParameterException is thrown.
+ */
+ @Test(expected = InvalidParameterException.class)
+ public void testAddMoreThanOneFilePlanTypeToRmSite()
+ {
+ NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
+ ArrayList assocs = new ArrayList();
+
+ SiteInfo mockedSiteInfo = mock(SiteInfo.class);
+ when(mockedSiteService.getSite(rmSiteNodeRef)).thenReturn(mockedSiteInfo);
+ when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
+
+ //first file plan creation
+ NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN);
+ ChildAssociationRef mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FILE_PLAN))).thenReturn(assocs);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+
+ //second filePlan creation
+ nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_FILE_PLAN);
+ mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_FILE_PLAN))).thenReturn(assocs);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+
+ /**
+ * 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 assocs = new ArrayList();
+
+ 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);
+ }
+
+ /**
+ * Given that we try to add more than one dod:filePlan to rm site,
+ * Then InvalidParameterException is thrown.
+ */
+ @Test(expected = InvalidParameterException.class)
+ public void testAddMoreThanOneDODFilePlanTypeToRmSite()
+ {
+ NodeRef rmSiteNodeRef = generateNodeRef(TYPE_DOD_5015_SITE, true);
+ ArrayList assocs = new ArrayList();
+
+ 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);
+
+ //first dod:filePlan creation
+ 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);
+
+ //second dod:filePlan creation
+ nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_DOD_5015_FILE_PLAN);
+ mockedChildAssoc = generateChildAssociationRef(rmSiteNodeRef, nodeRef);
+ assocs.add(mockedChildAssoc);
+ when(mockedNodeService.getChildAssocs(rmSiteNodeRef, Sets.newHashSet(TYPE_DOD_5015_FILE_PLAN))).thenReturn(assocs);
+ rmSiteType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+
+ /**
+ * Given that we try to add one rma:filePlan to DOD rm site,
+ * Then InvalidParameterException is thrown.
+ */
+ @Test(expected = InvalidParameterException.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);
+ }
+}
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerTypeUnitTest.java
index 2e3a3135b1..1623164f25 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerTypeUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerTypeUnitTest.java
@@ -51,16 +51,15 @@ public class TransferContainerTypeUnitTest extends BaseUnitTest
private @InjectMocks TransferContainerType transferContainerType;
/**
- * Given that we try to add a non "rma:transfer" type to transfer container,
+ * Given that we try to add to transfer container,
* Then InvalidParameterException is thrown.
*/
@Test(expected = InvalidParameterException.class)
- public void testAddNonTransferTypeToTransferContainerTest()
+ public void testAddToTransferContainerTest()
{
NodeRef transferContainer = generateNodeRef(TYPE_TRANSFER_CONTAINER, true);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_TRANSFER)).thenReturn(false);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
@@ -68,22 +67,4 @@ public class TransferContainerTypeUnitTest extends BaseUnitTest
when(mockedChildAssoc.getParentRef()).thenReturn(transferContainer);
transferContainerType.onCreateChildAssociation(mockedChildAssoc, true);
}
-
- /**
- * Given that we try to add "rma:transfer" type to transfer container,
- * Then the operation is successful.
- */
- @Test
- public void testAddTransferFolderToTransferContainer()
- {
- QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_TRANSFER)).thenReturn(true);
- NodeRef transferFolder= AlfMock.generateNodeRef(mockedNodeService, type);
-
- NodeRef transferContainer = generateNodeRef(TYPE_TRANSFER_CONTAINER, true);
- ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
- when(mockedChildAssoc.getChildRef()).thenReturn(transferFolder);
- when(mockedChildAssoc.getParentRef()).thenReturn(transferContainer);
- transferContainerType.onCreateChildAssociation(mockedChildAssoc, true);
- }
}
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferTypeUnitTest.java
new file mode 100644
index 0000000000..d16b49759a
--- /dev/null
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferTypeUnitTest.java
@@ -0,0 +1,71 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * -
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ * -
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+
+package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.security.InvalidParameterException;
+
+import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+
+/**
+ * Unit test for TransferType
+ *
+ * @author Silviu Dinuta
+ * @since 2.6
+ */
+public class TransferTypeUnitTest extends BaseUnitTest
+{
+ /** test object */
+ private @InjectMocks TransferType transferType;
+
+ /**
+ * Given that we try to add to transfer type folder,
+ * Then InvalidParameterException is thrown.
+ */
+ @Test(expected = InvalidParameterException.class)
+ public void testAddToTransferFolderTest()
+ {
+ NodeRef transferFolder = generateNodeRef(TYPE_TRANSFER, true);
+
+ QName type = AlfMock.generateQName();
+ NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type);
+
+ ChildAssociationRef mockedChildAssoc = mock(ChildAssociationRef.class);
+ when(mockedChildAssoc.getChildRef()).thenReturn(nodeRef);
+ when(mockedChildAssoc.getParentRef()).thenReturn(transferFolder);
+ transferType.onCreateChildAssociation(mockedChildAssoc, true);
+ }
+}
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordFolderTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordFolderTypeUnitTest.java
new file mode 100644
index 0000000000..18efc7ecde
--- /dev/null
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordFolderTypeUnitTest.java
@@ -0,0 +1,138 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * -
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ * -
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+
+package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.security.InvalidParameterException;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+
+/**
+ * Unit test for UnfiledRecordFolderType
+ *
+ * @author Silviu Dinuta
+ * @since 2.6
+ */
+public class UnfiledRecordFolderTypeUnitTest extends BaseUnitTest
+{
+ @InjectMocks
+ private UnfiledRecordFolderType unfiledRecordFolderType;
+
+ /**
+ * Given that we try to add a type that is not one of "rma:unfiledRecordFolder", "cm:content" or "rma:nonElectronicDocument" types to unfiled record folder,
+ * Then InvalidParameterException is thrown.
+ */
+ @Test(expected = InvalidParameterException.class)
+ public void testAddNonAcceptedTypeToUnfiledRecordFolder()
+ {
+ 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(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);
+ }
+
+ /**
+ * Given that we try to add "rma:unfiledRecordFolder" sub-type to unfiled record folder,
+ * Then the operation is successful.
+ */
+ @Test
+ public void testAddUnfiledRecordFolderTypeToUnfiledRecordFolder()
+ {
+ QName type = AlfMock.generateQName();
+ when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(true);
+ when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
+ 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);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Given that we try to add "rma:nonElectronicDocument" sub-type to unfiled record folder,
+ * Then the operation is successful.
+ */
+ @Test
+ public void testNonElectronicDocumentTypeToUnfiledRecordFolder()
+ {
+ 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 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);
+ }
+}
\ No newline at end of file
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java
index 5dc05ded3d..3ae63a99c2 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java
@@ -65,7 +65,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
-import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -725,32 +724,6 @@ public class RMNodesImplUnitTest extends BaseUnitTest
verify(mockedFileFolderService, never()).delete(nodeRef);
}
- @Test
- public void testIsRMSite() throws Exception
- {
- //test when rm site exists and we do not check the rm site
- NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
-
- NodeRef rmSiteNodeRef = AlfMock.generateNodeRef(mockedNodeService);
- SiteInfo mockedSiteInfo = mock(SiteInfo.class);
- when(mockedSiteInfo.getNodeRef()).thenReturn(rmSiteNodeRef);
- when(mockedSiteService.getSite(RM_SITE_ID)).thenReturn(mockedSiteInfo);
-
- boolean isRMSite = rmNodesImpl.isRMSite(parentNodeRef.getId());
- assertEquals("Should return false.", false, isRMSite);
-
- //check when rm site does not exist
- when(mockedSiteService.getSite(RM_SITE_ID)).thenReturn(null);
- isRMSite = rmNodesImpl.isRMSite(parentNodeRef.getId());
- assertEquals("Should return false.", false, isRMSite);
-
- //check when rm site exists and we check with rm site node ref id
- when(mockedSiteInfo.getNodeRef()).thenReturn(parentNodeRef);
- when(mockedSiteService.getSite(RM_SITE_ID)).thenReturn(mockedSiteInfo);
- isRMSite = rmNodesImpl.isRMSite(parentNodeRef.getId());
- assertEquals("Should return true.", true, isRMSite);
- }
-
private void setupCompanyHomeAndPrimaryParent(NodeRef nodeRef)
{
NodeRef companyHomeNodeRef = AlfMock.generateNodeRef(mockedNodeService);
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelationUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelationUnitTest.java
index 895437efa3..7e9c9d75e2 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelationUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/nodes/FileplanComponentChildrenRelationUnitTest.java
@@ -28,13 +28,9 @@
package org.alfresco.rm.rest.api.nodes;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
@@ -42,7 +38,6 @@ import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.rest.api.model.Node;
-import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rest.framework.webscripts.WithResponse;
import org.alfresco.rm.rest.api.impl.RMNodesImpl;
@@ -100,28 +95,6 @@ public class FileplanComponentChildrenRelationUnitTest extends BaseUnitTest
}
@Test
- public void testCreateOnRMSite() throws Exception
- {
- Parameters mockedParameters = mock(Parameters.class);
- NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
-
- List nodeInfos = new ArrayList();
- Node mokedNodeInfo = mock(Node.class);
- nodeInfos.add(mokedNodeInfo);
-
- when(mockedRMNodes.isRMSite(parentNodeRef.getId())).thenReturn(true);
- try
- {
- filePlanComponentChildrenRelation.create(parentNodeRef.getId(), nodeInfos, mockedParameters);
- fail("Expected ecxeption as POST request is not allowed in RM site.");
- }
- catch(PermissionDeniedException ex)
- {
- assertEquals("POST request not allowed in RM site.", ex.getMsgId());
- }
- verify(mockedRMNodes, never()).createNode(parentNodeRef.getId(), nodeInfos.get(0), mockedParameters);
- }
-
public void testUpload() throws Exception
{
Parameters mockedParameters = mock(Parameters.class);
@@ -131,24 +104,4 @@ public class FileplanComponentChildrenRelationUnitTest extends BaseUnitTest
filePlanComponentChildrenRelation.create(parentNodeRef.getId(), mockedFormData, mockedParameters, mockedWithResponse);
verify(mockedRMNodes, times(1)).upload(parentNodeRef.getId(), mockedFormData, mockedParameters);
}
-
- public void testUploadOnRMSite() throws Exception
- {
- Parameters mockedParameters = mock(Parameters.class);
- NodeRef parentNodeRef = AlfMock.generateNodeRef(mockedNodeService);
- FormData mockedFormData = mock(FormData.class);
- WithResponse mockedWithResponse = mock(WithResponse.class);
-
- when(mockedRMNodes.isRMSite(parentNodeRef.getId())).thenReturn(true);
- try
- {
- filePlanComponentChildrenRelation.create(parentNodeRef.getId(), mockedFormData, mockedParameters, mockedWithResponse);
- fail("Expected ecxeption as POST request is not allowed in RM site.");
- }
- catch(PermissionDeniedException ex)
- {
- assertEquals("POST request not allowed in RM site.", ex.getMsgId());
- }
- verify(mockedRMNodes, never()).upload(parentNodeRef.getId(), mockedFormData, mockedParameters);
- }
}