Merge pull request #9508 from atmire/w2p-105866_Submission-performance-main

Submission performance
This commit is contained in:
Tim Donohue
2024-05-06 11:02:39 -05:00
committed by GitHub
17 changed files with 894 additions and 73 deletions

View File

@@ -65,11 +65,13 @@ public class DeleteFeature implements AuthorizationFeature {
@Override
public boolean isAuthorized(Context context, BaseObjectRest object) throws SQLException {
if (object instanceof BaseObjectRest) {
DSpaceObject dSpaceObject = (DSpaceObject) utils.getDSpaceAPIObjectFromRest(context, object);
if (object.getType().equals(WorkspaceItemRest.NAME)) {
object = ((WorkspaceItemRest)object).getItem();
WorkspaceItem workspaceItem = (WorkspaceItem) utils.getDSpaceAPIObjectFromRest(context, object);
dSpaceObject = workspaceItem.getItem();
}
DSpaceObject dSpaceObject = (DSpaceObject) utils.getDSpaceAPIObjectFromRest(context, object);
DSpaceObject parentObject = getParentObject(context, dSpaceObject);
switch (object.getType()) {

View File

@@ -70,11 +70,6 @@ public abstract class AInprogressItemConverter<T extends InProgressSubmission,
submitter = obj.getSubmitter();
witem.setId(obj.getID());
witem.setCollection(collection != null ? converter.toRest(collection, projection) : null);
witem.setItem(converter.toRest(item, projection));
if (submitter != null) {
witem.setSubmitter(converter.toRest(submitter, projection));
}
// 1. retrieve the submission definition
// 2. iterate over the submission section to allow to plugin additional

View File

@@ -22,16 +22,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
*/
public abstract class AInprogressSubmissionRest extends BaseObjectRest<Integer> {
private Date lastModified = new Date();
private Map<String, Serializable> sections;
@JsonIgnore
private CollectionRest collection;
@JsonIgnore
private ItemRest item;
@JsonIgnore
private SubmissionDefinitionRest submissionDefinition;
@JsonIgnore
private EPersonRest submitter;
public Date getLastModified() {
return lastModified;
@@ -41,14 +36,6 @@ public abstract class AInprogressSubmissionRest extends BaseObjectRest<Integer>
this.lastModified = lastModified;
}
public ItemRest getItem() {
return item;
}
public void setItem(ItemRest item) {
this.item = item;
}
public SubmissionDefinitionRest getSubmissionDefinition() {
return submissionDefinition;
}
@@ -57,14 +44,6 @@ public abstract class AInprogressSubmissionRest extends BaseObjectRest<Integer>
this.submissionDefinition = submissionDefinition;
}
public EPersonRest getSubmitter() {
return submitter;
}
public void setSubmitter(EPersonRest submitter) {
this.submitter = submitter;
}
public Map<String, Serializable> getSections() {
if (sections == null) {
sections = new HashMap<String, Serializable>();
@@ -76,12 +55,6 @@ public abstract class AInprogressSubmissionRest extends BaseObjectRest<Integer>
this.sections = sections;
}
public CollectionRest getCollection() {
return collection;
}
public void setCollection(CollectionRest collection) {
this.collection = collection;
}
}

View File

@@ -15,10 +15,22 @@ import org.dspace.app.rest.RestResourceController;
* @author Andrea Bollini (andrea.bollini at 4science.it)
*/
@LinksRest(links = {
@LinkRest(
name = WorkflowItemRest.STEP,
method = "getStep"
)
@LinkRest(
name = WorkflowItemRest.STEP,
method = "getStep"
),
@LinkRest(
name = WorkflowItemRest.SUBMITTER,
method = "getWorkflowItemSubmitter"
),
@LinkRest(
name = WorkflowItemRest.ITEM,
method = "getWorkflowItemItem"
),
@LinkRest(
name = WorkflowItemRest.COLLECTION,
method = "getWorkflowItemCollection"
)
})
public class WorkflowItemRest extends AInprogressSubmissionRest {
public static final String NAME = "workflowitem";
@@ -27,6 +39,11 @@ public class WorkflowItemRest extends AInprogressSubmissionRest {
public static final String STEP = "step";
public static final String SUBMITTER = "submitter";
public static final String ITEM = "item";
public static final String COLLECTION = "collection";
@Override
public String getCategory() {
return CATEGORY;

View File

@@ -18,6 +18,18 @@ import org.dspace.app.rest.RestResourceController;
@LinkRest(
name = WorkspaceItemRest.SUPERVISION_ORDERS,
method = "getSupervisionOrders"
),
@LinkRest(
name = WorkspaceItemRest.SUBMITTER,
method = "getWorkspaceItemSubmitter"
),
@LinkRest(
name = WorkspaceItemRest.ITEM,
method = "getWorkspaceItemItem"
),
@LinkRest(
name = WorkspaceItemRest.COLLECTION,
method = "getWorkspaceItemCollection"
)
})
public class WorkspaceItemRest extends AInprogressSubmissionRest {
@@ -26,6 +38,9 @@ public class WorkspaceItemRest extends AInprogressSubmissionRest {
public static final String CATEGORY = RestAddressableModel.SUBMISSION;
public static final String SUPERVISION_ORDERS = "supervisionOrders";
public static final String SUBMITTER = "submitter";
public static final String ITEM = "item";
public static final String COLLECTION = "collection";
@Override
public String getCategory() {

View File

@@ -0,0 +1,60 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import javax.annotation.Nullable;
import jakarta.servlet.http.HttpServletRequest;
import org.dspace.app.rest.model.CollectionRest;
import org.dspace.app.rest.model.WorkflowItemRest;
import org.dspace.app.rest.projection.Projection;
import org.dspace.core.Context;
import org.dspace.workflow.WorkflowItem;
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
/**
* Link repository for "collection" subresource of a workflow item.
*/
@Component(WorkflowItemRest.CATEGORY + "." + WorkflowItemRest.PLURAL_NAME + "." + WorkflowItemRest.COLLECTION)
public class WorkflowItemCollectionLinkRepository extends AbstractDSpaceRestRepository
implements LinkRestRepository {
@Autowired
XmlWorkflowItemService wis;
/**
* Retrieve the item for a workflow collection.
*
* @param request - The current request
* @param id - The workflow item ID for which to retrieve the collection
* @param optionalPageable - optional pageable object
* @param projection - the current projection
* @return the item for the workflow collection
*/
@PreAuthorize("hasPermission(#id, 'WORKFLOWITEM', 'READ')")
public CollectionRest getWorkflowItemCollection(@Nullable HttpServletRequest request, Integer id,
@Nullable Pageable optionalPageable, Projection projection) {
try {
Context context = obtainContext();
WorkflowItem witem = wis.find(context, id);
if (witem == null) {
throw new ResourceNotFoundException("No such workflow item: " + id);
}
return converter.toRest(witem.getCollection(), projection);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,60 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import javax.annotation.Nullable;
import jakarta.servlet.http.HttpServletRequest;
import org.dspace.app.rest.model.ItemRest;
import org.dspace.app.rest.model.WorkflowItemRest;
import org.dspace.app.rest.projection.Projection;
import org.dspace.core.Context;
import org.dspace.workflow.WorkflowItem;
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
/**
* Link repository for "item" subresource of a workflow item.
*/
@Component(WorkflowItemRest.CATEGORY + "." + WorkflowItemRest.PLURAL_NAME + "." + WorkflowItemRest.ITEM)
public class WorkflowItemItemLinkRepository extends AbstractDSpaceRestRepository
implements LinkRestRepository {
@Autowired
XmlWorkflowItemService wis;
/**
* Retrieve the item for a workflow item.
*
* @param request - The current request
* @param id - The workflow item ID for which to retrieve the item
* @param optionalPageable - optional pageable object
* @param projection - the current projection
* @return the item for the workflow item
*/
@PreAuthorize("hasPermission(#id, 'WORKFLOWITEM', 'READ')")
public ItemRest getWorkflowItemItem(@Nullable HttpServletRequest request, Integer id,
@Nullable Pageable optionalPageable, Projection projection) {
try {
Context context = obtainContext();
WorkflowItem witem = wis.find(context, id);
if (witem == null) {
throw new ResourceNotFoundException("No such workflow item: " + id);
}
return converter.toRest(witem.getItem(), projection);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,60 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import javax.annotation.Nullable;
import jakarta.servlet.http.HttpServletRequest;
import org.dspace.app.rest.model.EPersonRest;
import org.dspace.app.rest.model.WorkflowItemRest;
import org.dspace.app.rest.projection.Projection;
import org.dspace.core.Context;
import org.dspace.workflow.WorkflowItem;
import org.dspace.xmlworkflow.storedcomponents.service.XmlWorkflowItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
/**
* Link repository for "submitter" subresource of a workflow item.
*/
@Component(WorkflowItemRest.CATEGORY + "." + WorkflowItemRest.PLURAL_NAME + "." + WorkflowItemRest.SUBMITTER)
public class WorkflowItemSubmitterLinkRepository extends AbstractDSpaceRestRepository
implements LinkRestRepository {
@Autowired
XmlWorkflowItemService wis;
/**
* Retrieve the submitter for a workflow item.
*
* @param request - The current request
* @param id - The workflow item ID for which to retrieve the submitter
* @param optionalPageable - optional pageable object
* @param projection - the current projection
* @return the submitter for the workflow item
*/
@PreAuthorize("hasPermission(#id, 'WORKFLOWITEM', 'READ')")
public EPersonRest getWorkflowItemSubmitter(@Nullable HttpServletRequest request, Integer id,
@Nullable Pageable optionalPageable, Projection projection) {
try {
Context context = obtainContext();
WorkflowItem witem = wis.find(context, id);
if (witem == null) {
throw new ResourceNotFoundException("No such workflow item: " + id);
}
return converter.toRest(witem.getSubmitter(), projection);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,60 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import javax.annotation.Nullable;
import jakarta.servlet.http.HttpServletRequest;
import org.dspace.app.rest.model.CollectionRest;
import org.dspace.app.rest.model.WorkspaceItemRest;
import org.dspace.app.rest.projection.Projection;
import org.dspace.content.WorkspaceItem;
import org.dspace.content.service.WorkspaceItemService;
import org.dspace.core.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
/**
* Link repository for "collection" subresource of a workspace item.
*/
@Component(WorkspaceItemRest.CATEGORY + "." + WorkspaceItemRest.PLURAL_NAME + "." + WorkspaceItemRest.COLLECTION)
public class WorkspaceItemCollectionLinkRepository extends AbstractDSpaceRestRepository
implements LinkRestRepository {
@Autowired
WorkspaceItemService wis;
/**
* Retrieve the collection for a workspace item.
*
* @param request - The current request
* @param id - The workspace item ID for which to retrieve the collection
* @param optionalPageable - optional pageable object
* @param projection - the current projection
* @return the collection for the workspace item
*/
@PreAuthorize("hasPermission(#id, 'WORKSPACEITEM', 'READ')")
public CollectionRest getWorkspaceItemCollection(@Nullable HttpServletRequest request, Integer id,
@Nullable Pageable optionalPageable, Projection projection) {
try {
Context context = obtainContext();
WorkspaceItem witem = wis.find(context, id);
if (witem == null) {
throw new ResourceNotFoundException("No such workspace item: " + id);
}
return converter.toRest(witem.getCollection(), projection);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,60 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import javax.annotation.Nullable;
import jakarta.servlet.http.HttpServletRequest;
import org.dspace.app.rest.model.ItemRest;
import org.dspace.app.rest.model.WorkspaceItemRest;
import org.dspace.app.rest.projection.Projection;
import org.dspace.content.WorkspaceItem;
import org.dspace.content.service.WorkspaceItemService;
import org.dspace.core.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
/**
* Link repository for "item" subresource of a workspace item.
*/
@Component(WorkspaceItemRest.CATEGORY + "." + WorkspaceItemRest.PLURAL_NAME + "." + WorkspaceItemRest.ITEM)
public class WorkspaceItemItemLinkRepository extends AbstractDSpaceRestRepository
implements LinkRestRepository {
@Autowired
WorkspaceItemService wis;
/**
* Retrieve the item for a workspace item.
*
* @param request - The current request
* @param id - The workspace item ID for which to retrieve the item
* @param optionalPageable - optional pageable object
* @param projection - the current projection
* @return the item for the workspace item
*/
@PreAuthorize("hasPermission(#id, 'WORKSPACEITEM', 'READ')")
public ItemRest getWorkspaceItemItem(@Nullable HttpServletRequest request, Integer id,
@Nullable Pageable optionalPageable, Projection projection) {
try {
Context context = obtainContext();
WorkspaceItem witem = wis.find(context, id);
if (witem == null) {
throw new ResourceNotFoundException("No such workspace item: " + id);
}
return converter.toRest(witem.getItem(), projection);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,60 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import javax.annotation.Nullable;
import jakarta.servlet.http.HttpServletRequest;
import org.dspace.app.rest.model.EPersonRest;
import org.dspace.app.rest.model.WorkspaceItemRest;
import org.dspace.app.rest.projection.Projection;
import org.dspace.content.WorkspaceItem;
import org.dspace.content.service.WorkspaceItemService;
import org.dspace.core.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
/**
* Link repository for "submitter" subresource of a workspace item.
*/
@Component(WorkspaceItemRest.CATEGORY + "." + WorkspaceItemRest.PLURAL_NAME + "." + WorkspaceItemRest.SUBMITTER)
public class WorkspaceItemSubmitterLinkRepository extends AbstractDSpaceRestRepository
implements LinkRestRepository {
@Autowired
WorkspaceItemService wis;
/**
* Retrieve the submitter for a workspace item.
*
* @param request - The current request
* @param id - The workspace item ID for which to retrieve the submitter
* @param optionalPageable - optional pageable object
* @param projection - the current projection
* @return the submitter for the workspace item
*/
@PreAuthorize("hasPermission(#id, 'WORKSPACEITEM', 'READ')")
public EPersonRest getWorkspaceItemSubmitter(@Nullable HttpServletRequest request, Integer id,
@Nullable Pageable optionalPageable, Projection projection) {
try {
Context context = obtainContext();
WorkspaceItem witem = wis.find(context, id);
if (witem == null) {
throw new ResourceNotFoundException("No such workspace item: " + id);
}
return converter.toRest(witem.getSubmitter(), projection);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -5832,10 +5832,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
.andExpect(jsonPath("$._embedded.searchResult._embedded.objects", Matchers.contains(
SearchResultMatcher.match("workflow", "pooltask", "pooltasks")
)))
.andExpect(jsonPath("$._embedded.searchResult._embedded.objects",Matchers.contains(
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Mathematical Theory"))))
)))
.andExpect(jsonPath("$._embedded.searchResult.page.totalElements", is(1)));
getClient(adminToken).perform(get("/api/discover/search/objects")
@@ -5849,12 +5845,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
SearchResultMatcher.match("workflow", "pooltask", "pooltasks"),
SearchResultMatcher.match("workflow", "pooltask", "pooltasks")
)))
.andExpect(jsonPath("$._embedded.searchResult._embedded.objects",Matchers.containsInAnyOrder(
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Metaphysics")))),
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Test Metaphysics"))))
)))
.andExpect(jsonPath("$._embedded.searchResult.page.totalElements", is(2)));
}
@@ -5919,14 +5909,6 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
SearchResultMatcher.match("workflow", "pooltask", "pooltasks"),
SearchResultMatcher.match("workflow", "pooltask", "pooltasks")
)))
.andExpect(jsonPath("$._embedded.searchResult._embedded.objects",Matchers.containsInAnyOrder(
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Mathematical Theory")))),
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Metaphysics")))),
allOf(hasJsonPath("$._embedded.indexableObject._embedded.workflowitem._embedded.item",
is(SearchResultMatcher.matchEmbeddedObjectOnItemName("item", "Test Metaphysics"))))
)))
.andExpect(jsonPath("$._embedded.searchResult.page.totalElements", is(3)));
}

View File

@@ -191,6 +191,7 @@ public class LoginAsEPersonIT extends AbstractControllerIntegrationTest {
// create a workspaceitem explicitly in the col1
MvcResult mvcResult = getClient(authToken).perform(post("/api/submission/workspaceitems")
.param("owningCollection", col1.getID().toString())
.param("embed", "collection")
.header("X-On-Behalf-Of", eperson.getID())
.contentType(org.springframework
.http.MediaType.APPLICATION_JSON))
@@ -204,7 +205,8 @@ public class LoginAsEPersonIT extends AbstractControllerIntegrationTest {
Map<String,Object> map = mapper.readValue(content, Map.class);
String workspaceItemId = String.valueOf(map.get("id"));
getClient(authToken).perform(get("/api/submission/workspaceitems/" + workspaceItemId))
getClient(authToken).perform(get("/api/submission/workspaceitems/" + workspaceItemId)
.param("embed", "submitter"))
.andExpect(jsonPath("$._embedded.submitter", EPersonMatcher.matchProperties(eperson)));
}

View File

@@ -406,6 +406,7 @@ public class SuggestionRestRepositoryIT extends AbstractControllerIntegrationTes
ObjectMapper mapper = new ObjectMapper();
MvcResult mvcResult = getClient(adminToken).perform(
post("/api/submission/workspaceitems?owningCollection=" + colPublications.getID().toString())
.param("embed", "item")
.contentType(parseMediaType(TEXT_URI_LIST_VALUE))
.content("http://localhost/api/integration/externalsources/"
+ MockSuggestionExternalDataSource.NAME + "/entryValues/" + suggestionId))
@@ -415,7 +416,8 @@ public class SuggestionRestRepositoryIT extends AbstractControllerIntegrationTes
workspaceItemId = (Integer) map.get("id");
String itemUuidString = String.valueOf(((Map) ((Map) map.get("_embedded")).get("item")).get("uuid"));
getClient(adminToken).perform(get("/api/submission/workspaceitems/" + workspaceItemId))
getClient(adminToken).perform(get("/api/submission/workspaceitems/" + workspaceItemId)
.param("embed", "item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.allOf(
hasJsonPath("$.id", is(workspaceItemId)),

View File

@@ -0,0 +1,226 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import com.jayway.jsonpath.matchers.JsonPathMatchers;
import org.dspace.app.rest.matcher.CollectionMatcher;
import org.dspace.app.rest.matcher.EPersonMatcher;
import org.dspace.app.rest.matcher.ItemMatcher;
import org.dspace.app.rest.matcher.WorkflowItemMatcher;
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
import org.dspace.builder.CollectionBuilder;
import org.dspace.builder.CommunityBuilder;
import org.dspace.builder.EPersonBuilder;
import org.dspace.builder.WorkflowItemBuilder;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.eperson.EPerson;
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
import org.hamcrest.Matchers;
import org.junit.Test;
/**
* Test suite for the WorkflowItem Link repositories
*/
public class WorkflowItemRestLinkRepositoryIT extends AbstractControllerIntegrationTest {
@Test
/**
* The workflowitem resource endpoint must have an embeddable submitter
*
* @throws Exception
*/
public void findOneEmbedSubmitterTest() throws Exception {
context.turnOffAuthorisationSystem();
EPerson submitter = EPersonBuilder.createEPerson(context)
.withEmail("submitter@dspace.org")
.withNameInMetadata("Sub", "Mitter")
.build();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1)
.withName("Collection 1")
.withWorkflowGroup("reviewer", admin)
.build();
XmlWorkflowItem witem = WorkflowItemBuilder.createWorkflowItem(context, col1)
.withSubmitter(submitter)
.withTitle("Workflow Item 1")
.withIssueDate("2017-10-17")
.withAuthor("Smith, Donald").withAuthor("Doe, John")
.withSubject("ExtraEntry")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID())).andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workflow Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$", JsonPathMatchers.hasNoJsonPath("$._embedded.submitter")));
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID()).param("embed", "submitter"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workflow Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$._embedded.submitter", Matchers.is(
EPersonMatcher.matchEPersonEntry(submitter))));
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID() + "/submitter"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", EPersonMatcher.matchEPersonEntry(submitter)));
}
@Test
/**
* The workflowitem resource endpoint must have an embeddable collection
*
* @throws Exception
*/
public void findOneEmbedCollectionTest() throws Exception {
context.turnOffAuthorisationSystem();
EPerson submitter = EPersonBuilder.createEPerson(context)
.withEmail("submitter@dspace.org")
.withNameInMetadata("Sub", "Mitter")
.build();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1)
.withName("Collection 1")
.withWorkflowGroup("reviewer", admin)
.build();
XmlWorkflowItem witem = WorkflowItemBuilder.createWorkflowItem(context, col1)
.withSubmitter(submitter)
.withTitle("Workflow Item 1")
.withIssueDate("2017-10-17")
.withAuthor("Smith, Donald").withAuthor("Doe, John")
.withSubject("ExtraEntry")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID())).andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workflow Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$", JsonPathMatchers.hasNoJsonPath("$._embedded.collection")));
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID()).param("embed", "collection"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workflow Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$._embedded.collection", Matchers.is(
CollectionMatcher.matchCollection(col1))));
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID() + "/collection"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", CollectionMatcher.matchCollection(col1)));
}
@Test
/**
* The workflowitem resource endpoint must have an embeddable item
*
* @throws Exception
*/
public void findOneEmbedItemTest() throws Exception {
context.turnOffAuthorisationSystem();
EPerson submitter = EPersonBuilder.createEPerson(context)
.withEmail("submitter@dspace.org")
.withNameInMetadata("Sub", "Mitter")
.build();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1)
.withName("Collection 1")
.withWorkflowGroup("reviewer", admin)
.build();
XmlWorkflowItem witem = WorkflowItemBuilder.createWorkflowItem(context, col1)
.withSubmitter(submitter)
.withTitle("Workflow Item 1")
.withIssueDate("2017-10-17")
.withAuthor("Smith, Donald").withAuthor("Doe, John")
.withSubject("ExtraEntry")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID())).andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workflow Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$", JsonPathMatchers.hasNoJsonPath("$._embedded.item")));
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID()).param("embed", "item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workflow Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$._embedded.item", Matchers.is(
ItemMatcher.matchItemProperties(witem.getItem()))));
getClient(authToken).perform(get("/api/workflow/workflowitems/" + witem.getID() + "/item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", ItemMatcher.matchItemProperties(witem.getItem())));
}
}

View File

@@ -0,0 +1,222 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import com.jayway.jsonpath.matchers.JsonPathMatchers;
import org.dspace.app.rest.matcher.CollectionMatcher;
import org.dspace.app.rest.matcher.EPersonMatcher;
import org.dspace.app.rest.matcher.ItemMatcher;
import org.dspace.app.rest.matcher.WorkspaceItemMatcher;
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
import org.dspace.builder.CollectionBuilder;
import org.dspace.builder.CommunityBuilder;
import org.dspace.builder.EPersonBuilder;
import org.dspace.builder.WorkspaceItemBuilder;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.WorkspaceItem;
import org.dspace.eperson.EPerson;
import org.hamcrest.Matchers;
import org.junit.Test;
/**
* Test suite for the WorkspaceItem Link repositories
*/
public class WorkspaceItemRestLinkRepositoryIT extends AbstractControllerIntegrationTest {
@Test
/**
* The workspaceitem resource endpoint must have an embeddable submitter
*
* @throws Exception
*/
public void findOneEmbedSubmitterTest() throws Exception {
context.turnOffAuthorisationSystem();
EPerson submitter = EPersonBuilder.createEPerson(context)
.withEmail("submitter@dspace.org")
.withNameInMetadata("Sub", "Mitter")
.build();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
//2. a workspace item
WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1)
.withSubmitter(submitter)
.withTitle("Workspace Item 1")
.withIssueDate("2017-10-17")
.withAuthor("Smith, Donald").withAuthor("Doe, John")
.withSubject("ExtraEntry")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())).andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkspaceItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workspace Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$", JsonPathMatchers.hasNoJsonPath("$._embedded.submitter")));
getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID()).param("embed", "submitter"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkspaceItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workspace Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$._embedded.submitter", Matchers.is(
EPersonMatcher.matchEPersonEntry(submitter))));
getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID() + "/submitter"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", EPersonMatcher.matchEPersonEntry(submitter)));
}
@Test
/**
* The workspaceitem resource endpoint must have an embeddable collection
*
* @throws Exception
*/
public void findOneEmbedCollectionTest() throws Exception {
context.turnOffAuthorisationSystem();
EPerson submitter = EPersonBuilder.createEPerson(context)
.withEmail("submitter@dspace.org")
.withNameInMetadata("Sub", "Mitter")
.build();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
//2. a workspace item
WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1)
.withSubmitter(submitter)
.withTitle("Workspace Item 1")
.withIssueDate("2017-10-17")
.withAuthor("Smith, Donald").withAuthor("Doe, John")
.withSubject("ExtraEntry")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())).andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkspaceItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workspace Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$", JsonPathMatchers.hasNoJsonPath("$._embedded.collection")));
getClient(authToken).perform(
get("/api/submission/workspaceitems/" + witem.getID()).param("embed", "collection"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkspaceItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workspace Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$._embedded.collection", Matchers.is(
CollectionMatcher.matchCollection(col1))));
getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID() + "/collection"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", CollectionMatcher.matchCollection(col1)));
}
@Test
/**
* The workspaceitem resource endpoint must have an embeddable item
*
* @throws Exception
*/
public void findOneEmbedItemTest() throws Exception {
context.turnOffAuthorisationSystem();
EPerson submitter = EPersonBuilder.createEPerson(context)
.withEmail("submitter@dspace.org")
.withNameInMetadata("Sub", "Mitter")
.build();
//** GIVEN **
//1. A community-collection structure with one parent community with sub-community and two collections.
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
.withName("Sub Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
//2. a workspace item
WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1)
.withSubmitter(submitter)
.withTitle("Workspace Item 1")
.withIssueDate("2017-10-17")
.withAuthor("Smith, Donald").withAuthor("Doe, John")
.withSubject("ExtraEntry")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID())).andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkspaceItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workspace Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$", JsonPathMatchers.hasNoJsonPath("$._embedded.item")));
getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID()).param("embed", "item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.is(
WorkspaceItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
"Workspace Item 1",
"2017-10-17",
"ExtraEntry"))))
.andExpect(jsonPath("$._embedded.item", Matchers.is(
ItemMatcher.matchItemProperties(witem.getItem()))));
getClient(authToken).perform(get("/api/submission/workspaceitems/" + witem.getID() + "/item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", ItemMatcher.matchItemProperties(witem.getItem())));
}
}

View File

@@ -883,6 +883,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
// create a workspaceitem explicitly in the col1
getClient(authToken).perform(post("/api/submission/workspaceitems")
.param("owningCollection", col1.getID().toString())
.param("embed", "collection")
.contentType(org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(status().isCreated())
.andExpect(jsonPath("$._embedded.collection.id", is(col1.getID().toString())))
@@ -891,6 +892,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
// create a workspaceitem explicitly in the col2
getClient(authToken).perform(post("/api/submission/workspaceitems")
.param("owningCollection", col2.getID().toString())
.param("embed", "collection")
.contentType(org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(status().isCreated())
.andExpect(jsonPath("$._embedded.collection.id", is(col2.getID().toString())))
@@ -899,10 +901,10 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
// create a workspaceitem without an explicit collection, this will go in the first valid collection for the
// user: the col1
getClient(authToken).perform(post("/api/submission/workspaceitems")
.param("embed", "collection")
.contentType(org.springframework.http.MediaType.APPLICATION_JSON))
.andExpect(status().isCreated())
.andExpect(jsonPath("$._embedded.collection.id", is(col1.getID().toString())))
.andExpect(jsonPath("$", WorkspaceItemMatcher.matchFullEmbeds()))
.andDo(result -> idRef3.set(read(result.getResponse().getContentAsString(), "$.id")));
@@ -950,7 +952,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile))
.file(bibtexFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -979,6 +982,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -1042,7 +1046,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile))
.file(bibtexFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0]" +
@@ -1076,6 +1081,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0]" +
@@ -1139,7 +1145,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile))
.file(bibtexFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections." +
@@ -1170,6 +1177,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections." +
@@ -1236,7 +1244,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile))
.file(bibtexFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0]" +
@@ -1276,6 +1285,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0]" +
@@ -1341,7 +1351,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
AtomicReference<List<Integer>> idRef = new AtomicReference<>();
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(csvFile))
.file(csvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -1381,6 +1392,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(csvFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone"
@@ -1458,7 +1470,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(csvFile))
.file(csvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -1536,7 +1549,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
// create workspaceitems in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(tsvFile))
.file(tsvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -1612,7 +1626,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
// create workspaceitems in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(tsvFile))
.file(tsvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -1689,7 +1704,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
// create workspaceitems in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(endnoteFile))
.file(endnoteFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -1768,7 +1784,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
// create workspaceitems in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(csvFile))
.file(csvFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -1849,7 +1866,9 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
// create a workspaceitem from a single bibliographic entry file explicitly in the default collection (col1)
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile).file(pubmedFile))
.file(bibtexFile)
.file(pubmedFile)
.param("embed", "collection"))
// create should return 200, 201 (created) is better for single resource
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -1884,6 +1903,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
try {
getClient(authToken).perform(multipart("/api/submission/workspaceitems")
.file(bibtexFile).file(pubmedFile)
.param("embed", "collection")
.param("owningCollection", col2.getID().toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
@@ -4328,6 +4348,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
String token = getAuthToken(admin.getEmail(), password);
MvcResult mvcResult = getClient(token).perform(post("/api/submission/workspaceitems?owningCollection="
+ col1.getID().toString())
.param("embed", "item")
.contentType(parseMediaType(TEXT_URI_LIST_VALUE))
.content("https://localhost:8080/server/api/integration/" +
"externalsources/mock/entryValues/one"))
@@ -4338,7 +4359,8 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
workspaceItemId = (Integer) map.get("id");
String itemUuidString = String.valueOf(((Map) ((Map) map.get("_embedded")).get("item")).get("uuid"));
getClient(token).perform(get("/api/submission/workspaceitems/" + workspaceItemId))
getClient(token).perform(get("/api/submission/workspaceitems/" + workspaceItemId)
.param("embed", "item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.allOf(
hasJsonPath("$.id", is(workspaceItemId)),
@@ -4533,6 +4555,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
String token = getAuthToken(eperson.getEmail(), password);
getClient(token).perform(post("/api/submission/workspaceitems")
.param("embed", "collection")
.param("owningCollection", col1.getID().toString())
.contentType(parseMediaType(TEXT_URI_LIST_VALUE))
.content("https://localhost:8080/server/api/integration/externalsources/" +
@@ -4542,7 +4565,9 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
.andDo(result -> idRef.set(read(result.getResponse().getContentAsString(), "$.id")));
workspaceItemId = idRef.get();
getClient(token).perform(get("/api/submission/workspaceitems/" + workspaceItemId))
getClient(token).perform(get("/api/submission/workspaceitems/" + workspaceItemId)
.param("embed", "collection")
.param("embed", "item"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", Matchers.allOf(
hasJsonPath("$.id", is(workspaceItemId)),