use of org.dspace.content.Community in project DSpace by DSpace.
the class EPersonInWorkflowIT method testDeleteUserWhenOnlyUserInGroup5.
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test verifies a user can't be removed from a workflow step they have claimed
* items for that task. This test also verifies that this verification is using both the step and the collection
* to determine whether the user can be removed from a workflow group. This test also verifies that after user has
* been removed from the workflow group and the task has been passed, the EPerson can be removed.
*
* @throws Exception
*/
@Test
public void testDeleteUserWhenOnlyUserInGroup5() throws Exception {
/*
* This test has the following setup:
* - Collection A - Step 1: user B
* - Collection A - Step 2: user C
* - Collection A - Step 3: user B
*
* - Collection B - Step 1: user B
*
* This test will perform the following checks:
* - create a workspace item in Collection A, and let it move to step 1
* - claim it by user B
* - delete user B
* - verify the delete is refused
* - remove user B from Col A - step 3
* - remove user B from Col B - step 1
* - remove user B from Col A - step 1
* - Verify that the removal from Col A - step 1 is refused because user B has a claimed task in that
* collection and no other user is present
* - approve it by user B, and let it move to step 2
* - remove user B from Col A - step 1
* - verify it succeeds
* - delete user B
* - verify it succeeds
* - approve it by user C
* - verify that the item is archived
*/
context.turnOffAuthorisationSystem();
Community parent = CommunityBuilder.createCommunity(context).build();
Collection collectionA = CollectionBuilder.createCollection(context, parent).withWorkflowGroup(1, workflowUserB).withWorkflowGroup(2, workflowUserC).withWorkflowGroup(3, workflowUserB).build();
Collection collectionB = CollectionBuilder.createCollection(context, parent).withWorkflowGroup(1, workflowUserB).build();
WorkspaceItem wsi = WorkspaceItemBuilder.createWorkspaceItem(context, collectionA).withSubmitter(workflowUserA).withTitle("Test item full workflow").withIssueDate("2019-03-06").withSubject("ExtraEntry").build();
Workflow workflow = XmlWorkflowServiceFactory.getInstance().getWorkflowFactory().getWorkflow(collectionA);
XmlWorkflowItem workflowItem = xmlWorkflowService.startWithoutNotify(context, wsi);
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
httpServletRequest.setParameter("submit_approve", "submit_approve");
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, REVIEW_STEP, CLAIM_ACTION);
assertRemovalOfEpersonFromWorkflowGroup(workflowUserB, collectionA, FINAL_EDIT_ROLE, true);
assertRemovalOfEpersonFromWorkflowGroup(workflowUserB, collectionB, REVIEW_ROLE, true);
assertRemovalOfEpersonFromWorkflowGroup(workflowUserB, collectionA, REVIEW_ROLE, false);
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, REVIEW_STEP, REVIEW_ACTION);
assertRemovalOfEpersonFromWorkflowGroup(workflowUserB, collectionA, REVIEW_ROLE, true);
assertDeletionOfEperson(workflowUserB, true);
executeWorkflowAction(httpServletRequest, workflowUserC, workflow, workflowItem, EDIT_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserC, workflow, workflowItem, EDIT_STEP, EDIT_ACTION);
assertTrue(workflowItem.getItem().isArchived());
}
use of org.dspace.content.Community in project DSpace by DSpace.
the class EPersonInWorkflowIT method testDeleteUserAfterReplacingUser3.
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has an
* item present in a workflow with a pooled task. This test verifies this with an item that has entered the workflow
* and is still to progress to the step where the user will be removed.
* This test also verifies that after a new user has been added to this step, the original user can be removed. This
* test then verifies that the item can proceed through the full workflow and is correctly archived at the end.
*
* @throws Exception
*/
@Test
public void testDeleteUserAfterReplacingUser3() throws Exception {
/*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
* - Step 3: user B
*
* This test will perform the following checks:
* - create a workspace item, and let it move to step 1
* - delete user C
* - verify the delete is refused
* - add user D to workflow step 2
* - delete user C
* - verify the delete succeeds
* - Approve it by user B
* - verify that the item moved to step 2
* - Approve it by user D
* - verify that the item moved to step 3
* - Approve it by user B
* - verify that the item is archived
*/
context.turnOffAuthorisationSystem();
Community parent = CommunityBuilder.createCommunity(context).build();
Collection collection = CollectionBuilder.createCollection(context, parent).withWorkflowGroup(1, workflowUserB).withWorkflowGroup(2, workflowUserC).withWorkflowGroup(3, workflowUserB).build();
WorkspaceItem wsi = WorkspaceItemBuilder.createWorkspaceItem(context, collection).withSubmitter(workflowUserA).withTitle("Test item full workflow").withIssueDate("2019-03-06").withSubject("ExtraEntry").build();
Workflow workflow = XmlWorkflowServiceFactory.getInstance().getWorkflowFactory().getWorkflow(collection);
XmlWorkflowItem workflowItem = xmlWorkflowService.startWithoutNotify(context, wsi);
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
httpServletRequest.setParameter("submit_approve", "submit_approve");
assertDeletionOfEperson(workflowUserC, false);
addUserToWorkflowGroup(workflowUserD, collection, EDIT_ROLE);
assertDeletionOfEperson(workflowUserC, true);
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, REVIEW_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, REVIEW_STEP, REVIEW_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserD, workflow, workflowItem, EDIT_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserD, workflow, workflowItem, EDIT_STEP, EDIT_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, FINAL_EDIT_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, FINAL_EDIT_STEP, FINAL_EDIT_ACTION);
assertTrue(workflowItem.getItem().isArchived());
}
use of org.dspace.content.Community in project DSpace by DSpace.
the class EPersonInWorkflowIT method testDeleteUserAfterReplacingUser1.
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test verifies this with a pooled task in the last workflow step.
* This test also verifies that after after another user has been added to the workflow groups, the original EPerson
* can be removed.
*
* @throws Exception
*/
@Test
public void testDeleteUserAfterReplacingUser1() throws Exception {
/*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
* - Step 3: user B
*
* This test will perform the following checks:
* - create a workspace item, and let it move to step 1
* - approve it by user B
* - verify that the item moved to step 2
* - Approve it by user C
* - delete user B
* - verify the delete is refused
* - add user D to workflow step 3
* - delete user B
* - verify the delete is refused
* - add user D to workflow step 1
* - delete user B
* - verify the delete succeeds
* - Approve it by user D
* - verify that the item is archived
*/
context.turnOffAuthorisationSystem();
Community parent = CommunityBuilder.createCommunity(context).build();
Collection collection = CollectionBuilder.createCollection(context, parent).withWorkflowGroup(1, workflowUserB).withWorkflowGroup(2, workflowUserC).withWorkflowGroup(3, workflowUserB).build();
WorkspaceItem wsi = WorkspaceItemBuilder.createWorkspaceItem(context, collection).withSubmitter(workflowUserA).withTitle("Test item full workflow").withIssueDate("2019-03-06").withSubject("ExtraEntry").build();
Workflow workflow = XmlWorkflowServiceFactory.getInstance().getWorkflowFactory().getWorkflow(collection);
XmlWorkflowItem workflowItem = xmlWorkflowService.startWithoutNotify(context, wsi);
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
httpServletRequest.setParameter("submit_approve", "submit_approve");
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, REVIEW_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, REVIEW_STEP, REVIEW_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserC, workflow, workflowItem, EDIT_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserC, workflow, workflowItem, EDIT_STEP, EDIT_ACTION);
assertDeletionOfEperson(workflowUserB, false);
addUserToWorkflowGroup(workflowUserD, collection, FINAL_EDIT_ROLE);
assertDeletionOfEperson(workflowUserB, false);
addUserToWorkflowGroup(workflowUserD, collection, REVIEW_ROLE);
assertDeletionOfEperson(workflowUserB, true);
executeWorkflowAction(httpServletRequest, workflowUserD, workflow, workflowItem, FINAL_EDIT_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserD, workflow, workflowItem, FINAL_EDIT_STEP, FINAL_EDIT_ACTION);
assertTrue(workflowItem.getItem().isArchived());
}
use of org.dspace.content.Community in project DSpace by DSpace.
the class EPersonInWorkflowIT method testDeleteUserWhenMultipleUser6.
/**
* This test verifies that an EPerson can be removed if there is another user is present in the Workflow Group.
* This test verifies this with a claimed task in the final workflow step.
* This test also verifies that the claimed task will return the final workflow's step task pool and that the other
* user can claim the task and complete workflow.
* This test then verifies that the item will be archived.
*
* @throws Exception
*/
@Test
public void testDeleteUserWhenMultipleUser6() throws Exception {
/*
* This test has the following setup:
* - Step 1: user B and D
* - Step 2: user C and D
* - Step 3: user B and D
*
* This test will perform the following checks:
* - create a workspace item, and let it move to step 1
* - Approve it by user B
* - verify that the item moved to step 2
* - Approve it by user C
* - verify that the item moved to step 3
* - claim it by user B, but don’t approve it
* - delete user B
* - verify the delete succeeds
* - Verify user D can now claim and approve it
* - verify that the item is archived
*/
context.turnOffAuthorisationSystem();
Community parent = CommunityBuilder.createCommunity(context).build();
Collection collection = CollectionBuilder.createCollection(context, parent).withWorkflowGroup(1, workflowUserB, workflowUserD).withWorkflowGroup(2, workflowUserC, workflowUserD).withWorkflowGroup(3, workflowUserB, workflowUserD).build();
WorkspaceItem wsi = WorkspaceItemBuilder.createWorkspaceItem(context, collection).withSubmitter(workflowUserA).withTitle("Test item full workflow").withIssueDate("2019-03-06").withSubject("ExtraEntry").build();
Workflow workflow = XmlWorkflowServiceFactory.getInstance().getWorkflowFactory().getWorkflow(collection);
XmlWorkflowItem workflowItem = xmlWorkflowService.startWithoutNotify(context, wsi);
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
httpServletRequest.setParameter("submit_approve", "submit_approve");
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, REVIEW_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, REVIEW_STEP, REVIEW_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserC, workflow, workflowItem, EDIT_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserC, workflow, workflowItem, EDIT_STEP, EDIT_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserB, workflow, workflowItem, FINAL_EDIT_STEP, CLAIM_ACTION);
assertDeletionOfEperson(workflowUserB, true);
executeWorkflowAction(httpServletRequest, workflowUserD, workflow, workflowItem, FINAL_EDIT_STEP, CLAIM_ACTION);
executeWorkflowAction(httpServletRequest, workflowUserD, workflow, workflowItem, FINAL_EDIT_STEP, FINAL_EDIT_ACTION);
assertTrue(workflowItem.getItem().isArchived());
}
use of org.dspace.content.Community in project DSpace by DSpace.
the class CurationIT method curationWithoutEPersonParameterTest.
@Test(expected = ParseException.class)
public void curationWithoutEPersonParameterTest() throws Exception {
context.turnOffAuthorisationSystem();
Community community = CommunityBuilder.createCommunity(context).build();
Collection collection = CollectionBuilder.createCollection(context, community).build();
context.restoreAuthSystemState();
String[] args = new String[] { "curate", "-t", CurationClientOptions.getTaskOptions().get(0), "-i", collection.getHandle() };
TestDSpaceRunnableHandler testDSpaceRunnableHandler = new TestDSpaceRunnableHandler();
ScriptService scriptService = ScriptServiceFactory.getInstance().getScriptService();
ScriptConfiguration scriptConfiguration = scriptService.getScriptConfiguration(args[0]);
DSpaceRunnable script = null;
if (scriptConfiguration != null) {
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
}
if (script != null) {
script.initialize(args, testDSpaceRunnableHandler, null);
script.run();
}
}
Aggregations