Skip to content

Commit

Permalink
CST-11298 openaire test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
frabacche committed Aug 7, 2023
1 parent d5dd2c9 commit ada6c02
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,15 @@ public void testManyEventsImportFromFile() throws Exception {
assertThat(handler.getWarningMessages(), empty());
assertThat(handler.getInfoMessages(), contains(
"Trying to read the QA events from the provided file",
"Found 2 events in the given file"));
"Found 5 events in the given file"));

assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 2L)));
assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 5L)));

assertThat(qaEventService.findAllTopics(0, 20), containsInAnyOrder(
QATopicMatcher.with("ENRICH/MORE/PROJECT", 1L),
QATopicMatcher.with("ENRICH/MORE/PID", 1L),
QATopicMatcher.with("ENRICH/MISSING/PID", 1L),
QATopicMatcher.with("ENRICH/MISSING/PROJECT", 1L),
QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 1L)));

String projectMessage = "{\"projects[0].acronym\":\"PAThs\",\"projects[0].code\":\"687567\","
Expand Down Expand Up @@ -200,14 +203,21 @@ public void testManyEventsImportFromFileWithUnknownHandle() throws Exception {
assertThat(handler.getWarningMessages(),
contains("An error occurs storing the event with id b4e09c71312cd7c397969f56c900823f: "
+ "Skipped event b4e09c71312cd7c397969f56c900823f related to the oai record "
+ "oai:www.openstarts.units.it:123456789/99998 as the record was not found",
"An error occurs storing the event with id d050d2c4399c6c6ccf27d52d479d26e4: "
+ "Skipped event d050d2c4399c6c6ccf27d52d479d26e4 related to the oai record "
+ "oai:www.openstarts.units.it:123456789/99998 as the record was not found"));
assertThat(handler.getInfoMessages(), contains(
"Trying to read the QA events from the provided file",
"Found 2 events in the given file"));
"Found 5 events in the given file"));

assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 1L)));
assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 3L)));

assertThat(qaEventService.findAllTopics(0, 20), contains(QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 1L)));
assertThat(qaEventService.findAllTopics(0, 20), containsInAnyOrder(
QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 1L),
QATopicMatcher.with("ENRICH/MISSING/PROJECT", 1L),
QATopicMatcher.with("ENRICH/MORE/PID", 1L)
));

String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}";

Expand Down Expand Up @@ -311,14 +321,17 @@ public void testImportFromOpenaireBroker() throws Exception {
assertThat(handler.getInfoMessages(), contains(
"Trying to read the QA events from the OPENAIRE broker",
"Found 3 subscriptions related to the given email",
"Found 2 events from the subscription sub1",
"Found 5 events from the subscription sub1",
"Found 0 events from the subscription sub2",
"Found 2 events from the subscription sub3"));

assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 3L)));
assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 6L)));

assertThat(qaEventService.findAllTopics(0, 20), containsInAnyOrder(
QATopicMatcher.with("ENRICH/MORE/PROJECT", 1L),
QATopicMatcher.with("ENRICH/MORE/PID", 1L),
QATopicMatcher.with("ENRICH/MISSING/PID", 1L),
QATopicMatcher.with("ENRICH/MISSING/PROJECT", 1L),
QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 2L)));

String projectMessage = "{\"projects[0].acronym\":\"PAThs\",\"projects[0].code\":\"687567\","
Expand Down Expand Up @@ -413,14 +426,17 @@ public void testImportFromOpenaireBrokerWithErrorDuringEventsDownload() throws E
assertThat(handler.getInfoMessages(), contains(
"Trying to read the QA events from the OPENAIRE broker",
"Found 3 subscriptions related to the given email",
"Found 2 events from the subscription sub1",
"Found 5 events from the subscription sub1",
"Found 0 events from the subscription sub2",
"Found 2 events from the subscription sub3"));

assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 3L)));
assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 6L)));

assertThat(qaEventService.findAllTopics(0, 20), containsInAnyOrder(
QATopicMatcher.with("ENRICH/MORE/PROJECT", 1L),
QATopicMatcher.with("ENRICH/MISSING/PID", 1L),
QATopicMatcher.with("ENRICH/MORE/PID", 1L),
QATopicMatcher.with("ENRICH/MISSING/PROJECT", 1L),
QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 2L)));

assertThat(qaEventService.findEventsByTopic("ENRICH/MORE/PROJECT"), hasSize(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,39 @@
"message": {
"abstracts[0]": "Missing Abstract"
}
}

},
{
"originalId": "oai:www.openstarts.units.it:123456789/99998",
"title": "Egypt, crossroad of translations and literary interweavings",
"topic": "ENRICH/MISSING/PID",
"trust": 1.0,
"message": {
"pids[0].type": "doi",
"pids[0].value": "10.13137/2282-572x/987"
}
},
{
"originalId": "oai:www.openstarts.units.it:123456789/99999",
"title": "Test Publication",
"topic": "ENRICH/MORE/PID",
"trust": 0.375,
"message": {
"pids[0].type": "doi",
"pids[0].value": "987654"
}
},
{
"originalId": "oai:www.openstarts.units.it:123456789/99999",
"title": "Test Publication",
"topic": "ENRICH/MISSING/PROJECT",
"trust": 1.0,
"message": {
"projects[0].acronym": "02.SNES missing project acronym",
"projects[0].code": "prjcode_snes",
"projects[0].funder": "02.SNES missing project funder",
"projects[0].fundingProgram": "02.SNES missing project fundingProgram",
"projects[0].jurisdiction": "02.SNES missing project jurisdiction",
"projects[0].title": "Project01"
}
}
]

0 comments on commit ada6c02

Please sign in to comment.