mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2130 (Check classification after method execution, filtering results where appropriate)
- Fixed failing integration tests +review RM-94 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/ENFORCE@107274 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,80 +24,53 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRMActionExecution;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.TestAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.TestAction2;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Records management action service implementation test
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordsManagementActionServiceImplTest extends TestCase
|
||||
implements RecordsManagementModel,
|
||||
BeforeRMActionExecution,
|
||||
public class RecordsManagementActionServiceImplTest extends BaseRMTestCase
|
||||
implements BeforeRMActionExecution,
|
||||
OnRMActionExecution
|
||||
{
|
||||
private static final String[] CONFIG_LOCATIONS = new String[] {
|
||||
"classpath:alfresco/application-context.xml",
|
||||
"classpath:test-context.xml"};
|
||||
|
||||
private ApplicationContext ctx;
|
||||
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private TransactionService transactionService;
|
||||
private RetryingTransactionHelper txnHelper;
|
||||
private NodeService nodeService;
|
||||
private RecordsManagementActionService rmActionService;
|
||||
private PolicyComponent policyComponent;
|
||||
|
||||
private NodeRef nodeRef;
|
||||
private List<NodeRef> nodeRefs;
|
||||
private NodeRef nodeRef;
|
||||
private List<NodeRef> nodeRefs;
|
||||
|
||||
private boolean beforeMarker;
|
||||
private boolean onMarker;
|
||||
private boolean inTest;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
ctx = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
this.serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||
this.transactionService = serviceRegistry.getTransactionService();
|
||||
this.txnHelper = transactionService.getRetryingTransactionHelper();
|
||||
this.nodeService = serviceRegistry.getNodeService();
|
||||
|
||||
this.rmActionService = (RecordsManagementActionService)ctx.getBean("RecordsManagementActionService");
|
||||
this.policyComponent = (PolicyComponent)ctx.getBean("policyComponent");
|
||||
// Set the current security context as system
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
|
||||
|
||||
// Set the current security context as admin
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
RetryingTransactionCallback<Void> setUpCallback = new RetryingTransactionCallback<Void>()
|
||||
RetryingTransactionCallback<Void> setUpCallback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
@@ -128,17 +101,17 @@ public class RecordsManagementActionServiceImplTest extends TestCase
|
||||
beforeMarker = false;
|
||||
onMarker = false;
|
||||
inTest = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
{
|
||||
@Override
|
||||
protected void tearDown()
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetActions()
|
||||
{
|
||||
RetryingTransactionCallback<Void> testCallback = new RetryingTransactionCallback<Void>()
|
||||
public void testGetActions()
|
||||
{
|
||||
RetryingTransactionCallback<Void> testCallback = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
@@ -147,36 +120,36 @@ public class RecordsManagementActionServiceImplTest extends TestCase
|
||||
}
|
||||
};
|
||||
txnHelper.doInTransaction(testCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private void getActionsImpl()
|
||||
{
|
||||
List<RecordsManagementAction> result = this.rmActionService.getRecordsManagementActions();
|
||||
assertNotNull(result);
|
||||
Map<String, RecordsManagementAction> resultMap = new HashMap<String, RecordsManagementAction>(8);
|
||||
for (RecordsManagementAction action : result)
|
||||
{
|
||||
resultMap.put(action.getName(), action);
|
||||
}
|
||||
|
||||
assertTrue(resultMap.containsKey(TestAction.NAME));
|
||||
assertTrue(resultMap.containsKey(TestAction2.NAME));
|
||||
|
||||
result = this.rmActionService.getDispositionActions();
|
||||
resultMap = new HashMap<String, RecordsManagementAction>(8);
|
||||
private void getActionsImpl()
|
||||
{
|
||||
List<RecordsManagementAction> result = this.rmActionService.getRecordsManagementActions();
|
||||
assertNotNull(result);
|
||||
Map<String, RecordsManagementAction> resultMap = new HashMap<String, RecordsManagementAction>(8);
|
||||
for (RecordsManagementAction action : result)
|
||||
{
|
||||
resultMap.put(action.getName(), action);
|
||||
}
|
||||
assertTrue(resultMap.containsKey(TestAction.NAME));
|
||||
assertFalse(resultMap.containsKey(TestAction2.NAME));
|
||||
|
||||
// get some specific actions and check the label
|
||||
RecordsManagementAction cutoff = this.rmActionService.getDispositionAction("cutoff");
|
||||
assertNotNull(cutoff);
|
||||
assertEquals("Cut off", cutoff.getLabel());
|
||||
assertTrue(resultMap.containsKey(TestAction.NAME));
|
||||
assertTrue(resultMap.containsKey(TestAction2.NAME));
|
||||
|
||||
RecordsManagementAction freeze = this.rmActionService.getRecordsManagementAction("freeze");
|
||||
result = this.rmActionService.getDispositionActions();
|
||||
resultMap = new HashMap<String, RecordsManagementAction>(8);
|
||||
for (RecordsManagementAction action : result)
|
||||
{
|
||||
resultMap.put(action.getName(), action);
|
||||
}
|
||||
assertTrue(resultMap.containsKey(TestAction.NAME));
|
||||
assertFalse(resultMap.containsKey(TestAction2.NAME));
|
||||
|
||||
// get some specific actions and check the label
|
||||
RecordsManagementAction cutoff = this.rmActionService.getDispositionAction("cutoff");
|
||||
assertNotNull(cutoff);
|
||||
assertEquals("Cut off", cutoff.getLabel());
|
||||
|
||||
RecordsManagementAction freeze = this.rmActionService.getRecordsManagementAction("freeze");
|
||||
assertNotNull(freeze);
|
||||
assertEquals("Freeze", freeze.getLabel());
|
||||
assertEquals("Freeze", freeze.getLabel());
|
||||
@@ -184,7 +157,7 @@ public class RecordsManagementActionServiceImplTest extends TestCase
|
||||
// test non-existent actions
|
||||
assertNull(this.rmActionService.getDispositionAction("notThere"));
|
||||
assertNull(this.rmActionService.getRecordsManagementAction("notThere"));
|
||||
}
|
||||
}
|
||||
|
||||
public void testExecution()
|
||||
{
|
||||
@@ -225,37 +198,37 @@ public class RecordsManagementActionServiceImplTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
private void executionImpl()
|
||||
{
|
||||
inTest = true;
|
||||
try
|
||||
{
|
||||
policyComponent.bindClassBehaviour(
|
||||
RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION,
|
||||
this,
|
||||
new JavaBehaviour(this, "beforeRMActionExecution", NotificationFrequency.EVERY_EVENT));
|
||||
policyComponent.bindClassBehaviour(
|
||||
private void executionImpl()
|
||||
{
|
||||
inTest = true;
|
||||
try
|
||||
{
|
||||
policyComponent.bindClassBehaviour(
|
||||
RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION,
|
||||
this,
|
||||
new JavaBehaviour(this, "beforeRMActionExecution", NotificationFrequency.EVERY_EVENT));
|
||||
policyComponent.bindClassBehaviour(
|
||||
RecordsManagementPolicies.ON_RM_ACTION_EXECUTION,
|
||||
this,
|
||||
new JavaBehaviour(this, "onRMActionExecution", NotificationFrequency.EVERY_EVENT));
|
||||
|
||||
assertFalse(beforeMarker);
|
||||
assertFalse(onMarker);
|
||||
assertFalse(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD));
|
||||
assertFalse(beforeMarker);
|
||||
assertFalse(onMarker);
|
||||
assertFalse(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD));
|
||||
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(TestAction.PARAM, TestAction.PARAM_VALUE);
|
||||
this.rmActionService.executeRecordsManagementAction(this.nodeRef, TestAction.NAME, params);
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(TestAction.PARAM, TestAction.PARAM_VALUE);
|
||||
this.rmActionService.executeRecordsManagementAction(this.nodeRef, TestAction.NAME, params);
|
||||
|
||||
assertTrue(beforeMarker);
|
||||
assertTrue(beforeMarker);
|
||||
assertTrue(onMarker);
|
||||
assertTrue(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD));
|
||||
}
|
||||
finally
|
||||
{
|
||||
inTest = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
inTest = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void testBulkExecution()
|
||||
{
|
||||
@@ -270,20 +243,20 @@ public class RecordsManagementActionServiceImplTest extends TestCase
|
||||
txnHelper.doInTransaction(testCallback);
|
||||
}
|
||||
|
||||
private void bulkExecutionImpl()
|
||||
{
|
||||
for (NodeRef nodeRef : this.nodeRefs)
|
||||
private void bulkExecutionImpl()
|
||||
{
|
||||
for (NodeRef nodeRef : this.nodeRefs)
|
||||
{
|
||||
assertFalse(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD));
|
||||
assertFalse(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD));
|
||||
}
|
||||
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(TestAction.PARAM, TestAction.PARAM_VALUE);
|
||||
this.rmActionService.executeRecordsManagementAction(this.nodeRefs, TestAction.NAME, params);
|
||||
|
||||
for (NodeRef nodeRef : this.nodeRefs)
|
||||
for (NodeRef nodeRef : this.nodeRefs)
|
||||
{
|
||||
assertTrue(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ public class RecordsManagementSearchServiceImplTest extends BaseRMTestCase
|
||||
private static final String SEARCH3 = "search3";
|
||||
private static final String SEARCH4 = "search4";
|
||||
|
||||
private static final String USER1 = generate();
|
||||
private String user;
|
||||
|
||||
private NodeRef folderLevelRecordFolder;
|
||||
private NodeRef recordLevelRecordFolder;
|
||||
@@ -72,7 +72,8 @@ public class RecordsManagementSearchServiceImplTest extends BaseRMTestCase
|
||||
assertNotNull(searches);
|
||||
numberOfReports = searches.size();
|
||||
|
||||
createPerson(USER1);
|
||||
user = generate();
|
||||
createPerson(user);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -163,7 +164,7 @@ public class RecordsManagementSearchServiceImplTest extends BaseRMTestCase
|
||||
return null;
|
||||
}
|
||||
|
||||
}, USER1);
|
||||
}, user);
|
||||
|
||||
// Get searches (as admin user)
|
||||
doTestInTransaction(new Test<Void>()
|
||||
@@ -222,7 +223,7 @@ public class RecordsManagementSearchServiceImplTest extends BaseRMTestCase
|
||||
return null;
|
||||
}
|
||||
|
||||
}, USER1);
|
||||
}, user);
|
||||
|
||||
// Update search (as admin user)
|
||||
doTestInTransaction(new Test<Void>()
|
||||
|
Reference in New Issue
Block a user