mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
CST-12748 ACK extractor management verification with IT class
This commit is contained in:
@@ -118,7 +118,7 @@ public class LDNMessageServiceImpl implements LDNMessageService {
|
|||||||
ldnMessage.setQueueStatus(LDNMessageEntity.QUEUE_STATUS_QUEUED);
|
ldnMessage.setQueueStatus(LDNMessageEntity.QUEUE_STATUS_QUEUED);
|
||||||
//CST-12126 if source is untrusted, set the queue_status of the
|
//CST-12126 if source is untrusted, set the queue_status of the
|
||||||
//ldnMsgEntity to UNTRUSTED
|
//ldnMsgEntity to UNTRUSTED
|
||||||
if (ldnMessage.getOrigin() == null) {
|
if (ldnMessage.getOrigin() == null && !"Offer".equalsIgnoreCase(ldnMessage.getActivityStreamType())) {
|
||||||
ldnMessage.setQueueStatus(LDNMessageEntity.QUEUE_STATUS_UNTRUSTED);
|
ldnMessage.setQueueStatus(LDNMessageEntity.QUEUE_STATUS_UNTRUSTED);
|
||||||
}
|
}
|
||||||
ldnMessage.setQueueTimeout(new Date());
|
ldnMessage.setQueueTimeout(new Date());
|
||||||
|
@@ -146,6 +146,59 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
|
|||||||
.andExpect(status().isBadRequest());
|
.andExpect(status().isBadRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ldnInboxOfferReviewAndACKTest() throws Exception {
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
Community community = CommunityBuilder.createCommunity(context).withName("community").build();
|
||||||
|
Collection collection = CollectionBuilder.createCollection(context, community).build();
|
||||||
|
Item item = ItemBuilder.createItem(context, collection).build();
|
||||||
|
String object = configurationService.getProperty("dspace.ui.url") + "/handle/" + item.getHandle();
|
||||||
|
NotifyServiceEntity notifyServiceEntity = NotifyServiceBuilder.createNotifyServiceBuilder(context)
|
||||||
|
.withName("service name")
|
||||||
|
.withDescription("service description")
|
||||||
|
.withUrl("https://review-service.com/inbox/about/")
|
||||||
|
.withLdnUrl("https://review-service.com/inbox/")
|
||||||
|
.withScore(BigDecimal.valueOf(0.6d))
|
||||||
|
.build();
|
||||||
|
InputStream offerReviewStream = getClass().getResourceAsStream("ldn_offer_review.json");
|
||||||
|
String announceReview = IOUtils.toString(offerReviewStream, Charset.defaultCharset());
|
||||||
|
offerReviewStream.close();
|
||||||
|
String message = announceReview.replaceAll("<<object_handle>>", object);
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
Notification notification = mapper.readValue(message, Notification.class);
|
||||||
|
getClient()
|
||||||
|
.perform(post("/ldn/inbox")
|
||||||
|
.contentType("application/ld+json")
|
||||||
|
.content(message))
|
||||||
|
.andExpect(status().isAccepted());
|
||||||
|
|
||||||
|
int processed = ldnMessageService.extractAndProcessMessageFromQueue(context);
|
||||||
|
assertEquals(processed, 1);
|
||||||
|
processed = ldnMessageService.extractAndProcessMessageFromQueue(context);
|
||||||
|
assertEquals(processed, 0);
|
||||||
|
|
||||||
|
InputStream ackReviewStream = getClass().getResourceAsStream("ldn_ack_review_reject.json");
|
||||||
|
String ackReview = IOUtils.toString(ackReviewStream, Charset.defaultCharset());
|
||||||
|
offerReviewStream.close();
|
||||||
|
String ackMessage = ackReview.replaceAll("<<object_handle>>", object);
|
||||||
|
|
||||||
|
ObjectMapper ackMapper = new ObjectMapper();
|
||||||
|
Notification ackNotification = mapper.readValue(ackMessage, Notification.class);
|
||||||
|
getClient()
|
||||||
|
.perform(post("/ldn/inbox")
|
||||||
|
.contentType("application/ld+json")
|
||||||
|
.content(ackMessage))
|
||||||
|
.andExpect(status().isAccepted());
|
||||||
|
|
||||||
|
int ackProcessed = ldnMessageService.extractAndProcessMessageFromQueue(context);
|
||||||
|
assertEquals(ackProcessed, 1);
|
||||||
|
ackProcessed = ldnMessageService.extractAndProcessMessageFromQueue(context);
|
||||||
|
assertEquals(ackProcessed, 0);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void checkStoredLDNMessage(Notification notification, LDNMessageEntity ldnMessage, String object)
|
private void checkStoredLDNMessage(Notification notification, LDNMessageEntity ldnMessage, String object)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"@context": [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
"https://purl.org/coar/notify"
|
||||||
|
],
|
||||||
|
"actor": {
|
||||||
|
"id": "https://generic-service.com",
|
||||||
|
"name": "Generic Service",
|
||||||
|
"type": "Service"
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"id": "https://some-organisation.org/resource/0021",
|
||||||
|
"ietf:cite-as": "https://doi.org/10.4598/12123487",
|
||||||
|
"type": "Document"
|
||||||
|
},
|
||||||
|
"id": "urn:uuid:668f26e0-2c8d-4117-a0d2-ee713523bcb4",
|
||||||
|
"inReplyTo": "urn:uuid:0370c0fb-bb78-4a9b-87f5-bed307a509de",
|
||||||
|
"object": {
|
||||||
|
"id": "<<object_handle>>",
|
||||||
|
"object": "https://some-organisation.org/resource/0021",
|
||||||
|
"type": "Offer"
|
||||||
|
},
|
||||||
|
"origin": {
|
||||||
|
"id": "https://generic-service.com/system",
|
||||||
|
"inbox": "https://review-service.com/inbox/",
|
||||||
|
"type": "Service"
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
"id": "https://some-organisation.org",
|
||||||
|
"inbox": "hop",
|
||||||
|
"type": "Organization"
|
||||||
|
},
|
||||||
|
"type": ["TentativeReject", "coar-notify:ReviewAction"]
|
||||||
|
}
|
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"@context": [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
"https://purl.org/coar/notify"
|
||||||
|
],
|
||||||
|
"actor": {
|
||||||
|
"id": "https://orcid.org/0000-0002-1825-0097",
|
||||||
|
"name": "Josiah Carberry",
|
||||||
|
"type": "Person"
|
||||||
|
},
|
||||||
|
"id": "urn:uuid:0370c0fb-bb78-4a9b-87f5-bed307a509de",
|
||||||
|
"object": {
|
||||||
|
"id": "<<object_handle>>",
|
||||||
|
"ietf:cite-as": "https://doi.org/10.5555/12345680",
|
||||||
|
"type": "sorg:AboutPage",
|
||||||
|
"url": {
|
||||||
|
"id": "url.pdf",
|
||||||
|
"mediaType": "applicationpdf",
|
||||||
|
"type": [
|
||||||
|
"Article",
|
||||||
|
"sorg:ScholarlyArticle"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"origin": {
|
||||||
|
"id": "https://research-organisation.org/repository",
|
||||||
|
"inbox": "sookah",
|
||||||
|
"type": "Service"
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
"id": "https://review-service.com/system",
|
||||||
|
"inbox": "https://review-service.com/inbox/",
|
||||||
|
"type": "Service"
|
||||||
|
},
|
||||||
|
"type": [
|
||||||
|
"Offer",
|
||||||
|
"coar-notify:ReviewAction"
|
||||||
|
]
|
||||||
|
}
|
@@ -173,7 +173,7 @@
|
|||||||
<property name="actions">
|
<property name="actions">
|
||||||
<list value-type="org.dspace.app.ldn.action.LDNAction">
|
<list value-type="org.dspace.app.ldn.action.LDNAction">
|
||||||
<bean class="org.dspace.app.ldn.action.LDNEmailAction">
|
<bean class="org.dspace.app.ldn.action.LDNEmailAction">
|
||||||
<property name="actionSendFilter" value="william_welling@harvard.edu" />
|
<property name="actionSendFilter" value="${ldn.notification.email}" />
|
||||||
<property name="actionSendEmailTextFile" value="coar_notify_reviewed" />
|
<property name="actionSendEmailTextFile" value="coar_notify_reviewed" />
|
||||||
</bean>
|
</bean>
|
||||||
</list>
|
</list>
|
||||||
@@ -184,7 +184,7 @@
|
|||||||
<property name="actions">
|
<property name="actions">
|
||||||
<list value-type="org.dspace.app.ldn.action.LDNAction">
|
<list value-type="org.dspace.app.ldn.action.LDNAction">
|
||||||
<bean class="org.dspace.app.ldn.action.LDNEmailAction">
|
<bean class="org.dspace.app.ldn.action.LDNEmailAction">
|
||||||
<property name="actionSendFilter" value="william_welling@harvard.edu" />
|
<property name="actionSendFilter" value="${ldn.notification.email}" />
|
||||||
<property name="actionSendEmailTextFile" value="coar_notify_reviewed" />
|
<property name="actionSendEmailTextFile" value="coar_notify_reviewed" />
|
||||||
</bean>
|
</bean>
|
||||||
</list>
|
</list>
|
||||||
@@ -195,7 +195,7 @@
|
|||||||
<property name="actions">
|
<property name="actions">
|
||||||
<list value-type="org.dspace.app.ldn.action.LDNAction">
|
<list value-type="org.dspace.app.ldn.action.LDNAction">
|
||||||
<bean class="org.dspace.app.ldn.action.LDNEmailAction">
|
<bean class="org.dspace.app.ldn.action.LDNEmailAction">
|
||||||
<property name="actionSendFilter" value="william_welling@harvard.edu" />
|
<property name="actionSendFilter" value="${ldn.notification.email}" />
|
||||||
<property name="actionSendEmailTextFile" value="coar_notify_reviewed" />
|
<property name="actionSendEmailTextFile" value="coar_notify_reviewed" />
|
||||||
</bean>
|
</bean>
|
||||||
</list>
|
</list>
|
||||||
|
Reference in New Issue
Block a user