mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
CST-12510 fix ITs, fix QAEvent generated by LDNCorrectionAction
This commit is contained in:
@@ -44,8 +44,10 @@ public class LDNCorrectionAction implements LDNAction {
|
||||
public ActionStatus execute(Notification notification, Item item) throws Exception {
|
||||
ActionStatus result;
|
||||
Context context = ContextUtil.obtainCurrentRequestContext();
|
||||
//FIXME the original id should be just an (optional) identifier/reference of the event in
|
||||
// the external system. The target Item should be passed as a constructor argument
|
||||
QAEvent qaEvent = new QAEvent(QAEvent.COAR_NOTIFY,
|
||||
notification.getObject().getId(), item.getID().toString(), item.getName(),
|
||||
"oai:localhost:" + item.getHandle(), item.getID().toString(), item.getName(),
|
||||
this.getQaEventTopic(), getScore(context, notification).doubleValue(),
|
||||
"{\"abstracts[0]\": \"" + notification.getObject().getIetfCiteAs() + "\"}"
|
||||
, new Date());
|
||||
|
@@ -17,17 +17,20 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.dspace.app.ldn.LDNMessageEntity;
|
||||
import org.dspace.app.ldn.NotifyServiceEntity;
|
||||
import org.dspace.app.ldn.model.Notification;
|
||||
import org.dspace.app.ldn.service.LDNMessageService;
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.builder.CollectionBuilder;
|
||||
import org.dspace.builder.CommunityBuilder;
|
||||
import org.dspace.builder.ItemBuilder;
|
||||
import org.dspace.builder.NotifyServiceBuilder;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
@@ -58,7 +61,6 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
|
||||
Collection collection = CollectionBuilder.createCollection(context, community).build();
|
||||
Item item = ItemBuilder.createItem(context, collection).build();
|
||||
String object = configurationService.getProperty("dspace.ui.url") + "/handle/" + item.getHandle();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
InputStream offerEndorsementStream = getClass().getResourceAsStream("ldn_offer_endorsement_object.json");
|
||||
@@ -68,7 +70,7 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Notification notification = mapper.readValue(message, Notification.class);
|
||||
|
||||
getClient(getAuthToken(admin.getEmail(), password))
|
||||
getClient()
|
||||
.perform(post("/ldn/inbox")
|
||||
.contentType("application/ld+json")
|
||||
.content(message))
|
||||
@@ -96,7 +98,7 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Notification notification = mapper.readValue(message, Notification.class);
|
||||
getClient(getAuthToken(admin.getEmail(), password))
|
||||
getClient()
|
||||
.perform(post("/ldn/inbox")
|
||||
.contentType("application/ld+json")
|
||||
.content(message))
|
||||
@@ -109,12 +111,22 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void ldnInboxAnnounceReviewTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
NotifyServiceEntity serviceEntity = NotifyServiceBuilder.createNotifyServiceBuilder(context)
|
||||
.withName("Review Service")
|
||||
.withLdnUrl("https://review-service.com/inbox/")
|
||||
.withScore(BigDecimal.valueOf(0.6d))
|
||||
.build();
|
||||
Community com = CommunityBuilder.createCommunity(context).withName("Test Community").build();
|
||||
Collection col = CollectionBuilder.createCollection(context, com).withName("Test Collection").build();
|
||||
Item item = ItemBuilder.createItem(context, col).withHandle("123456789/9999").withTitle("Test Item").build();
|
||||
context.restoreAuthSystemState();
|
||||
InputStream announceReviewStream = getClass().getResourceAsStream("ldn_announce_review.json");
|
||||
String message = IOUtils.toString(announceReviewStream, Charset.defaultCharset());
|
||||
announceReviewStream.close();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Notification notification = mapper.readValue(message, Notification.class);
|
||||
getClient(getAuthToken(admin.getEmail(), password))
|
||||
getClient()
|
||||
.perform(post("/ldn/inbox")
|
||||
.contentType("application/ld+json")
|
||||
.content(message))
|
||||
@@ -134,7 +146,7 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
|
||||
offerEndorsementStream.close();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Notification notification = mapper.readValue(message, Notification.class);
|
||||
getClient(getAuthToken(admin.getEmail(), password))
|
||||
getClient()
|
||||
.perform(post("/ldn/inbox")
|
||||
.contentType("application/ld+json")
|
||||
.content(message))
|
||||
|
@@ -41,7 +41,7 @@ public class SubmissionCOARNotifyRestRepositoryIT extends AbstractControllerInte
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(contentType))
|
||||
.andExpect(jsonPath("$._embedded.submissioncoarnotifyconfigs", Matchers.containsInAnyOrder(
|
||||
SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("default",
|
||||
SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("coarnotify",
|
||||
List.of("review", "endorsement", "ingest"))
|
||||
)));
|
||||
}
|
||||
@@ -64,11 +64,11 @@ public class SubmissionCOARNotifyRestRepositoryIT extends AbstractControllerInte
|
||||
public void findOneTest() throws Exception {
|
||||
String epersonToken = getAuthToken(eperson.getEmail(), password);
|
||||
|
||||
getClient(epersonToken).perform(get("/api/config/submissioncoarnotifyconfigs/default"))
|
||||
getClient(epersonToken).perform(get("/api/config/submissioncoarnotifyconfigs/coarnotify"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(contentType))
|
||||
.andExpect(jsonPath("$", Matchers.is(
|
||||
SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("default",
|
||||
SubmissionCOARNotifyMatcher.matchCOARNotifyEntry("coarnotify",
|
||||
List.of("review", "endorsement", "ingest"))
|
||||
)));
|
||||
}
|
||||
|
@@ -205,7 +205,7 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
|
||||
// We expect the content type to be "application/hal+json;charset=UTF-8"
|
||||
.andExpect(content().contentType(contentType))
|
||||
// Match only that a section exists with a submission configuration behind
|
||||
.andExpect(jsonPath("$._embedded.submissionsections", hasSize(9)))
|
||||
.andExpect(jsonPath("$._embedded.submissionsections", hasSize(10)))
|
||||
.andExpect(jsonPath("$._embedded.submissionsections",
|
||||
Matchers.hasItem(
|
||||
allOf(
|
||||
|
@@ -9,7 +9,7 @@
|
||||
"type": "Service"
|
||||
},
|
||||
"context": {
|
||||
"id": "oai:http://localhost:4000/handle:123456789/12",
|
||||
"id": "http://localhost:4000/handle/123456789/9999",
|
||||
"ietf:cite-as": "https://doi.org/10.5555/12345680",
|
||||
"type": "sorg:AboutPage",
|
||||
"url": {
|
||||
|
@@ -929,6 +929,7 @@ registry.metadata.load = openaire4-types.xml
|
||||
registry.metadata.load = dspace-types.xml
|
||||
registry.metadata.load = iiif-types.xml
|
||||
registry.metadata.load = datacite-types.xml
|
||||
registry.metadata.load = coar-types.xml
|
||||
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
|
Reference in New Issue
Block a user