Search in sources :

Example 21 with Community

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());
}
Also used : XmlWorkflowItem(org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Collection(org.dspace.content.Collection) Workflow(org.dspace.xmlworkflow.state.Workflow) Community(org.dspace.content.Community) WorkspaceItem(org.dspace.content.WorkspaceItem) Test(org.junit.Test)

Example 22 with Community

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());
}
Also used : XmlWorkflowItem(org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Collection(org.dspace.content.Collection) Workflow(org.dspace.xmlworkflow.state.Workflow) Community(org.dspace.content.Community) WorkspaceItem(org.dspace.content.WorkspaceItem) Test(org.junit.Test)

Example 23 with Community

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());
}
Also used : XmlWorkflowItem(org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Collection(org.dspace.content.Collection) Workflow(org.dspace.xmlworkflow.state.Workflow) Community(org.dspace.content.Community) WorkspaceItem(org.dspace.content.WorkspaceItem) Test(org.junit.Test)

Example 24 with Community

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());
}
Also used : XmlWorkflowItem(org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Collection(org.dspace.content.Collection) Workflow(org.dspace.xmlworkflow.state.Workflow) Community(org.dspace.content.Community) WorkspaceItem(org.dspace.content.WorkspaceItem) Test(org.junit.Test)

Example 25 with Community

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();
    }
}
Also used : ScriptService(org.dspace.scripts.service.ScriptService) Collection(org.dspace.content.Collection) ScriptConfiguration(org.dspace.scripts.configuration.ScriptConfiguration) DSpaceRunnable(org.dspace.scripts.DSpaceRunnable) TestDSpaceRunnableHandler(org.dspace.app.scripts.handler.impl.TestDSpaceRunnableHandler) Community(org.dspace.content.Community) Test(org.junit.Test)

Aggregations

Community (org.dspace.content.Community)776 Test (org.junit.Test)653 Collection (org.dspace.content.Collection)651 AbstractControllerIntegrationTest (org.dspace.app.rest.test.AbstractControllerIntegrationTest)577 Item (org.dspace.content.Item)348 WorkspaceItem (org.dspace.content.WorkspaceItem)228 EPerson (org.dspace.eperson.EPerson)183 ArrayList (java.util.ArrayList)167 XmlWorkflowItem (org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem)131 Operation (org.dspace.app.rest.model.patch.Operation)127 ReplaceOperation (org.dspace.app.rest.model.patch.ReplaceOperation)123 InputStream (java.io.InputStream)115 AddOperation (org.dspace.app.rest.model.patch.AddOperation)114 RemoveOperation (org.dspace.app.rest.model.patch.RemoveOperation)96 ResourcePolicy (org.dspace.authorize.ResourcePolicy)78 Bitstream (org.dspace.content.Bitstream)76 Group (org.dspace.eperson.Group)71 Matchers.emptyOrNullString (org.hamcrest.Matchers.emptyOrNullString)71 HashMap (java.util.HashMap)59 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)53