[DURACOM-272] added COAR LDN integration test

This commit is contained in:
Stefano Maffei
2024-06-11 09:13:46 +02:00
parent 38a25f623a
commit ec84fd937f
3 changed files with 81 additions and 0 deletions

View File

@@ -121,6 +121,11 @@ public class NotifyServiceBuilder extends AbstractBuilder<NotifyServiceEntity, N
return this;
}
public NotifyServiceBuilder withStatus(boolean enabled) {
notifyServiceEntity.setEnabled(enabled);
return this;
}
public NotifyServiceBuilder withScore(BigDecimal score) {
notifyServiceEntity.setScore(score);
return this;

View File

@@ -62,6 +62,7 @@ public class NotifyRequestStatusRestControllerIT extends AbstractControllerInteg
.withDescription("service description")
.withUrl("https://review-service.com/inbox/about/")
.withLdnUrl("https://review-service.com/inbox/")
.withStatus(true)
.withScore(BigDecimal.valueOf(0.6d))
.build();
//SEND OFFER REVIEW
@@ -96,6 +97,41 @@ public class NotifyRequestStatusRestControllerIT extends AbstractControllerInteg
;
}
@Test
public void oneStatusAnnounceEndorsementTestDisabledService() 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/")
.withStatus(false) // service is disabled
.withScore(BigDecimal.valueOf(0.6d))
.build();
//SEND OFFER REVIEW
InputStream offerReviewStream = getClass().getResourceAsStream("ldn_offer_review3.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, 0);
processed = ldnMessageService.extractAndProcessMessageFromQueue(context);
assertEquals(processed, 0);
}
@Test
public void oneStatusRejectedTest() throws Exception {
context.turnOffAuthorisationSystem();
@@ -108,6 +144,7 @@ public class NotifyRequestStatusRestControllerIT extends AbstractControllerInteg
.withDescription("service description")
.withUrl("https://review-service.com/inbox/about/")
.withLdnUrl("https://review-service.com/inbox/")
.withStatus(true)
.withScore(BigDecimal.valueOf(0.6d))
.build();
//SEND OFFER REVIEW

View File

@@ -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-bed308a509da",
"object": {
"id": "<<object_handle>>",
"ietf:cite-as": "https://doi.org/10.5555/12345680",
"type": "sorg:AboutPage",
"ietf:item": {
"id": "url.pdf",
"mediaType": "applicationpdf",
"type": [
"Article",
"sorg:ScholarlyArticle"
]
}
},
"origin": {
"id": "https://research-organisation.org/repository",
"inbox": "https://review-service.com/inbox/",
"type": "Service"
},
"target": {
"id": "https://review-service.com/system",
"inbox": "https://review-service.com/inbox/",
"type": "Service"
},
"type": [
"Offer",
"coar-notify:ReviewAction"
]
}