mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
[CST-5587] Fixed orcid tests
This commit is contained in:
@@ -25,6 +25,7 @@ import javax.persistence.TemporalType;
|
|||||||
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "orcid_history")
|
@Table(name = "orcid_history")
|
||||||
@@ -53,6 +54,7 @@ public class OrcidHistory implements ReloadableEntity<Integer> {
|
|||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Lob
|
@Lob
|
||||||
|
@Type(type = "org.dspace.storage.rdbms.hibernate.DatabaseAwareLobType")
|
||||||
@Column(name = "metadata")
|
@Column(name = "metadata")
|
||||||
private String metadata;
|
private String metadata;
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@ public class OrcidHistory implements ReloadableEntity<Integer> {
|
|||||||
private OrcidOperation operation;
|
private OrcidOperation operation;
|
||||||
|
|
||||||
@Lob
|
@Lob
|
||||||
|
@Type(type = "org.dspace.storage.rdbms.hibernate.DatabaseAwareLobType")
|
||||||
@Column(name = "response_message")
|
@Column(name = "response_message")
|
||||||
private String responseMessage;
|
private String responseMessage;
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@ import javax.persistence.Table;
|
|||||||
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.core.ReloadableEntity;
|
import org.dspace.core.ReloadableEntity;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity that model a record on the ORCID synchronization queue.
|
* Entity that model a record on the ORCID synchronization queue.
|
||||||
@@ -61,6 +62,7 @@ public class OrcidQueue implements ReloadableEntity<Integer> {
|
|||||||
|
|
||||||
@Lob
|
@Lob
|
||||||
@Column(name = "metadata")
|
@Column(name = "metadata")
|
||||||
|
@Type(type = "org.dspace.storage.rdbms.hibernate.DatabaseAwareLobType")
|
||||||
private String metadata;
|
private String metadata;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
|
@@ -16,14 +16,17 @@ import static org.dspace.eperson.Group.ANONYMOUS;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.dspace.app.exception.ResourceAlreadyExistsException;
|
import org.dspace.app.exception.ResourceAlreadyExistsException;
|
||||||
|
import org.dspace.app.profile.service.AfterResearcherProfileCreationAction;
|
||||||
import org.dspace.app.profile.service.ResearcherProfileService;
|
import org.dspace.app.profile.service.ResearcherProfileService;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.service.AuthorizeService;
|
import org.dspace.authorize.service.AuthorizeService;
|
||||||
@@ -86,6 +89,18 @@ public class ResearcherProfileServiceImpl implements ResearcherProfileService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AuthorizeService authorizeService;
|
private AuthorizeService authorizeService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private List<AfterResearcherProfileCreationAction> afterCreationActions;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void postConstruct() {
|
||||||
|
|
||||||
|
if (afterCreationActions == null) {
|
||||||
|
afterCreationActions = Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResearcherProfile findById(Context context, UUID id) throws SQLException, AuthorizeException {
|
public ResearcherProfile findById(Context context, UUID id) throws SQLException, AuthorizeException {
|
||||||
Assert.notNull(id, "An id must be provided to find a researcher profile");
|
Assert.notNull(id, "An id must be provided to find a researcher profile");
|
||||||
@@ -111,15 +126,16 @@ public class ResearcherProfileServiceImpl implements ResearcherProfileService {
|
|||||||
.orElseThrow(() -> new IllegalStateException("No collection found for researcher profiles"));
|
.orElseThrow(() -> new IllegalStateException("No collection found for researcher profiles"));
|
||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
try {
|
|
||||||
|
|
||||||
Item item = createProfileItem(context, ePerson, collection);
|
Item item = createProfileItem(context, ePerson, collection);
|
||||||
return new ResearcherProfile(item);
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
ResearcherProfile researcherProfile = new ResearcherProfile(item);
|
||||||
|
|
||||||
|
for (AfterResearcherProfileCreationAction afterCreationAction : afterCreationActions) {
|
||||||
|
afterCreationAction.perform(context, researcherProfile, ePerson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return researcherProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -586,7 +586,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
|||||||
|
|
||||||
String schema = "dc";
|
String schema = "dc";
|
||||||
String element = "contributor";
|
String element = "contributor";
|
||||||
String qualifier = "author";
|
String qualifier = "editor";
|
||||||
String lang = Item.ANY;
|
String lang = Item.ANY;
|
||||||
List<String> values = Arrays.asList("value0", "value1");
|
List<String> values = Arrays.asList("value0", "value1");
|
||||||
List<String> authorities = Arrays.asList("auth0", "auth2");
|
List<String> authorities = Arrays.asList("auth0", "auth2");
|
||||||
@@ -682,7 +682,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
|||||||
|
|
||||||
String schema = "dc";
|
String schema = "dc";
|
||||||
String element = "contributor";
|
String element = "contributor";
|
||||||
String qualifier = "author";
|
String qualifier = "editor";
|
||||||
String lang = Item.ANY;
|
String lang = Item.ANY;
|
||||||
String values = "value0";
|
String values = "value0";
|
||||||
String authorities = "auth0";
|
String authorities = "auth0";
|
||||||
|
@@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.exception.ResourceAlreadyExistsException;
|
import org.dspace.app.exception.ResourceAlreadyExistsException;
|
||||||
|
import org.dspace.app.orcid.exception.OrcidValidationException;
|
||||||
import org.dspace.app.rest.utils.ContextUtil;
|
import org.dspace.app.rest.utils.ContextUtil;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -134,6 +135,12 @@ public class DSpaceApiExceptionControllerAdvice extends ResponseEntityExceptionH
|
|||||||
HttpStatus.UNPROCESSABLE_ENTITY.value());
|
HttpStatus.UNPROCESSABLE_ENTITY.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler({ OrcidValidationException.class })
|
||||||
|
protected void handleOrcidValidationException(HttpServletRequest request, HttpServletResponse response,
|
||||||
|
OrcidValidationException ex) throws IOException {
|
||||||
|
sendErrorResponse(request, response, ex, ex.getMessage(), HttpStatus.UNPROCESSABLE_ENTITY.value());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add user-friendly error messages to the response body for selected errors.
|
* Add user-friendly error messages to the response body for selected errors.
|
||||||
* Since the error messages will be exposed to the API user, the
|
* Since the error messages will be exposed to the API user, the
|
||||||
|
@@ -79,7 +79,7 @@ public class OrcidQueueSearchRestPermissionEvaluatorPlugin extends RestObjectPer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasAccess(EPerson ePerson, Item owner) {
|
private boolean hasAccess(EPerson ePerson, Item owner) {
|
||||||
List<MetadataValue> values = itemService.getMetadata(owner, "cris", "owner", null, Item.ANY);
|
List<MetadataValue> values = itemService.getMetadata(owner, "dspace", "object", "owner", Item.ANY);
|
||||||
if (values.get(0).getAuthority().equals(ePerson.getID().toString())) {
|
if (values.get(0).getAuthority().equals(ePerson.getID().toString())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -56,6 +56,7 @@ import org.dspace.content.Community;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.authority.Choices;
|
import org.dspace.content.authority.Choices;
|
||||||
|
import org.dspace.content.authority.service.ChoiceAuthorityService;
|
||||||
import org.dspace.content.authority.service.MetadataAuthorityService;
|
import org.dspace.content.authority.service.MetadataAuthorityService;
|
||||||
import org.dspace.discovery.configuration.DiscoverySortFieldConfiguration;
|
import org.dspace.discovery.configuration.DiscoverySortFieldConfiguration;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -77,6 +78,8 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
|
|||||||
@Autowired
|
@Autowired
|
||||||
MetadataAuthorityService metadataAuthorityService;
|
MetadataAuthorityService metadataAuthorityService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ChoiceAuthorityService choiceAuthorityService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rootDiscoverTest() throws Exception {
|
public void rootDiscoverTest() throws Exception {
|
||||||
@@ -200,6 +203,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
|
|||||||
configurationService.setProperty("authority.controlled.dc.contributor.author", "true");
|
configurationService.setProperty("authority.controlled.dc.contributor.author", "true");
|
||||||
|
|
||||||
metadataAuthorityService.clearCache();
|
metadataAuthorityService.clearCache();
|
||||||
|
choiceAuthorityService.clearCache();
|
||||||
|
|
||||||
//Turn off the authorization system, otherwise we can't make the objects
|
//Turn off the authorization system, otherwise we can't make the objects
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
@@ -281,6 +285,7 @@ public class DiscoveryRestControllerIT extends AbstractControllerIntegrationTest
|
|||||||
DSpaceServicesFactory.getInstance().getConfigurationService().reloadConfig();
|
DSpaceServicesFactory.getInstance().getConfigurationService().reloadConfig();
|
||||||
|
|
||||||
metadataAuthorityService.clearCache();
|
metadataAuthorityService.clearCache();
|
||||||
|
choiceAuthorityService.clearCache();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1891,7 +1891,7 @@ public class ResearcherProfileRestRepositoryIT extends AbstractControllerIntegra
|
|||||||
getClient(authToken)
|
getClient(authToken)
|
||||||
.perform(post("/api/eperson/profiles/").contentType(TEXT_URI_LIST)
|
.perform(post("/api/eperson/profiles/").contentType(TEXT_URI_LIST)
|
||||||
.content("http://localhost:8080/server/api/core/items/" + id))
|
.content("http://localhost:8080/server/api/core/items/" + id))
|
||||||
.andExpect(status().isConflict());
|
.andExpect(status().isUnprocessableEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Item createProfile(EPerson ePerson) throws Exception {
|
private Item createProfile(EPerson ePerson) throws Exception {
|
||||||
|
@@ -612,7 +612,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
|||||||
.withDescription("IT")
|
.withDescription("IT")
|
||||||
.withOperation(OrcidOperation.INSERT)
|
.withOperation(OrcidOperation.INSERT)
|
||||||
.withRecordType("COUNTRY")
|
.withRecordType("COUNTRY")
|
||||||
.withMetadata("crisrp.country::IT")
|
.withMetadata("person.country::IT")
|
||||||
.build();
|
.build();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
@@ -668,7 +668,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
|||||||
.withDescription("IT")
|
.withDescription("IT")
|
||||||
.withOperation(OrcidOperation.DELETE)
|
.withOperation(OrcidOperation.DELETE)
|
||||||
.withRecordType("COUNTRY")
|
.withRecordType("COUNTRY")
|
||||||
.withMetadata("crisrp.country::IT")
|
.withMetadata("person.country::IT")
|
||||||
.withPutCode("12345")
|
.withPutCode("12345")
|
||||||
.build();
|
.build();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
@@ -45,7 +45,7 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
@Test
|
@Test
|
||||||
public void findAllTest() throws Exception {
|
public void findAllTest() throws Exception {
|
||||||
String authToken = getAuthToken(admin.getEmail(), password);
|
String authToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(authToken).perform(get("/api/cris/orcidqueues"))
|
getClient(authToken).perform(get("/api/eperson/orcidqueues"))
|
||||||
.andExpect(status().isMethodNotAllowed());
|
.andExpect(status().isMethodNotAllowed());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +111,6 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
.withTitle("Title Project")
|
.withTitle("Title Project")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
itemService.addMetadata(context, itemPerson, "crisevent", "description", "keywords", null, "psychoceramics");
|
|
||||||
itemService.addMetadata(context, itemPerson, "dc", "identifier", "scopus", null, "7004769520");
|
itemService.addMetadata(context, itemPerson, "dc", "identifier", "scopus", null, "7004769520");
|
||||||
|
|
||||||
OrcidQueue orcidQueue = OrcidQueueBuilder.createOrcidQueue(context, itemPerson, itemPublication).build();
|
OrcidQueue orcidQueue = OrcidQueueBuilder.createOrcidQueue(context, itemPerson, itemPublication).build();
|
||||||
@@ -123,7 +122,7 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
||||||
String tokenResearcher2 = getAuthToken(researcher2.getEmail(), password);
|
String tokenResearcher2 = getAuthToken(researcher2.getEmail(), password);
|
||||||
|
|
||||||
getClient(tokenResearcher).perform(get("/api/cris/orcidqueue/search/findByOwner")
|
getClient(tokenResearcher).perform(get("/api/eperson/orcidqueue/search/findByOwner")
|
||||||
.param("ownerId", itemPerson.getID().toString()))
|
.param("ownerId", itemPerson.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$._embedded.orcidqueues", Matchers.containsInAnyOrder(
|
.andExpect(jsonPath("$._embedded.orcidqueues", Matchers.containsInAnyOrder(
|
||||||
@@ -132,7 +131,7 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
)))
|
)))
|
||||||
.andExpect(jsonPath("$.page.totalElements", is(2)));
|
.andExpect(jsonPath("$.page.totalElements", is(2)));
|
||||||
|
|
||||||
getClient(tokenResearcher2).perform(get("/api/cris/orcidqueue/search/findByOwner")
|
getClient(tokenResearcher2).perform(get("/api/eperson/orcidqueue/search/findByOwner")
|
||||||
.param("ownerId", itemPerson2.getID().toString()))
|
.param("ownerId", itemPerson2.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$._embedded.orcidqueues", Matchers.contains(
|
.andExpect(jsonPath("$._embedded.orcidqueues", Matchers.contains(
|
||||||
@@ -140,9 +139,9 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
)))
|
)))
|
||||||
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
||||||
.andExpect(jsonPath("$._links.self.href", Matchers
|
.andExpect(jsonPath("$._links.self.href", Matchers
|
||||||
.containsString("/api/cris/orcidqueue/search/findByOwner")));
|
.containsString("/api/eperson/orcidqueue/search/findByOwner")));
|
||||||
|
|
||||||
getClient(tokenAdmin).perform(get("/api/cris/orcidqueue/search/findByOwner")
|
getClient(tokenAdmin).perform(get("/api/eperson/orcidqueue/search/findByOwner")
|
||||||
.param("ownerId", itemPerson.getID().toString()))
|
.param("ownerId", itemPerson.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$._embedded.orcidqueues", Matchers.containsInAnyOrder(
|
.andExpect(jsonPath("$._embedded.orcidqueues", Matchers.containsInAnyOrder(
|
||||||
@@ -206,7 +205,6 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
.withIssueDate("2013-02-17")
|
.withIssueDate("2013-02-17")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
itemService.addMetadata(context, itemPerson, "crisevent", "description", "keywords", null, "psychoceramics");
|
|
||||||
itemService.addMetadata(context, itemPerson, "dc", "identifier", "scopus", null, "7004769520");
|
itemService.addMetadata(context, itemPerson, "dc", "identifier", "scopus", null, "7004769520");
|
||||||
|
|
||||||
OrcidQueueBuilder.createOrcidQueue(context, itemPerson, itemPublication).build();
|
OrcidQueueBuilder.createOrcidQueue(context, itemPerson, itemPublication).build();
|
||||||
@@ -215,7 +213,7 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String tokenResearcher2 = getAuthToken(researcher2.getEmail(), password);
|
String tokenResearcher2 = getAuthToken(researcher2.getEmail(), password);
|
||||||
|
|
||||||
getClient(tokenResearcher2).perform(get("/api/cris/orcidqueue/search/findByOwner")
|
getClient(tokenResearcher2).perform(get("/api/eperson/orcidqueue/search/findByOwner")
|
||||||
.param("ownerId", itemPerson.getID().toString()))
|
.param("ownerId", itemPerson.getID().toString()))
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
}
|
}
|
||||||
@@ -255,14 +253,13 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
.withIssueDate("2013-08-03")
|
.withIssueDate("2013-08-03")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
itemService.addMetadata(context, itemPerson, "crisevent", "description", "keywords", null, "psychoceramics");
|
|
||||||
itemService.addMetadata(context, itemPerson, "dc", "identifier", "scopus", null, "7004769520");
|
itemService.addMetadata(context, itemPerson, "dc", "identifier", "scopus", null, "7004769520");
|
||||||
|
|
||||||
OrcidQueueBuilder.createOrcidQueue(context, itemPerson, itemPublication).build();
|
OrcidQueueBuilder.createOrcidQueue(context, itemPerson, itemPublication).build();
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
getClient().perform(get("/api/cris/orcidqueue/search/findByOwner")
|
getClient().perform(get("/api/eperson/orcidqueue/search/findByOwner")
|
||||||
.param("ownerId", itemPerson.getID().toString()))
|
.param("ownerId", itemPerson.getID().toString()))
|
||||||
.andExpect(status().isUnauthorized());
|
.andExpect(status().isUnauthorized());
|
||||||
}
|
}
|
||||||
@@ -325,21 +322,21 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
||||||
String tokenResearcher2 = getAuthToken(researcher2.getEmail(), password);
|
String tokenResearcher2 = getAuthToken(researcher2.getEmail(), password);
|
||||||
|
|
||||||
getClient(tokenResearcher).perform(get("/api/cris/orcidqueues/" + orcidQueue.getID().toString()))
|
getClient(tokenResearcher).perform(get("/api/eperson/orcidqueues/" + orcidQueue.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue))))
|
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue))))
|
||||||
.andExpect(jsonPath("$._links.self.href", Matchers
|
.andExpect(jsonPath("$._links.self.href", Matchers
|
||||||
.containsString("/api/cris/orcidqueues/" + orcidQueue.getID())))
|
.containsString("/api/eperson/orcidqueues/" + orcidQueue.getID())))
|
||||||
.andExpect(jsonPath("$._links.owner.href", Matchers
|
.andExpect(jsonPath("$._links.owner.href", Matchers
|
||||||
.containsString("/api/core/items/" + itemPerson1.getID())))
|
.containsString("/api/core/items/" + itemPerson1.getID())))
|
||||||
.andExpect(jsonPath("$._links.entity.href", Matchers
|
.andExpect(jsonPath("$._links.entity.href", Matchers
|
||||||
.containsString("/api/core/items/" + itemPublication.getID())));
|
.containsString("/api/core/items/" + itemPublication.getID())));
|
||||||
|
|
||||||
getClient(tokenResearcher2).perform(get("/api/cris/orcidqueues/" + orcidQueue2.getID().toString()))
|
getClient(tokenResearcher2).perform(get("/api/eperson/orcidqueues/" + orcidQueue2.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue2))))
|
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue2))))
|
||||||
.andExpect(jsonPath("$._links.self.href", Matchers
|
.andExpect(jsonPath("$._links.self.href", Matchers
|
||||||
.containsString("/api/cris/orcidqueues/" + orcidQueue2.getID())))
|
.containsString("/api/eperson/orcidqueues/" + orcidQueue2.getID())))
|
||||||
.andExpect(jsonPath("$._links.owner.href", Matchers
|
.andExpect(jsonPath("$._links.owner.href", Matchers
|
||||||
.containsString("/api/core/items/" + itemPerson2.getID())))
|
.containsString("/api/core/items/" + itemPerson2.getID())))
|
||||||
.andExpect(jsonPath("$._links.entity.href", Matchers
|
.andExpect(jsonPath("$._links.entity.href", Matchers
|
||||||
@@ -376,10 +373,10 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
||||||
|
|
||||||
getClient(tokenResearcher).perform(get("/api/cris/orcidqueues/" + orcidQueue.getID().toString()))
|
getClient(tokenResearcher).perform(get("/api/eperson/orcidqueues/" + orcidQueue.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue))))
|
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue))))
|
||||||
.andExpect(jsonPath("$._links.self.href", containsString("/api/cris/orcidqueues/" + orcidQueue.getID())))
|
.andExpect(jsonPath("$._links.self.href", containsString("/api/eperson/orcidqueues/" + orcidQueue.getID())))
|
||||||
.andExpect(jsonPath("$._links.owner.href", containsString("/api/core/items/" + itemPerson.getID())));
|
.andExpect(jsonPath("$._links.owner.href", containsString("/api/core/items/" + itemPerson.getID())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,7 +419,7 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String tokenEperson = getAuthToken(eperson.getEmail(), password);
|
String tokenEperson = getAuthToken(eperson.getEmail(), password);
|
||||||
|
|
||||||
getClient(tokenEperson).perform(get("/api/cris/orcidqueues/" + orcidQueue.getID().toString()))
|
getClient(tokenEperson).perform(get("/api/eperson/orcidqueues/" + orcidQueue.getID().toString()))
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,14 +461,14 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
getClient().perform(get("/api/cris/orcidqueue/" + orcidQueue.getID().toString()))
|
getClient().perform(get("/api/eperson/orcidqueue/" + orcidQueue.getID().toString()))
|
||||||
.andExpect(status().isUnauthorized());
|
.andExpect(status().isUnauthorized());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findOneNotFoundTest() throws Exception {
|
public void findOneNotFoundTest() throws Exception {
|
||||||
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(tokenAdmin).perform(get("/api/cris/orcidQueues/" + Integer.MAX_VALUE))
|
getClient(tokenAdmin).perform(get("/api/eperson/orcidQueues/" + Integer.MAX_VALUE))
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,10 +511,10 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
||||||
|
|
||||||
getClient(tokenResearcher).perform(delete("/api/cris/orcidqueues/" + orcidQueue.getID()))
|
getClient(tokenResearcher).perform(delete("/api/eperson/orcidqueues/" + orcidQueue.getID()))
|
||||||
.andExpect(status().isNoContent());
|
.andExpect(status().isNoContent());
|
||||||
|
|
||||||
getClient(tokenResearcher).perform(get("/api/cris/orcidqueues/" + orcidQueue.getID()))
|
getClient(tokenResearcher).perform(get("/api/eperson/orcidqueues/" + orcidQueue.getID()))
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,10 +559,10 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
String tokenEPerson = getAuthToken(eperson.getEmail(), password);
|
String tokenEPerson = getAuthToken(eperson.getEmail(), password);
|
||||||
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
||||||
|
|
||||||
getClient(tokenEPerson).perform(delete("/api/cris/orcidqueues/" + orcidQueue.getID()))
|
getClient(tokenEPerson).perform(delete("/api/eperson/orcidqueues/" + orcidQueue.getID()))
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
|
|
||||||
getClient(tokenResearcher).perform(get("/api/cris/orcidqueues/" + orcidQueue.getID()))
|
getClient(tokenResearcher).perform(get("/api/eperson/orcidqueues/" + orcidQueue.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue))));
|
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue))));
|
||||||
}
|
}
|
||||||
@@ -609,10 +606,10 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
String tokenResearcher = getAuthToken(researcher.getEmail(), password);
|
||||||
|
|
||||||
getClient().perform(delete("/api/cris/orcidqueues/" + orcidQueue.getID()))
|
getClient().perform(delete("/api/eperson/orcidqueues/" + orcidQueue.getID()))
|
||||||
.andExpect(status().isUnauthorized());
|
.andExpect(status().isUnauthorized());
|
||||||
|
|
||||||
getClient(tokenResearcher).perform(get("/api/cris/orcidqueues/" + orcidQueue.getID()))
|
getClient(tokenResearcher).perform(get("/api/eperson/orcidqueues/" + orcidQueue.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue))));
|
.andExpect(jsonPath("$", is(matchOrcidQueue(orcidQueue))));
|
||||||
}
|
}
|
||||||
@@ -620,7 +617,7 @@ public class OrcidQueueRestRepositoryIT extends AbstractControllerIntegrationTes
|
|||||||
@Test
|
@Test
|
||||||
public void deleteOneNotFoundTest() throws Exception {
|
public void deleteOneNotFoundTest() throws Exception {
|
||||||
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(tokenAdmin).perform(delete("/api/cris/orcidqueues/" + Integer.MAX_VALUE))
|
getClient(tokenAdmin).perform(delete("/api/eperson/orcidqueues/" + Integer.MAX_VALUE))
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user