mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1341: Couldn't complete event if link record before completing it
* some refactoring to ensure complete, undo and refresh logic was encapsulated in the service layer (not in the actions) * integration test for complete event to check interactions * restructure integration test packages git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@67986 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.IntegrationTestSuite;
|
||||
import org.alfresco.repo.ParameterProcessorTestSuite;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
@@ -37,9 +38,8 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
CapabilitiesTestSuite.class,
|
||||
ServicesTestSuite.class,
|
||||
WebScriptTestSuite.class,
|
||||
IssueTestSuite.class,
|
||||
ParameterProcessorTestSuite.class,
|
||||
DoD5015TestSuite.class
|
||||
IntegrationTestSuite.class
|
||||
})
|
||||
public class AllTestSuite
|
||||
{
|
||||
|
@@ -38,6 +38,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.springframework.extensions.webscripts.GUID;
|
||||
|
||||
/**
|
||||
* Declarative capability unit test
|
||||
@@ -59,6 +60,8 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
|
||||
|
||||
private NodeRef moveToFolder;
|
||||
private NodeRef moveToCategory;
|
||||
|
||||
private NodeRef hold;
|
||||
|
||||
@Override
|
||||
protected boolean isUserTest()
|
||||
@@ -106,9 +109,12 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
|
||||
utils.declareRecord(declaredRecord);
|
||||
utils.declareRecord(frozenRecord);
|
||||
utils.declareRecord(frozenRecord2);
|
||||
utils.freeze(frozenRecord);
|
||||
utils.freeze(frozenRecordFolder);
|
||||
utils.freeze(frozenRecord2);
|
||||
|
||||
hold = holdService.createHold(filePlan, GUID.generate(), "reason", "description");
|
||||
|
||||
holdService.addToHold(hold, frozenRecord);
|
||||
holdService.addToHold(hold, frozenRecordFolder);
|
||||
holdService.addToHold(hold, frozenRecord2);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -119,9 +125,9 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
|
||||
protected void tearDownImpl()
|
||||
{
|
||||
// Unfreeze stuff so it can be deleted
|
||||
utils.unfreeze(frozenRecord);
|
||||
utils.unfreeze(frozenRecordFolder);
|
||||
utils.unfreeze(frozenRecord2);
|
||||
holdService.removeFromHold(hold, frozenRecord);
|
||||
holdService.removeFromHold(hold, frozenRecordFolder);
|
||||
holdService.removeFromHold(hold, frozenRecord2);
|
||||
|
||||
super.tearDownImpl();
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.dod.DoD5015TestSuite;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.event.EventTestSuite;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.IssueTestSuite;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
|
||||
/**
|
||||
* RM Integration Test Suite
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses(
|
||||
{
|
||||
DoD5015TestSuite.class,
|
||||
IssueTestSuite.class,
|
||||
EventTestSuite.class
|
||||
})
|
||||
public class IntegrationTestSuite
|
||||
{
|
||||
}
|
@@ -16,10 +16,8 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.dod;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.dod.RM1147DODRMSiteTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.dod.RM1194ExcludeDoDRecordTypesTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.dod;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.dod;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.dod;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.dod;
|
||||
|
||||
import java.util.Set;
|
||||
|
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.GUID;
|
||||
|
||||
/**
|
||||
* Complete events integration tests.
|
||||
* <p>
|
||||
* Relates to:
|
||||
* - https://issues.alfresco.com/jira/browse/RM-1341
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class CompleteEventsTest extends BaseRMTestCase
|
||||
{
|
||||
private static final String ANOTHER_EVENT = "abolished";
|
||||
|
||||
/**
|
||||
* test completion of a single event on a record level disposition schedule
|
||||
*/
|
||||
public void testCompleteSingleEventRecordLevel()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private NodeRef record;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// create record category
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||
|
||||
// create disposition schedule
|
||||
utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", true, true);
|
||||
|
||||
// create record folder
|
||||
NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||
|
||||
// file record
|
||||
record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||
utils.declareRecord(record);
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
// build action properties
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
|
||||
// complete event
|
||||
rmActionService.executeRecordsManagementAction(record, CompleteEventAction.NAME, params);
|
||||
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
// check that the record is now eligible for the next disposition action
|
||||
assertTrue(dispositionService.isNextDispositionActionEligible(record));
|
||||
|
||||
// check the next disposition action
|
||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
|
||||
assertNotNull(dispositionAction);
|
||||
assertEquals("cutoff", dispositionAction.getName());
|
||||
|
||||
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||
assertTrue(eventDetails.isEventComplete());
|
||||
assertNotNull(eventDetails.getEventCompletedAt());
|
||||
assertNotNull(eventDetails.getEventCompletedBy());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* test completion of a single event at the record level
|
||||
*/
|
||||
public void testCompleteSimpleSingleEventRecordFolderLevel()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private NodeRef recordFolder;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// create record category
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||
|
||||
// create disposition schedule
|
||||
utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, true);
|
||||
|
||||
// create record folder
|
||||
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||
|
||||
// file record
|
||||
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||
utils.declareRecord(record);
|
||||
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
// build action properties
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
|
||||
// complete event
|
||||
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
// check that the record is now eligible for the next disposition action
|
||||
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
|
||||
|
||||
// check the next disposition action
|
||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
|
||||
assertNotNull(dispositionAction);
|
||||
assertEquals("cutoff", dispositionAction.getName());
|
||||
|
||||
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||
assertTrue(eventDetails.isEventComplete());
|
||||
assertNotNull(eventDetails.getEventCompletedAt());
|
||||
assertNotNull(eventDetails.getEventCompletedBy());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* test complete event given at least one event is needed for the disposition action to be eligible
|
||||
*/
|
||||
public void testAtLeastOneEventToBeEligible()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
NodeRef recordFolder = null;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// create record category
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||
|
||||
// create disposition schedule
|
||||
DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false);
|
||||
|
||||
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
|
||||
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||
adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION);
|
||||
|
||||
List<String> events = new ArrayList<String>(1);
|
||||
events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
events.add(ANOTHER_EVENT);
|
||||
adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events);
|
||||
dispositionService.addDispositionActionDefinition(mySchedule, adParams);
|
||||
|
||||
// create record folder
|
||||
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||
|
||||
// file record
|
||||
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||
utils.declareRecord(record);
|
||||
|
||||
}
|
||||
public void when()
|
||||
{
|
||||
// build action properties
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
|
||||
// complete event
|
||||
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
// check that the record is now eligible for the next disposition action
|
||||
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
|
||||
|
||||
// check the next disposition action
|
||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
|
||||
assertNotNull(dispositionAction);
|
||||
assertEquals("cutoff", dispositionAction.getName());
|
||||
|
||||
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||
assertTrue(eventDetails.isEventComplete());
|
||||
assertNotNull(eventDetails.getEventCompletedAt());
|
||||
assertNotNull(eventDetails.getEventCompletedBy());
|
||||
|
||||
eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(ANOTHER_EVENT, eventDetails.getEventName());
|
||||
assertFalse(eventDetails.isEventComplete());
|
||||
assertNull(eventDetails.getEventCompletedAt());
|
||||
assertNull(eventDetails.getEventCompletedBy());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* test that disposition action is not eligible given all events need to be completed and only has been
|
||||
*/
|
||||
public void testOnlyOneOfAllEventsSoNotEligible()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
NodeRef recordFolder = null;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// create record category
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||
|
||||
// create disposition schedule
|
||||
DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false);
|
||||
|
||||
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
|
||||
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||
adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION);
|
||||
adParams.put(PROP_DISPOSITION_EVENT_COMBINATION, "and");
|
||||
|
||||
List<String> events = new ArrayList<String>(1);
|
||||
events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
events.add(ANOTHER_EVENT);
|
||||
adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events);
|
||||
dispositionService.addDispositionActionDefinition(mySchedule, adParams);
|
||||
|
||||
// create record folder
|
||||
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||
|
||||
// file record
|
||||
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||
utils.declareRecord(record);
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
// build action properties
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
|
||||
// complete event
|
||||
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
assertFalse(dispositionService.isNextDispositionActionEligible(recordFolder));
|
||||
|
||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
|
||||
assertNotNull(dispositionAction);
|
||||
assertEquals("cutoff", dispositionAction.getName());
|
||||
|
||||
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||
assertTrue(eventDetails.isEventComplete());
|
||||
assertNotNull(eventDetails.getEventCompletedAt());
|
||||
assertNotNull(eventDetails.getEventCompletedBy());
|
||||
|
||||
eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(ANOTHER_EVENT, eventDetails.getEventName());
|
||||
assertFalse(eventDetails.isEventComplete());
|
||||
assertNull(eventDetails.getEventCompletedAt());
|
||||
assertNull(eventDetails.getEventCompletedBy());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* test event complete makes disposition eligible given that all events are complete and required
|
||||
*/
|
||||
public void testAllEventsSoEligible()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
NodeRef recordFolder = null;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// create record category
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||
|
||||
// create disposition schedule
|
||||
DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false);
|
||||
|
||||
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
|
||||
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||
adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION);
|
||||
adParams.put(PROP_DISPOSITION_EVENT_COMBINATION, "and");
|
||||
|
||||
List<String> events = new ArrayList<String>(1);
|
||||
events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
events.add(ANOTHER_EVENT);
|
||||
adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events);
|
||||
dispositionService.addDispositionActionDefinition(mySchedule, adParams);
|
||||
|
||||
// create record folder
|
||||
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||
|
||||
// file record
|
||||
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||
utils.declareRecord(record);
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
// build action properties
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
|
||||
// complete event
|
||||
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||
|
||||
// build action properties
|
||||
params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, ANOTHER_EVENT);
|
||||
|
||||
// complete event
|
||||
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
|
||||
|
||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
|
||||
assertNotNull(dispositionAction);
|
||||
assertEquals("cutoff", dispositionAction.getName());
|
||||
|
||||
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||
assertTrue(eventDetails.isEventComplete());
|
||||
assertNotNull(eventDetails.getEventCompletedAt());
|
||||
assertNotNull(eventDetails.getEventCompletedBy());
|
||||
|
||||
eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(ANOTHER_EVENT, eventDetails.getEventName());
|
||||
assertTrue(eventDetails.isEventComplete());
|
||||
assertNotNull(eventDetails.getEventCompletedAt());
|
||||
assertNotNull(eventDetails.getEventCompletedBy());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* test complete event works for multi-filed record
|
||||
*/
|
||||
public void testCompleteEventWhenCutoffMultiFiled_RM1341()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private NodeRef record;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// create record category
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||
NodeRef recordCategory2 = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||
|
||||
// create disposition schedule
|
||||
utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", true, true);
|
||||
|
||||
// create record folder
|
||||
NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||
NodeRef recordFolder2 = recordFolderService.createRecordFolder(recordCategory2, GUID.generate());
|
||||
|
||||
// file record
|
||||
String recordName = GUID.generate();
|
||||
record = utils.createRecord(recordFolder, recordName, "title");
|
||||
utils.declareRecord(record);
|
||||
|
||||
// link record to second record folder
|
||||
nodeService.addChild(recordFolder2, record, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, recordName));
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
// build action properties
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
|
||||
// complete event
|
||||
rmActionService.executeRecordsManagementAction(record, CompleteEventAction.NAME, params);
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
// check that the record is now eligible for the next disposition action
|
||||
assertTrue(dispositionService.isNextDispositionActionEligible(record));
|
||||
|
||||
// check the next disposition action
|
||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
|
||||
assertNotNull(dispositionAction);
|
||||
assertEquals("cutoff", dispositionAction.getName());
|
||||
|
||||
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||
assertNotNull(eventDetails);
|
||||
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||
assertTrue(eventDetails.isEventComplete());
|
||||
assertNotNull(eventDetails.getEventCompletedAt());
|
||||
assertNotNull(eventDetails.getEventCompletedBy());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.event;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
/**
|
||||
* Event integration test suite
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses(
|
||||
{
|
||||
CompleteEventsTest.class
|
||||
})
|
||||
public class EventTestSuite
|
||||
{
|
||||
}
|
@@ -16,15 +16,8 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1008Test;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1027Test;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1030Test;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1039Test;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM452Test;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM804Test;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM994Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
@@ -38,7 +38,7 @@ import org.alfresco.util.GUID;
|
||||
|
||||
|
||||
/**
|
||||
* System test for RM-1008
|
||||
* Test for RM-1008
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.1
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import java.util.List;
|
||||
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition;
|
@@ -808,7 +808,51 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
{
|
||||
// empty implementation
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void doBehaviourDrivenTest(BehaviourDrivenTest test)
|
||||
{
|
||||
test.run();
|
||||
}
|
||||
|
||||
protected abstract class BehaviourDrivenTest
|
||||
{
|
||||
public abstract void given();
|
||||
|
||||
public abstract void when();
|
||||
|
||||
public abstract void then();
|
||||
|
||||
public void run()
|
||||
{
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
given();
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
when();
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
then();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
|
@@ -1,5 +1,20 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.util;
|
||||
|
||||
@@ -17,13 +32,11 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||
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.FreezeAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
|
||||
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.disposition.DispositionSchedule;
|
||||
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.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
@@ -41,6 +54,8 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Common RM test utility methods.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class CommonRMTestUtils implements RecordsManagementModel
|
||||
@@ -73,9 +88,10 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param container
|
||||
* @return
|
||||
* Create a disposition schedule
|
||||
*
|
||||
* @param container record category
|
||||
* @return {@link DispositionSchedule} created disposition schedule node reference
|
||||
*/
|
||||
public DispositionSchedule createBasicDispositionSchedule(NodeRef container)
|
||||
{
|
||||
@@ -207,15 +223,8 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
||||
modelSecurityService.setEnabled(false);
|
||||
try
|
||||
{
|
||||
// Declare record
|
||||
nodeService.setProperty(record, DOD5015Model.PROP_PUBLICATION_DATE, new Date());
|
||||
nodeService.setProperty(record, DOD5015Model.PROP_MEDIA_TYPE, "mediaTypeValue");
|
||||
nodeService.setProperty(record, DOD5015Model.PROP_FORMAT, "formatValue");
|
||||
nodeService.setProperty(record, DOD5015Model.PROP_DATE_RECEIVED, new Date());
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date());
|
||||
nodeService.setProperty(record, DOD5015Model.PROP_ORIGINATOR, "origValue");
|
||||
nodeService.setProperty(record, DOD5015Model.PROP_ORIGINATING_ORGANIZATION, "origOrgValue");
|
||||
nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue");
|
||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date());
|
||||
nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue");
|
||||
actionService.executeRecordsManagementAction(record, "declareRecord");
|
||||
}
|
||||
finally
|
||||
@@ -251,37 +260,6 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
||||
}, AuthenticationUtil.getAdminUserName());
|
||||
}
|
||||
|
||||
public void freeze(final NodeRef nodeRef)
|
||||
{
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||
params.put(FreezeAction.PARAM_REASON, "Freeze reason.");
|
||||
actionService.executeRecordsManagementAction(nodeRef, "freeze", params);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
public void unfreeze(final NodeRef nodeRef)
|
||||
{
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
actionService.executeRecordsManagementAction(nodeRef, "unfreeze");
|
||||
return null;
|
||||
}
|
||||
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
}
|
||||
|
||||
public Role createRole(NodeRef filePlan, String roleName, String ... capabilityNames)
|
||||
{
|
||||
Set<Capability> capabilities = new HashSet<Capability>(capabilityNames.length);
|
||||
|
Reference in New Issue
Block a user