CST-11298 openaire test fix

This commit is contained in:
Francesco Bacchelli
2023-08-07 13:37:22 +02:00
parent d5dd2c93bb
commit ada6c021e4
2 changed files with 60 additions and 11 deletions

View File

@@ -153,12 +153,15 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
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\","
@@ -200,14 +203,21 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
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\"}";
@@ -311,14 +321,17 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
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\","
@@ -413,14 +426,17 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
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));

View File

@@ -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"
}
}
]