Merge branch 'feature/RM-4347_Integrate_REST_API_in_UI_Automation'

Conflicts:
	rm-automation/src/main/java/org/alfresco/po/rm/actions/viewaudit/AuditLogPage.java
	rm-automation/src/main/java/org/alfresco/po/rm/console/audit/AuditEvents.java
	rm-automation/src/test/java/org/alfresco/test/TestData.java
	rm-automation/src/test/java/org/alfresco/test/integration/level2/audit/AuditAccess.java
This commit is contained in:
Tuna Aksoy
2016-11-14 14:42:35 +00:00
27 changed files with 571 additions and 81 deletions

View File

@@ -39,4 +39,9 @@ rm.action.parameter-not-supplied=Add a ''{0}'' to continue.
rm.action.delete-not-hold-type=We couldn't delete the hold because {1} isn't of type {0}.
rm.action.cast-to-rm-type=You can't upload a custom folder type to the records management file plan.
rm.action.record-folder-create=You can't create a record folder in another record folder.
rm.action.unique.child.type-error-message=Operation failed. Multiple children of this type are not allowed.
rm.action.multiple.children.type-error-message=Operation failed. Children of type {0} are not allowed
rm.action.create.transfer.container.child-error-message=Operation failed. Creation is not allowed in Transfer Container.
rm.action.create.transfer.child-error-message=Operation failed. Creation is not allowed in Transfer Folders.
rm.action.create.record.folder.child-error-message=Only records can be created in record folders but it was {0}

View File

@@ -142,6 +142,7 @@
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.updateDispositionActionDefinition=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.isNextDispositionActionEligible=RM.Read.0
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getNextDispositionAction=RM.Read.0
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.recalculateNextDispositionStep=RM.Read.0
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getCompletedDispositionActions=RM.Read.0
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.getLastCompletedDispostionAction=RM.Read.0
org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService.isDisposableItemCutoff=RM.Read.0

View File

@@ -196,7 +196,7 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
{
// the change does effect the nextAction for this node
// so go ahead and determine what needs updating
if (changedProps.contains(PROP_DISPOSITION_PERIOD)
if ((changedProps.contains(PROP_DISPOSITION_PERIOD) || changedProps.contains(PROP_DISPOSITION_PERIOD_PROPERTY))
&& isNotTrue((Boolean) getNodeService().getProperty(nextAction.getNodeRef(), PROP_MANUALLY_SET_AS_OF)))
{
persistPeriodChanges(dispositionActionDef, nextAction);

View File

@@ -274,4 +274,12 @@ public interface DispositionService
* @return the initial disposition
*/
DispositionSchedule getOriginDispositionSchedule(NodeRef nodeRef);
/**
* Updates disposition action step when linking or unlinking
* the given record to/from a record folder
*
* @param record
*/
void recalculateNextDispositionStep(NodeRef record);
}

View File

@@ -1106,6 +1106,32 @@ public class DispositionServiceImpl extends ServiceBaseImpl
return null;
}
public void recalculateNextDispositionStep(NodeRef record)
{
List<NodeRef> recordFolders = recordFolderService.getRecordFolders(record);
DispositionAction nextDispositionAction = getNextDispositionAction(record);
if (nextDispositionAction != null)
{
NextActionFromDisposition dsNextAction = getNextDispositionAction(record, recordFolders, nextDispositionAction);
if (dsNextAction != null)
{
final NodeRef action = dsNextAction.getNextActionNodeRef();
final Date dispositionActionDate = dsNextAction.getNextActionDateAsOf();
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork()
{
nodeService.setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
return null;
}
});
}
}
}
/**
* Helper method to determine if a node is frozen or has frozen children
*

View File

@@ -27,19 +27,20 @@
package org.alfresco.module.org_alfresco_module_rm.model;
import java.security.InvalidParameterException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.policy.annotation.BehaviourRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.I18NUtil;
import com.google.common.collect.Sets;
@@ -56,6 +57,10 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
/** Logger */
protected static final Log LOGGER = LogFactory.getLog(BaseBehaviourBean.class);
/** I18N */
protected static final String UNIQUE_CHILD_TYPE_ERROR = "rm.action.unique.child.type-error-message";
protected static final String MULTIPLE_CHILDREN_TYPE_ERROR = "rm.action.multiple.children.type-error-message";
/** behaviour filter */
protected BehaviourFilter behaviourFilter;
@@ -99,9 +104,9 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
* @param childType the child node
* @param acceptedUniqueChildType a list of node types that are accepted as children of the provided parent only once
* @param acceptedMultipleChildType a list of node types that are accepted as children of the provided parent multiple times
* @throws InvalidParameterException if the child association doesn't comply with the RM rules
* @throws IntegrityException if the child association doesn't comply with the RM rules
*/
protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List<QName> acceptedUniqueChildType, List<QName> acceptedMultipleChildType) throws InvalidParameterException
protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List<QName> acceptedUniqueChildType, List<QName> acceptedMultipleChildType) throws IntegrityException
{
QName childType = getInternalNodeService().getType(child);
if(acceptedUniqueChildType.contains(childType))
@@ -109,12 +114,12 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
// check the user is not trying to create multiple children of a type that is only accepted once
if(nodeService.getChildAssocs(parent, Sets.newHashSet(childType)).size() > 1)
{
throw new InvalidParameterException("Operation failed. Multiple children of this type are not allowed.");
throw new IntegrityException(I18NUtil.getMessage(UNIQUE_CHILD_TYPE_ERROR), null);
}
}
else if(!acceptedMultipleChildType.contains(childType))
{
throw new InvalidParameterException("Operation failed. Children of type " + childType + " are not allowed");
throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, childType), null);
}
}
@@ -122,9 +127,9 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
* Helper method that checks if the newly created child association is between the sub-types of accepted types.
* @param childType the child node
* @param acceptedMultipleChildType a list of node types that are accepted as children of the provided parent multiple times
* @throws InvalidParameterException if the child association isn't between the sub-types of accepted types
* @throws IntegrityException if the child association isn't between the sub-types of accepted types
*/
protected void validateNewChildAssociationSubTypesIncluded(NodeRef child, List<QName> acceptedMultipleChildType) throws InvalidParameterException
protected void validateNewChildAssociationSubTypesIncluded(NodeRef child, List<QName> acceptedMultipleChildType) throws IntegrityException
{
QName childType = getInternalNodeService().getType(child);
for(QName type : acceptedMultipleChildType)
@@ -135,6 +140,6 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
}
}
//no match was found in sub-types of permitted types list
throw new InvalidParameterException("Operation failed. Children of type " + childType + " are not allowed");
throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, childType), null);
}
}

View File

@@ -27,8 +27,10 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
@@ -61,6 +63,9 @@ public class RecordCategoryType extends BaseBehaviourBean
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
NodeServicePolicies.OnCreateNodePolicy
{
private final static List<QName> ACCEPTED_UNIQUE_CHILD_TYPES = new ArrayList<QName>();
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY, TYPE_RECORD_FOLDER);
/** vital record service */
protected VitalRecordService vitalRecordService;
@@ -106,13 +111,9 @@ public class RecordCategoryType extends BaseBehaviourBean
)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
{
// ensure content is not placed directly into a record category
NodeRef nodeRef = childAssocRef.getChildRef();
if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT))
{
throw new AlfrescoRuntimeException("Operation failed, because you can't place content directly into a record category.");
}
NodeRef parentRef = childAssocRef.getParentRef();
validateNewChildAssociation(parentRef, nodeRef, ACCEPTED_UNIQUE_CHILD_TYPES, ACCEPTED_NON_UNIQUE_CHILD_TYPES);
if (bNew)
{
// setup the record folder

View File

@@ -32,6 +32,7 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
@@ -40,6 +41,7 @@ import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails;
import org.alfresco.repo.copy.DefaultCopyBehaviourCallback;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
@@ -76,7 +78,7 @@ public class RecordFolderType extends AbstractDisposableItem
protected VitalRecordService vitalRecordService;
/** I18N */
private static final String MSG_CANNOT_CREATE_RECORD_FOLDER = "rm.action.record-folder-create";
private static final String MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD = "rm.action.create.record.folder.child-error-message";
/**
* @param recordService record service
@@ -219,6 +221,15 @@ public class RecordFolderType extends AbstractDisposableItem
if (nodeService.exists(nodeRef))
{
boolean notFolderOrRmFolderSubType = !instanceOf(nodeRef, ContentModel.TYPE_FOLDER) ||
instanceOf(nodeRef, RecordsManagementModel.TYPE_RECORDS_MANAGEMENT_CONTAINER) ||
instanceOf(nodeRef, RecordsManagementModel.TYPE_RECORD_FOLDER) ||
instanceOf(nodeRef, RecordsManagementModel.TYPE_TRANSFER);
if (!instanceOf(nodeRef, ContentModel.TYPE_CONTENT) && notFolderOrRmFolderSubType)
{
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD, nodeService.getType(nodeRef)), null);
}
// ensure nothing is being added to a closed record folder
NodeRef recordFolder = childAssocRef.getParentRef();
Boolean isClosed = (Boolean) nodeService.getProperty(recordFolder, PROP_IS_CLOSED);
@@ -245,9 +256,9 @@ public class RecordFolderType extends AbstractDisposableItem
final NodeRef recordFolder = childAssocRef.getChildRef();
// only records can be added in a record folder or hidden folders(is the case of e-mail attachments)
if (!instanceOf(recordFolder, ContentModel.TYPE_CONTENT) && !nodeService.hasAspect(recordFolder, ContentModel.ASPECT_HIDDEN))
if (instanceOf(recordFolder, ContentModel.TYPE_FOLDER) && !nodeService.hasAspect(recordFolder, ContentModel.ASPECT_HIDDEN))
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER));
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD, nodeService.getType(recordFolder)), null);
}
behaviourFilter.disableBehaviour();

View File

@@ -28,7 +28,6 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import java.io.Serializable;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -41,6 +40,7 @@ import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
@@ -59,6 +59,7 @@ import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
import org.alfresco.util.PropertyMap;
import org.springframework.extensions.surf.util.I18NUtil;
import com.google.common.collect.Sets;
@@ -343,14 +344,14 @@ public class RmSiteType extends BaseBehaviourBean
*/
@Override
protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List<QName> acceptedUniqueChildType,
List<QName> acceptedMultipleChildType) throws InvalidParameterException
List<QName> acceptedMultipleChildType) throws IntegrityException
{
super.validateNewChildAssociation(parent, child, acceptedUniqueChildType, acceptedMultipleChildType);
// check the user is not trying to create more than 2 folders that are created by default.
if(nodeService.getChildAssocs(parent, Sets.newHashSet(ContentModel.TYPE_FOLDER)).size() > 2)
{
throw new InvalidParameterException("Operation failed. Children of type " + ContentModel.TYPE_FOLDER + " are not allowed");
throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, ContentModel.TYPE_FOLDER), null);
}
}
}

View File

@@ -26,12 +26,11 @@
*/
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import java.security.InvalidParameterException;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
@@ -50,6 +49,7 @@ public class TransferContainerType extends BaseBehaviourBean
implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy
{
private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container";
private final static String MSG_ERROR_ADD_CHILD_TO_TRANSFER_CONTAINER = "rm.action.create.transfer.container.child-error-message";
private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForTransferContainer";
/**
@@ -84,7 +84,7 @@ public class TransferContainerType extends BaseBehaviourBean
)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
{
throw new InvalidParameterException("Operation failed. Creation is not allowed in Transfer Container");
throw new IntegrityException(I18NUtil.getMessage(MSG_ERROR_ADD_CHILD_TO_TRANSFER_CONTAINER), null);
}
@Override

View File

@@ -27,14 +27,14 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import java.security.InvalidParameterException;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* rma:transfer behaviour bean
@@ -45,6 +45,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
@BehaviourBean(defaultType = "rma:transfer")
public class TransferType extends BaseBehaviourBean implements NodeServicePolicies.OnCreateChildAssociationPolicy
{
private final static String MSG_ERROR_ADD_CHILD_TO_TRANSFER = "rm.action.create.transfer.child-error-message";
private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForTransferType";
/**
@@ -76,6 +77,6 @@ public class TransferType extends BaseBehaviourBean implements NodeServicePolici
)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
{
throw new InvalidParameterException("Operation failed. Creation is not allowed in Transfer Folders");
throw new IntegrityException(I18NUtil.getMessage(MSG_ERROR_ADD_CHILD_TO_TRANSFER), null);
}
}

View File

@@ -45,14 +45,12 @@ import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeFileRecord;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnFileRecord;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
@@ -560,6 +558,8 @@ public class RecordServiceImpl extends BaseBehaviourBean
// create and file the content as a record
file(nodeRef);
// recalculate disposition schedule for the record when linking it
dispositionService.recalculateNextDispositionStep(nodeRef);
}
}
}
@@ -1716,7 +1716,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
// ensure we are linking a record to a record folder
if(isRecord(record) && isRecordFolder(recordFolder))
{
// ensure that we are not linking a record to an exisiting location
// ensure that we are not linking a record to an existing location
List<ChildAssociationRef> parents = nodeService.getParentAssocs(record);
for (ChildAssociationRef parent : parents)
{
@@ -1739,6 +1739,9 @@ public class RecordServiceImpl extends BaseBehaviourBean
record,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name));
// recalculate disposition schedule for the record when linking it
dispositionService.recalculateNextDispositionStep(record);
}
else
{
@@ -1795,6 +1798,9 @@ public class RecordServiceImpl extends BaseBehaviourBean
// remove the link
nodeService.removeChild(recordFolder, record);
// recalculate disposition schedule for record after unlinking it
dispositionService.recalculateNextDispositionStep(record);
}
else
{

View File

@@ -46,7 +46,7 @@ import org.alfresco.rm.rest.api.model.SiteUpdate;
* @since 2.6
*
*/
@EntityResource(name = "sites", title = "IG Sites")
@EntityResource(name = "ig-sites", title = "IG Sites")
public class RMSiteEntityResource implements EntityResourceAction.Delete, EntityResourceAction.Create<RMSite>,
EntityResourceAction.Update<RMSite>, EntityResourceAction.ReadById<RMSite>
{

View File

@@ -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.");
}
/**
* <a href="https://issues.alfresco.com/jira/browse/RM-4292">RM-4292</a>
* <p><pre>
* 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.
* </pre>
*/
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.");
}
}

View File

@@ -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;

View File

@@ -27,11 +27,10 @@
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import java.security.InvalidParameterException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
@@ -78,7 +77,7 @@ public class RM3341Test extends BaseRMTestCase
fileFolderService.create(holdContainer, "test file", ContentModel.TYPE_CONTENT);
fail("This should have thrown an exception");
}
catch (InvalidParameterException e)
catch (IntegrityException e)
{
// ("Content can't be added to a hold container. Use record folders to file content.")
}
@@ -104,7 +103,7 @@ public class RM3341Test extends BaseRMTestCase
fail("This should have thrown an exception");
}
catch (InvalidParameterException e)
catch (IntegrityException e)
{
// ("Content can't be added to a transfer container. Use record folders to file content.")
}

View File

@@ -26,10 +26,9 @@
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import java.security.InvalidParameterException;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.module.org_alfresco_module_rm.test.util.TestModel;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.util.GUID;
import org.springframework.extensions.surf.util.I18NUtil;
@@ -50,7 +49,7 @@ public class RM3450Test extends BaseRMTestCase
doTestInTransaction(new FailureTest
(
I18NUtil.getMessage(MSG_CANNOT_CAST_TO_RM_TYPE),
InvalidParameterException.class
IntegrityException.class
)
{
@Override

View File

@@ -27,16 +27,25 @@
package org.alfresco.module.org_alfresco_module_rm.action.impl;
import static java.util.Arrays.asList;
import static org.alfresco.module.org_alfresco_module_rm.action.impl.BroadcastDispositionActionDefinitionUpdateAction.CHANGED_PROPERTIES;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.PROP_DISPOSITION_AS_OF;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.PROP_DISPOSITION_PERIOD_PROPERTY;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.TYPE_DISPOSITION_ACTION_DEFINITION;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.Serializable;
import java.util.Date;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -63,6 +72,7 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
private NodeService mockNodeService = mock(NodeService.class);
private DispositionService mockDispositionService = mock(DispositionService.class);
private BehaviourFilter mockBehaviourFilter = mock(BehaviourFilter.class);
/** Inject the mock services into the class under test and link the content and next action nodes. */
@Before
@@ -70,6 +80,7 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
{
action.setNodeService(mockNodeService);
action.setDispositionService(mockDispositionService);
action.setBehaviourFilter(mockBehaviourFilter);
ChildAssociationRef mockAssocRef = mock(ChildAssociationRef.class);
when(mockNodeService.getPrimaryParent(NEXT_ACTION_NODE_REF)).thenReturn(mockAssocRef);
@@ -100,4 +111,61 @@ public class BroadcastDispositionActionDefinitionUpdateActionUnitTest
// Check that the "disposition as of" date has been set on the next action.
verify(mockNodeService).setProperty(NEXT_ACTION_NODE_REF, PROP_DISPOSITION_AS_OF, asOfDate);
}
/**
* Check that changing the period property triggers a recalculation of the "disposition as of" date.
* <p>
* Set up a disposition action definition node under a schedule defintion node, under a category node. Create a
* record whose next action is an instance of the action definition. Check that if the "period property" of the
* action definition changes then the "disposition as of" date is recalculated and persisted against the node of the
* next action.
*/
@Test
public void testChangePeriodProperty()
{
// Set up the action definition node.
String definitionNodeId = "definitionNodeId";
NodeRef definitionNode = new NodeRef("definition://node/" + definitionNodeId);
DispositionSchedule mockDispositionSchedule = mock(DispositionSchedule.class);
when(mockDispositionSchedule.getNodeRef()).thenReturn(definitionNode);
when(mockNodeService.getType(definitionNode)).thenReturn(TYPE_DISPOSITION_ACTION_DEFINITION);
// Set up the schedule definition node hierarchy.
NodeRef categoryNode = new NodeRef("category://node/");
NodeRef scheduleNode = new NodeRef("schedule://node/");
ChildAssociationRef scheduleDefinitionRelationship = new ChildAssociationRef(null, scheduleNode, null, definitionNode);
when(mockNodeService.getPrimaryParent(definitionNode)).thenReturn(scheduleDefinitionRelationship);
ChildAssociationRef categoryScheduleRelationship = new ChildAssociationRef(null, categoryNode, null, scheduleNode);
when(mockNodeService.getPrimaryParent(scheduleNode)).thenReturn(categoryScheduleRelationship);
// Set up the record/step relationship.
NodeRef recordNode = new NodeRef("record://node/");
NodeRef stepNode = new NodeRef("step://node/");
ChildAssociationRef recordStepRelationship = new ChildAssociationRef(null, recordNode, null, stepNode);
when(mockNodeService.getPrimaryParent(stepNode)).thenReturn(recordStepRelationship);
// Set up the disposition schedule.
when(mockDispositionService.getAssociatedDispositionSchedule(categoryNode)).thenReturn(mockDispositionSchedule);
when(mockDispositionService.getDisposableItems(mockDispositionSchedule)).thenReturn(asList(recordNode));
when(mockDispositionService.getDispositionSchedule(recordNode)).thenReturn(mockDispositionSchedule);
// Set up the record.
when(mockNodeService.hasAspect(recordNode, ASPECT_DISPOSITION_LIFECYCLE)).thenReturn(true);
// Set up the next disposition action.
DispositionAction nextAction = mock(DispositionAction.class);
when(nextAction.getId()).thenReturn(definitionNodeId);
when(nextAction.getNodeRef()).thenReturn(stepNode);
when(mockDispositionService.getNextDispositionAction(recordNode)).thenReturn(nextAction);
DispositionActionDefinition mockActionDefinition = mock(DispositionActionDefinition.class);
when(nextAction.getDispositionActionDefinition()).thenReturn(mockActionDefinition);
// Set up the action so that it looks like the period property has been changed.
Action mockAction = mock(Action.class);
when(mockAction.getParameterValue(CHANGED_PROPERTIES)).thenReturn((Serializable) asList(PROP_DISPOSITION_PERIOD_PROPERTY));
// Set up the expected "as of" date.
Date newAsOfDate = new Date(123456789000L);
when(mockDispositionService.calculateAsOfDate(recordNode, mockActionDefinition, false)).thenReturn(newAsOfDate);
// Call the method under test.
action.executeImpl(mockAction, definitionNode);
// Check that the "as of" date is updated.
verify(mockNodeService).setProperty(stepNode, PROP_DISPOSITION_AS_OF, newAsOfDate);
}
}

View File

@@ -29,11 +29,11 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.when;
import java.security.InvalidParameterException;
import java.util.Arrays;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -69,7 +69,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
* When adding a child of type TYPE_FILE_PLAN
* Then an error should be thrown
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testAddFileplanToFileplan()
{
ChildAssociationRef childAssoc = createFileplanContainerChild(TYPE_FILE_PLAN);
@@ -112,7 +112,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
* When adding another child of type TYPE_HOLD_CONTAINER
* Then an error should be thrown
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testCreateMultipleHoldContainers()
{
ChildAssociationRef existingHoldAssoc = createFileplanContainerChild(TYPE_HOLD_CONTAINER);
@@ -141,7 +141,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
* When adding another child of type TYPE_TRANSFER_CONTAINER
* Then an error should be thrown
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testCreateMultipleTransferContainers()
{
ChildAssociationRef existingHoldAssoc = createFileplanContainerChild(TYPE_TRANSFER_CONTAINER);
@@ -170,7 +170,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
* When adding another child of type TYPE_UNFILED_RECORD_CONTAINER
* Then an error should be thrown
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testCreateMultipleUnfiledRecordsContainers()
{
ChildAssociationRef existingHoldAssoc = createFileplanContainerChild(TYPE_UNFILED_RECORD_CONTAINER);

View File

@@ -29,10 +29,9 @@ 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.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -52,9 +51,9 @@ public class HoldContainerTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add a non "rma:hold" type to hold container,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testAddNonHoldTypeToHoldContainer()
{
QName type = AlfMock.generateQName();

View File

@@ -0,0 +1,111 @@
/*
* #%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 <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.when;
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.module.org_alfresco_module_rm.vital.VitalRecordService;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
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;
/**
* Unit test class for RecordCategoryType
*
* @author Silviu Dinuta
* @since 2.6
*
*/
public class RecordCategoryTypeUnitTest extends BaseUnitTest
{
@Mock
private AuthenticationUtil mockAuthenticationUtil;
@Mock
private VitalRecordService mockedVitalRecordService;
private @InjectMocks RecordCategoryType recordCategoryType;
@Before
public void setup()
{
MockitoAnnotations.initMocks(this);
MockAuthenticationUtilHelper.setup(mockAuthenticationUtil);
when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
}
/**
* 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);
}
/**
* Given that we try to add "rma:recordCategory" type to a record category,
* Then operation is successful.
*/
@Test
public void testCreateRecordCategory() throws Exception
{
NodeRef recordCategoryNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_CATEGORY);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_CATEGORY, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordCategoryNodeRef, nodeRef);
recordCategoryType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add "rma:recordFolder" type to a record category,
* Then operation is successful.
*/
@Test
public void testCreateRecordFolder() throws Exception
{
NodeRef recordCategoryNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_CATEGORY);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordCategoryNodeRef, nodeRef);
recordCategoryType.onCreateChildAssociation(childAssocRef, true);
}
}

View File

@@ -0,0 +1,226 @@
/*
* #%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 <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.when;
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.module.org_alfresco_module_rm.vital.VitalRecordService;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
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;
/**
* Unit test class for RecordFolderType
*
* @author Silviu Dinuta
* @since 2.6
*
*/
public class RecordFolderTypeUnitTest extends BaseUnitTest
{
@Mock
private AuthenticationUtil mockAuthenticationUtil;
@Mock
private VitalRecordService mockedVitalRecordService;
private @InjectMocks RecordFolderType recordFolderType;
@Before
public void setup()
{
MockitoAnnotations.initMocks(this);
MockAuthenticationUtilHelper.setup(mockAuthenticationUtil);
when(mockedApplicationContext.getBean("dbNodeService")).thenReturn(mockedNodeService);
}
/**
* Given that we try to add one rma:transfer to a record folder,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testCreateTransferFolder() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_TRANSFER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add one record folder to a record folder,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testCreateRecordFolder() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_RECORD_FOLDER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add sub-type of rma:recordsManagementContainer to a record folder,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testCreateSubTypesOfRecordManagementContainer() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_RECORDS_MANAGEMENT_CONTAINER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add cm:folder sub-type to a record folder,
* Then the operation is successful.
*/
@Test
public void testCreateFolderSubType() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add non cm:folder sub-type to a record folder,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testCreateNonFolderSubType() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(false);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add cm:content sub-type to a record folder,
* Then the operation is successful.
*/
public void testCreateContent() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_CONTENT)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add non cm:content or non cm:folder sub-type to a record folder,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testCreateNonContent() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_CONTENT)).thenReturn(false);
when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(false);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
/**
* Given that we try to add not hidden cm:folder sub-type to a record folder,
* Then IntegrityException is thrown on commit.
*/
@Test(expected = IntegrityException.class)
public void testCreateNotHiddenFolderSubTypeOnCommit() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociationOnCommit(childAssocRef, true);
}
/**
* Given that we try to add hidden cm:folder sub-type to a record folder,
* Then the operation is successful.
*/
@Test
public void testCreateHiddenFolderSubTypeOnCommit() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(true);
when(mockedNodeService.hasAspect(nodeRef, ASPECT_HIDDEN)).thenReturn(true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociationOnCommit(childAssocRef, true);
}
/**
* Given that we try to add non cm:folder sub-type to a record folder,
* Then the operation is successful.
*/
@Test
public void testCreateNonFolderSubTypeOnCommit() throws Exception
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(false);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociationOnCommit(childAssocRef, true);
}
}

View File

@@ -30,7 +30,6 @@ 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;
@@ -38,6 +37,7 @@ 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.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteInfo;
@@ -77,9 +77,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add non allowed type to rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddNonAcceptedTypeToRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
@@ -149,9 +149,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add more than two cm:folder to rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddMoreThanTwhoFolderTypeToRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
@@ -208,9 +208,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add one dod:filePlan to standard rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddDODFilePlanTypeToStandardRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
@@ -225,9 +225,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add more than one rma:filePlan to rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddMoreThanOneFilePlanTypeToRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
@@ -281,9 +281,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add more than one dod:filePlan to rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddMoreThanOneDODFilePlanTypeToRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_DOD_5015_SITE, true);
@@ -315,9 +315,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add one rma:filePlan to DOD rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddStandardFilePlanTypeToDODRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_DOD_5015_SITE, true);

View File

@@ -29,10 +29,9 @@ 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.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -52,9 +51,9 @@ public class TransferContainerTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add to transfer container,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddToTransferContainerTest()
{
NodeRef transferContainer = generateNodeRef(TYPE_TRANSFER_CONTAINER, true);

View File

@@ -30,10 +30,9 @@ 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.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -53,9 +52,9 @@ public class TransferTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add to transfer type folder,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddToTransferFolderTest()
{
NodeRef transferFolder = generateNodeRef(TYPE_TRANSFER, true);

View File

@@ -30,11 +30,10 @@ 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.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -54,9 +53,9 @@ public class UnfiledRecordContainerTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add a type that is not one of "rma:unfiledRecordFolder", "cm:content" or "rma:nonElectronicDocument" types to unfiled record container,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddNonAcceptedTypeToUnfiledRecordContainer()
{
QName type = AlfMock.generateQName();

View File

@@ -30,11 +30,10 @@ 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.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -54,9 +53,9 @@ public class UnfiledRecordFolderTypeUnitTest extends BaseUnitTest
/**
* 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.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddNonAcceptedTypeToUnfiledRecordFolder()
{
QName type = AlfMock.generateQName();