forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in CST-12406-introduce-constants (pull request DSpace#1298)
CST-12406 instroduce constants first implementation and test fixes
- Loading branch information
Showing
7 changed files
with
229 additions
and
167 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
dspace-api/src/main/java/org/dspace/qaevent/QANotifyPatterns.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.qaevent; | ||
|
||
/** | ||
* Constants for Quality Assurance configurations to be used into cfg and xml spring. | ||
* | ||
* @author Francesco Bacchelli (francesco.bacchelli at 4science.it) | ||
* | ||
*/ | ||
public class QANotifyPatterns { | ||
public static final String TOPIC_ENRICH_MORE_PROJECT = "ENRICH/MORE/PROJECT"; | ||
public static final String TOPIC_ENRICH_MISSING_PROJECT = "ENRICH/MISSING/PROJECT"; | ||
public static final String TOPIC_ENRICH_MISSING_ABSTRACT = "ENRICH/MISSING/ABSTRACT"; | ||
public static final String TOPIC_ENRICH_MORE_REVIEW = "ENRICH/MORE/REVIEW"; | ||
public static final String TOPIC_ENRICH_MORE_ENDORSEMENT = "ENRICH/MORE/ENDORSEMENT"; | ||
public static final String TOPIC_ENRICH_MORE_PID = "ENRICH/MORE/PID"; | ||
public static final String TOPIC_ENRICH_MISSING_PID = "ENRICH/MISSING/PID"; | ||
|
||
/** | ||
* Default constructor | ||
*/ | ||
private QANotifyPatterns() { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
import org.dspace.content.QAEvent; | ||
import org.dspace.matcher.QASourceMatcher; | ||
import org.dspace.matcher.QATopicMatcher; | ||
import org.dspace.qaevent.QANotifyPatterns; | ||
import org.dspace.qaevent.QATopic; | ||
import org.dspace.qaevent.service.BrokerClientFactory; | ||
import org.dspace.qaevent.service.QAEventService; | ||
|
@@ -57,6 +58,7 @@ | |
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
|
||
/** | ||
* Integration tests for {@link OpenaireEventsImport}. | ||
* | ||
|
@@ -171,30 +173,33 @@ public void testManyEventsImportFromFile() throws Exception { | |
); | ||
|
||
List<QATopic> topicList = qaEventService.findAllTopicsBySource(context, OPENAIRE_SOURCE, 0, 20); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MORE/PROJECT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MORE/PID", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/PID", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/PROJECT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MORE_PROJECT, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MORE_PID, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_PID, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_PROJECT, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1L))); | ||
|
||
String projectMessage = "{\"projects[0].acronym\":\"PAThs\",\"projects[0].code\":\"687567\"," | ||
+ "\"projects[0].funder\":\"EC\",\"projects[0].fundingProgram\":\"H2020\"," | ||
+ "\"projects[0].jurisdiction\":\"EU\"," | ||
+ "\"projects[0].openaireId\":\"40|corda__h2020::6e32f5eb912688f2424c68b851483ea4\"," | ||
+ "\"projects[0].title\":\"Tracking Papyrus and Parchment Paths\"}"; | ||
|
||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, "ENRICH/MORE/PROJECT", 0, 20), | ||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, | ||
QANotifyPatterns.TOPIC_ENRICH_MORE_PROJECT, 0, 20), | ||
contains( | ||
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/99998", firstItem, | ||
"Egypt, crossroad of translations and literary interweavings", projectMessage, | ||
"ENRICH/MORE/PROJECT", 1.00d))); | ||
QANotifyPatterns.TOPIC_ENRICH_MORE_PROJECT, 1.00d))); | ||
|
||
String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}"; | ||
|
||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, "ENRICH/MISSING/ABSTRACT", 0, 20), | ||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, | ||
QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 0, 20), | ||
contains( | ||
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/99999", secondItem, "Test Publication", | ||
abstractMessage, "ENRICH/MISSING/ABSTRACT", 1.00d))); | ||
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/99999", | ||
secondItem, "Test Publication", | ||
abstractMessage, QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1.00d))); | ||
|
||
verifyNoInteractions(mockBrokerClient); | ||
|
||
|
@@ -229,16 +234,17 @@ public void testManyEventsImportFromFileWithUnknownHandle() throws Exception { | |
assertThat(qaEventService.findAllSources(context, 0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 3L))); | ||
|
||
List<QATopic> topicList = qaEventService.findAllTopicsBySource(context, OPENAIRE_SOURCE, 0, 20); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/PROJECT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MORE/PID", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_PROJECT, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MORE_PID, 1L))); | ||
|
||
String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}"; | ||
|
||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, "ENRICH/MISSING/ABSTRACT", 0, 20), | ||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, | ||
QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 0, 20), | ||
contains( | ||
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/99999", item, "Test Publication", | ||
abstractMessage, "ENRICH/MISSING/ABSTRACT", 1.00d))); | ||
abstractMessage, QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1.00d))); | ||
|
||
verifyNoInteractions(mockBrokerClient); | ||
|
||
|
@@ -269,14 +275,15 @@ public void testManyEventsImportFromFileWithUnknownTopic() throws Exception { | |
assertThat(qaEventService.findAllSources(context, 0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 1L))); | ||
|
||
assertThat(qaEventService.findAllTopicsBySource(context, OPENAIRE_SOURCE, 0, 20), | ||
contains(QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 1L))); | ||
contains(QATopicMatcher.with(org.dspace.qaevent.QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1L))); | ||
|
||
String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}"; | ||
|
||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, "ENRICH/MISSING/ABSTRACT", 0, 20), | ||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, | ||
QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 0, 20), | ||
contains( | ||
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/999991", secondItem, "Test Publication 2", | ||
abstractMessage, "ENRICH/MISSING/ABSTRACT", 1.00d))); | ||
abstractMessage, org.dspace.qaevent.QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1.00d))); | ||
|
||
verifyNoInteractions(mockBrokerClient); | ||
|
||
|
@@ -345,34 +352,35 @@ public void testImportFromOpenaireBroker() throws Exception { | |
assertThat(qaEventService.findAllSources(context, 0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 6L))); | ||
|
||
List<QATopic> topicList = qaEventService.findAllTopicsBySource(context, OPENAIRE_SOURCE, 0, 20); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MORE/PROJECT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MORE/PID", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/PID", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/PROJECT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 2L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MORE_PROJECT, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MORE_PID, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_PID, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_PROJECT, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 2L))); | ||
|
||
String projectMessage = "{\"projects[0].acronym\":\"PAThs\",\"projects[0].code\":\"687567\"," | ||
+ "\"projects[0].funder\":\"EC\",\"projects[0].fundingProgram\":\"H2020\"," | ||
+ "\"projects[0].jurisdiction\":\"EU\"," | ||
+ "\"projects[0].openaireId\":\"40|corda__h2020::6e32f5eb912688f2424c68b851483ea4\"," | ||
+ "\"projects[0].title\":\"Tracking Papyrus and Parchment Paths\"}"; | ||
|
||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, "ENRICH/MORE/PROJECT", 0, 20), | ||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, | ||
QANotifyPatterns.TOPIC_ENRICH_MORE_PROJECT, 0, 20), | ||
contains( | ||
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/99998", firstItem, | ||
"Egypt, crossroad of translations and literary interweavings", projectMessage, | ||
"ENRICH/MORE/PROJECT", 1.00d))); | ||
QANotifyPatterns.TOPIC_ENRICH_MORE_PROJECT, 1.00d))); | ||
|
||
String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}"; | ||
|
||
List<QAEvent> eventList = qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, | ||
"ENRICH/MISSING/ABSTRACT", 0, 20); | ||
QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 0, 20); | ||
assertThat(eventList, hasItem( | ||
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/99999", secondItem, "Test Publication", | ||
abstractMessage, "ENRICH/MISSING/ABSTRACT", 1.00d))); | ||
abstractMessage, QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1.00d))); | ||
assertThat(eventList, hasItem( | ||
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/999991", thirdItem, "Test Publication 2", | ||
abstractMessage, "ENRICH/MISSING/ABSTRACT", 1.00d))); | ||
abstractMessage, QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1.00d))); | ||
|
||
verify(mockBrokerClient).listSubscriptions(openaireURL, "[email protected]"); | ||
verify(mockBrokerClient).downloadEvents(eq(openaireURL), eq("sub1"), any()); | ||
|
@@ -454,15 +462,17 @@ public void testImportFromOpenaireBrokerWithErrorDuringEventsDownload() throws E | |
assertThat(qaEventService.findAllSources(context, 0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 6L))); | ||
|
||
List<QATopic> topicList = qaEventService.findAllTopicsBySource(context, OPENAIRE_SOURCE, 0, 20); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MORE/PROJECT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/PID", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MORE/PID", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/PROJECT", 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 2L))); | ||
|
||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, "ENRICH/MORE/PROJECT", 0, 20), | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MORE_PROJECT, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_PID, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MORE_PID, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_PROJECT, 1L))); | ||
assertThat(topicList, hasItem(QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 2L))); | ||
|
||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, | ||
QANotifyPatterns.TOPIC_ENRICH_MORE_PROJECT, 0, 20), | ||
hasSize(1)); | ||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, "ENRICH/MISSING/ABSTRACT", 0, 20), | ||
assertThat(qaEventService.findEventsByTopicAndPage(context, OPENAIRE_SOURCE, | ||
QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 0, 20), | ||
hasSize(2)); | ||
|
||
verify(mockBrokerClient).listSubscriptions(openaireURL, "[email protected]"); | ||
|
@@ -489,7 +499,7 @@ public void testImportFromFileEventMoreReview() throws Exception { | |
ScriptLauncher.handleScript(args, ScriptLauncher.getConfig(kernelImpl), handler, kernelImpl); | ||
|
||
assertThat(qaEventService.findAllTopicsBySource(context, OPENAIRE_SOURCE, 0, 20), contains( | ||
QATopicMatcher.with("ENRICH/MORE/REVIEW", 1L))); | ||
QATopicMatcher.with(QANotifyPatterns.TOPIC_ENRICH_MORE_REVIEW, 1L))); | ||
|
||
assertThat(qaEventService.findAllSources(context, 0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 1L))); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.