mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1635: Recordable Version Store Service Prototype
* integration tests to ensure recorded version retireves the state of the versioned content accurately * various improvements to satisfy tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@81055 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -87,9 +87,6 @@ public class FilePlanPermissionServiceImplUnitTest extends BaseUnitTest
|
||||
{
|
||||
super.before();
|
||||
|
||||
// mock up run as methods
|
||||
mockRunAsMethods(filePlanPermissionService);
|
||||
|
||||
// initialize node's
|
||||
unfiledRecordContainer = generateContainerNodeRef(TYPE_UNFILED_RECORD_CONTAINER);
|
||||
unfiledRecordFolder = generateContainerNodeRef(TYPE_UNFILED_RECORD_FOLDER);
|
||||
|
@@ -41,10 +41,12 @@ import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.impl.ExtendedPermissionService;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -114,6 +116,9 @@ public class BaseUnitTest implements RecordsManagementModel, ContentModel
|
||||
@Mock(name="filePlanRoleService") protected FilePlanRoleService mockedFilePlanRoleService;
|
||||
@Mock(name="recordsManagementAuditService") protected RecordsManagementAuditService mockedRecordsManagementAuditService;
|
||||
@Mock(name="policyBehaviourFilter") protected BehaviourFilter mockedBehaviourFilter;
|
||||
@Mock(name="authenticationUtil") protected AuthenticationUtil mockedAuthenticationUtil;
|
||||
@Mock(name="extendedPermissionService") protected ExtendedPermissionService mockedExtendedPermissionService;
|
||||
@Mock(name="extendedSecurityService") protected ExtendedSecurityService mockedExtendedSecurityService;
|
||||
|
||||
/** application context mock */
|
||||
@Mock(name="applicationContext") protected ApplicationContext mockedApplicationContext;
|
||||
@@ -146,6 +151,9 @@ public class BaseUnitTest implements RecordsManagementModel, ContentModel
|
||||
}
|
||||
};
|
||||
doAnswer(doInTransactionAnswer).when(mockedRetryingTransactionHelper).doInTransaction(any(RetryingTransactionCallback.class));
|
||||
|
||||
// setup mocked authentication util
|
||||
setupAuthenticationUtilMock();
|
||||
|
||||
// setup file plan
|
||||
filePlan = generateNodeRef(TYPE_FILE_PLAN);
|
||||
@@ -173,6 +181,43 @@ public class BaseUnitTest implements RecordsManagementModel, ContentModel
|
||||
doReturn(Collections.singletonList(record)).when(mockedRecordService).getRecords(recordFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup authentication util mock
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setupAuthenticationUtilMock()
|
||||
{
|
||||
// just do the work
|
||||
doAnswer(new Answer<Object>()
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable
|
||||
{
|
||||
RunAsWork work = (RunAsWork)invocation.getArguments()[0];
|
||||
return work.doWork();
|
||||
}
|
||||
|
||||
}).when(mockedAuthenticationUtil).runAsSystem(any(RunAsWork.class));
|
||||
|
||||
// just do the work
|
||||
doAnswer(new Answer<Object>()
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable
|
||||
{
|
||||
RunAsWork work = (RunAsWork)invocation.getArguments()[0];
|
||||
return work.doWork();
|
||||
}
|
||||
|
||||
}).when(mockedAuthenticationUtil).runAs(any(RunAsWork.class), anyString());
|
||||
|
||||
// assume admin
|
||||
doReturn("admin").when(mockedAuthenticationUtil).getAdminUserName();
|
||||
doReturn("admin").when(mockedAuthenticationUtil).getFullyAuthenticatedUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to generate a qname.
|
||||
*
|
||||
@@ -349,40 +394,6 @@ public class BaseUnitTest implements RecordsManagementModel, ContentModel
|
||||
doReturn(assocs).when(mockedNodeService).getChildAssocs(parent, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to mock up calls to 'run as' methods
|
||||
* on base service implementation.
|
||||
*
|
||||
* @param service
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void mockRunAsMethods(ServiceBaseImpl service)
|
||||
{
|
||||
doAnswer(new Answer<Object>()
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable
|
||||
{
|
||||
RunAsWork work = (RunAsWork)invocation.getArguments()[0];
|
||||
return work.doWork();
|
||||
}
|
||||
|
||||
}).when(service).runAsSystem(any(RunAsWork.class));
|
||||
|
||||
doAnswer(new Answer<Object>()
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable
|
||||
{
|
||||
RunAsWork work = (RunAsWork)invocation.getArguments()[0];
|
||||
return work.doWork();
|
||||
}
|
||||
|
||||
}).when(service).runAs(any(RunAsWork.class), anyString());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> List<T> buildList(T ... values)
|
||||
{
|
||||
|
Reference in New Issue
Block a user