CST-12467 refactor qatopic to always refer to a qasource

This commit is contained in:
Andrea Bollini
2023-11-01 00:04:46 +01:00
parent 0540cae734
commit a144caa2c2
16 changed files with 466 additions and 289 deletions

View File

@@ -8,6 +8,7 @@
package org.dspace.qaevent;
import java.util.Date;
import java.util.UUID;
/**
* This model class represent the source/provider of the QA events (as OpenAIRE).
@@ -17,7 +18,14 @@ import java.util.Date;
*/
public class QASource {
private String name;
/**
* if the QASource stats (see next attributes) are related to a specific target
*/
private UUID focus;
private long totalEvents;
private Date lastEvent;
public String getName() {
@@ -28,6 +36,14 @@ public class QASource {
this.name = name;
}
public UUID getFocus() {
return focus;
}
public void setFocus(UUID focus) {
this.focus = focus;
}
public long getTotalEvents() {
return totalEvents;
}
@@ -43,4 +59,9 @@ public class QASource {
public void setLastEvent(Date lastEvent) {
this.lastEvent = lastEvent;
}
@Override
public String toString() {
return name + focus + totalEvents;
}
}

View File

@@ -8,6 +8,7 @@
package org.dspace.qaevent;
import java.util.Date;
import java.util.UUID;
/**
* This model class represent the quality assurance broker topic concept. A
@@ -17,10 +18,22 @@ import java.util.Date;
*
*/
public class QATopic {
private String source;
private String key;
/**
* if the QASource stats (see next attributes) are related to a specific target
*/
private UUID focus;
private long totalEvents;
private Date lastEvent;
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getKey() {
return key;
}
@@ -29,6 +42,14 @@ public class QATopic {
this.key = key;
}
public void setFocus(UUID focus) {
this.focus = focus;
}
public UUID getFocus() {
return focus;
}
public long getTotalEvents() {
return totalEvents;
}
@@ -44,4 +65,5 @@ public class QATopic {
public void setLastEvent(Date lastEvent) {
this.lastEvent = lastEvent;
}
}

View File

@@ -23,15 +23,6 @@ import org.dspace.qaevent.QATopic;
*/
public interface QAEventService {
/**
* Find all the event's topics.
*
* @param offset the offset to apply
* @param pageSize the page size
* @return the topics list
*/
public List<QATopic> findAllTopics(long offset, long pageSize);
/**
* Find all the event's topics related to the given source.
*
@@ -40,14 +31,17 @@ public interface QAEventService {
* @param count the page size
* @return the topics list
*/
public List<QATopic> findAllTopicsBySource(String source, long offset, long count);
public List<QATopic> findAllTopicsBySource(String source, long offset, int count);
/**
* Count all the event's topics.
* Find a specific topic by its name, source and optionally a target.
*
* @return the count result
* @param sourceName the name of the source
* @param topicName the topic name to search for
* @param target (nullable) the uuid of the target to focus on
* @return the topic
*/
public long countTopics();
public QATopic findTopicBySourceAndNameAndTarget(String sourceName, String topicName, UUID target);
/**
* Count all the event's topics related to the given source.
@@ -60,12 +54,13 @@ public interface QAEventService {
/**
* Find all the events by topic sorted by trust descending.
*
* @param source the source name
* @param topic the topic to search for
* @param offset the offset to apply
* @param pageSize the page size
* @return the events
*/
public List<QAEvent> findEventsByTopicAndPage(String topic, long offset, int pageSize);
public List<QAEvent> findEventsByTopicAndPage(String source, String topic, long offset, int pageSize);
/**
* Find all the events by topic.
@@ -73,7 +68,7 @@ public interface QAEventService {
* @param topic the topic to search for
* @return the events count
*/
public long countEventsByTopic(String topic);
public long countEventsByTopic(String source, String topic);
/**
* Find an event by the given id.
@@ -105,14 +100,6 @@ public interface QAEventService {
*/
public void deleteEventsByTargetId(UUID targetId);
/**
* Find a specific topid by the given id.
*
* @param topicId the topic id to search for
* @return the topic
*/
public QATopic findTopicByTopicId(String topicId);
/**
* Find a specific source by the given name.
*
@@ -121,6 +108,15 @@ public interface QAEventService {
*/
public QASource findSource(String source);
/**
* Find a specific source by the given name including the stats focused on the target item.
*
* @param source the source name
* @param target the uuid of the item target
* @return the source
*/
public QASource findSource(String source, UUID target);
/**
* Find all the event's sources.
*
@@ -149,26 +145,30 @@ public interface QAEventService {
* Find a list of QA events according to the pagination parameters for the specified topic and target sorted by
* trust descending
*
* @param source the source name
* @param topic the topic to search for
* @param offset the offset to apply
* @param pageSize the page size
* @param target the uuid of the QA event's target
* @return the events
*/
public List<QAEvent> findEventsByTopicAndPageAndTarget(String topic, long offset, int pageSize, UUID target);
public List<QAEvent> findEventsByTopicAndPageAndTarget(String source, String topic, long offset, int pageSize,
UUID target);
/**
* Count the QA events related to the specified topic and target
*
* @param source the source name
* @param topic the topic to search for
* @param target the uuid of the QA event's target
* @return the count result
*/
public long countEventsByTopicAndTarget(String topic, UUID target);
public long countEventsByTopicAndTarget(String source, String topic, UUID target);
/**
* Find all the event's topics related to the given source for a specific item
*
* @param source the source to search for
* @param source (not null) the source to search for
* @param target the item referring to
* @param offset the offset to apply
* @param pageSize the page size
@@ -185,4 +185,22 @@ public interface QAEventService {
*/
public long countTopicsBySourceAndTarget(String source, UUID target);
/**
* Find all the event's sources related to a specific item
*
* @param target the item referring to
* @param offset the offset to apply
* @param pageSize the page size
* @return the source list
*/
public List<QASource> findAllSourcesByTarget(UUID target, long offset, int pageSize);
/**
* Count all the event's sources related to a specific item
*
* @param target the item uuid
* @return the count result
*/
public long countSourcesByTarget(UUID target);
}

View File

@@ -105,23 +105,6 @@ public class QAEventServiceImpl implements QAEventService {
return solr;
}
@Override
public long countTopics() {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRows(0);
solrQuery.setQuery("*:*");
solrQuery.setFacet(true);
solrQuery.setFacetMinCount(1);
solrQuery.addFacetField(TOPIC);
QueryResponse response;
try {
response = getSolr().query(solrQuery);
} catch (SolrServerException | IOException e) {
throw new RuntimeException(e);
}
return response.getFacetField(TOPIC).getValueCount();
}
@Override
public long countTopicsBySource(String source) {
SolrQuery solrQuery = new SolrQuery();
@@ -130,7 +113,7 @@ public class QAEventServiceImpl implements QAEventService {
solrQuery.setFacet(true);
solrQuery.setFacetMinCount(1);
solrQuery.addFacetField(TOPIC);
solrQuery.addFilterQuery("source:" + source);
solrQuery.addFilterQuery(SOURCE + ":\"" + source + "\"");
QueryResponse response;
try {
response = getSolr().query(solrQuery);
@@ -148,9 +131,9 @@ public class QAEventServiceImpl implements QAEventService {
solrQuery.setFacet(true);
solrQuery.setFacetMinCount(1);
solrQuery.addFacetField(TOPIC);
solrQuery.addFilterQuery("source:" + source);
solrQuery.addFilterQuery(SOURCE + ":\"" + source + "\"");
if (target != null) {
solrQuery.addFilterQuery(RESOURCE_UUID + ":" + target.toString());
solrQuery.addFilterQuery(RESOURCE_UUID + ":\"" + target.toString() + "\"");
}
QueryResponse response;
try {
@@ -182,10 +165,16 @@ public class QAEventServiceImpl implements QAEventService {
}
@Override
public QATopic findTopicByTopicId(String topicId) {
public QATopic findTopicBySourceAndNameAndTarget(String sourceName, String topicName, UUID target) {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRows(0);
solrQuery.setQuery(TOPIC + ":" + topicId.replaceAll("!", "/"));
solrQuery.addFilterQuery(SOURCE + ":\"" + sourceName + "\"");
solrQuery.addFilterQuery(TOPIC + ":\"" + topicName + "\"");
if (target != null) {
solrQuery.setQuery(RESOURCE_UUID + ":\"" + target.toString() + "\"");
} else {
solrQuery.setQuery("*:*");
}
solrQuery.setFacet(true);
solrQuery.setFacetMinCount(1);
solrQuery.addFacetField(TOPIC);
@@ -194,8 +183,9 @@ public class QAEventServiceImpl implements QAEventService {
response = getSolr().query(solrQuery);
FacetField facetField = response.getFacetField(TOPIC);
for (Count c : facetField.getValues()) {
if (c.getName().equals(topicId.replace("!", "/"))) {
if (c.getName().equals(topicName)) {
QATopic topic = new QATopic();
topic.setSource(sourceName);
topic.setKey(c.getName());
topic.setTotalEvents(c.getCount());
topic.setLastEvent(new Date());
@@ -209,50 +199,8 @@ public class QAEventServiceImpl implements QAEventService {
}
@Override
public List<QATopic> findAllTopics(long offset, long count) {
return findAllTopicsBySource(null, offset, count);
}
@Override
public List<QATopic> findAllTopicsBySource(String source, long offset, long count) {
if (source != null && isNotSupportedSource(source)) {
return null;
}
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRows(0);
solrQuery.setQuery("*:*");
solrQuery.setFacet(true);
solrQuery.setFacetMinCount(1);
solrQuery.setFacetLimit((int) (offset + count));
solrQuery.addFacetField(TOPIC);
if (source != null) {
solrQuery.addFilterQuery(SOURCE + ":" + source);
}
QueryResponse response;
List<QATopic> topics = new ArrayList<>();
try {
response = getSolr().query(solrQuery);
FacetField facetField = response.getFacetField(TOPIC);
topics = new ArrayList<>();
int idx = 0;
for (Count c : facetField.getValues()) {
if (idx < offset) {
idx++;
continue;
}
QATopic topic = new QATopic();
topic.setKey(c.getName());
topic.setTotalEvents(c.getCount());
topic.setLastEvent(new Date());
topics.add(topic);
idx++;
}
} catch (SolrServerException | IOException e) {
throw new RuntimeException(e);
}
return topics;
public List<QATopic> findAllTopicsBySource(String source, long offset, int count) {
return findAllTopicsBySourceAndTarget(source, null, offset, count);
}
@Override
@@ -267,9 +215,7 @@ public class QAEventServiceImpl implements QAEventService {
solrQuery.setFacetMinCount(1);
solrQuery.setFacetLimit((int) (offset + count));
solrQuery.addFacetField(TOPIC);
if (source != null) {
solrQuery.addFilterQuery(SOURCE + ":" + source);
}
solrQuery.addFilterQuery(SOURCE + ":\"" + source + "\"");
if (target != null) {
solrQuery.addFilterQuery(RESOURCE_UUID + ":" + target.toString());
}
@@ -286,7 +232,9 @@ public class QAEventServiceImpl implements QAEventService {
continue;
}
QATopic topic = new QATopic();
topic.setSource(source);
topic.setKey(c.getName());
topic.setFocus(target);
topic.setTotalEvents(c.getCount());
topic.setLastEvent(new Date());
topics.add(topic);
@@ -347,7 +295,7 @@ public class QAEventServiceImpl implements QAEventService {
}
@Override
public List<QAEvent> findEventsByTopicAndPage(String topic, long offset, int pageSize) {
public List<QAEvent> findEventsByTopicAndPage(String source, String topic, long offset, int pageSize) {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setStart(((Long) offset).intValue());
@@ -355,7 +303,8 @@ public class QAEventServiceImpl implements QAEventService {
solrQuery.setRows(pageSize);
}
solrQuery.setSort(TRUST, ORDER.desc);
solrQuery.setQuery(TOPIC + ":" + topic.replaceAll("!", "/"));
solrQuery.addFilterQuery(SOURCE + ":\"" + source + "\"");
solrQuery.setQuery(TOPIC + ":\"" + topic + "\"");
QueryResponse response;
try {
@@ -377,15 +326,20 @@ public class QAEventServiceImpl implements QAEventService {
}
@Override
public List<QAEvent> findEventsByTopicAndPageAndTarget(String topic, long offset, int pageSize, UUID target) {
public List<QAEvent> findEventsByTopicAndPageAndTarget(String source, String topic, long offset, int pageSize,
UUID target) {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setStart(((Long) offset).intValue());
solrQuery.setRows(pageSize);
solrQuery.setSort(TRUST, ORDER.desc);
solrQuery.setQuery("*:*");
solrQuery.addFilterQuery(TOPIC + ":" + topic.replaceAll("!", "/"));
solrQuery.addFilterQuery(RESOURCE_UUID + ":" + target.toString());
if (target != null) {
solrQuery.setQuery(RESOURCE_UUID + ":\"" + target.toString() + "\"");
} else {
solrQuery.setQuery("*:*");
}
solrQuery.addFilterQuery(SOURCE + ":\"" + source + "\"");
solrQuery.addFilterQuery(TOPIC + ":\"" + topic + "\"");
QueryResponse response;
try {
@@ -407,10 +361,11 @@ public class QAEventServiceImpl implements QAEventService {
}
@Override
public long countEventsByTopic(String topic) {
public long countEventsByTopic(String source, String topic) {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRows(0);
solrQuery.setQuery(TOPIC + ":" + topic.replace("!", "/"));
solrQuery.setQuery(TOPIC + ":\"" + topic + "\"");
solrQuery.addFilterQuery(SOURCE + ":\"" + source + "\"");
QueryResponse response = null;
try {
response = getSolr().query(solrQuery);
@@ -421,12 +376,16 @@ public class QAEventServiceImpl implements QAEventService {
}
@Override
public long countEventsByTopicAndTarget(String topic, UUID target) {
public long countEventsByTopicAndTarget(String source, String topic, UUID target) {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setRows(0);
solrQuery.setQuery("*:*");
solrQuery.addFilterQuery(TOPIC + ":" + topic.replace("!", "/"));
solrQuery.addFilterQuery(RESOURCE_UUID + ":" + target.toString());
if (target != null) {
solrQuery.setQuery(RESOURCE_UUID + ":\"" + target.toString() + "\"");
} else {
solrQuery.setQuery("*:*");
}
solrQuery.addFilterQuery(SOURCE + ":\"" + source + "\"");
solrQuery.addFilterQuery(TOPIC + ":\"" + topic + "\"");
QueryResponse response = null;
try {
response = getSolr().query(solrQuery);
@@ -438,6 +397,12 @@ public class QAEventServiceImpl implements QAEventService {
@Override
public QASource findSource(String sourceName) {
String[] split = sourceName.split(":");
return findSource(split[0], split.length == 2 ? UUID.fromString(split[1]) : null);
}
@Override
public QASource findSource(String sourceName, UUID target) {
if (isNotSupportedSource(sourceName)) {
return null;
@@ -445,7 +410,10 @@ public class QAEventServiceImpl implements QAEventService {
SolrQuery solrQuery = new SolrQuery("*:*");
solrQuery.setRows(0);
solrQuery.addFilterQuery(SOURCE + ":" + sourceName);
solrQuery.addFilterQuery(SOURCE + ":\"" + sourceName + "\"");
if (target != null) {
solrQuery.addFilterQuery(target + ":" + target.toString());
}
solrQuery.setFacet(true);
solrQuery.setFacetMinCount(1);
solrQuery.addFacetField(SOURCE);
@@ -458,6 +426,7 @@ public class QAEventServiceImpl implements QAEventService {
if (c.getName().equalsIgnoreCase(sourceName)) {
QASource source = new QASource();
source.setName(c.getName());
source.setFocus(target);
source.setTotalEvents(c.getCount());
source.setLastEvent(new Date());
return source;
@@ -489,6 +458,21 @@ public class QAEventServiceImpl implements QAEventService {
return getSupportedSources().length;
}
@Override
public List<QASource> findAllSourcesByTarget(UUID target, long offset, int pageSize) {
return Arrays.stream(getSupportedSources())
.map((sourceName) -> findSource(sourceName, target))
.sorted(comparing(QASource::getTotalEvents).reversed())
.skip(offset)
.limit(pageSize)
.collect(Collectors.toList());
}
@Override
public long countSourcesByTarget(UUID target) {
return getSupportedSources().length;
}
@Override
public boolean isRelatedItemSupported(QAEvent qaevent) {
// Currently only PROJECT topics related to OPENAIRE supports related items

View File

@@ -163,7 +163,7 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 5L))
);
List<QATopic> topicList = qaEventService.findAllTopics(0, 20);
List<QATopic> topicList = qaEventService.findAllTopicsBySource(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)));
@@ -176,14 +176,16 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
+ "\"projects[0].openaireId\":\"40|corda__h2020::6e32f5eb912688f2424c68b851483ea4\","
+ "\"projects[0].title\":\"Tracking Papyrus and Parchment Paths\"}";
assertThat(qaEventService.findEventsByTopicAndPage("ENRICH/MORE/PROJECT", 0, 20), contains(
assertThat(qaEventService.findEventsByTopicAndPage(OPENAIRE_SOURCE, "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)));
String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}";
assertThat(qaEventService.findEventsByTopicAndPage("ENRICH/MISSING/ABSTRACT", 0, 20), contains(
assertThat(qaEventService.findEventsByTopicAndPage(OPENAIRE_SOURCE, "ENRICH/MISSING/ABSTRACT", 0, 20),
contains(
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/99999", secondItem, "Test Publication",
abstractMessage, "ENRICH/MISSING/ABSTRACT", 1.00d)));
@@ -219,14 +221,15 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
assertThat(qaEventService.findAllSources(0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 3L)));
List<QATopic> topicList = qaEventService.findAllTopics(0, 20);
List<QATopic> topicList = qaEventService.findAllTopicsBySource(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)));
String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}";
assertThat(qaEventService.findEventsByTopicAndPage("ENRICH/MISSING/ABSTRACT", 0, 20), contains(
assertThat(qaEventService.findEventsByTopicAndPage(OPENAIRE_SOURCE, "ENRICH/MISSING/ABSTRACT", 0, 20),
contains(
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/99999", item, "Test Publication",
abstractMessage, "ENRICH/MISSING/ABSTRACT", 1.00d)));
@@ -258,11 +261,13 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
assertThat(qaEventService.findAllSources(0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 1L)));
assertThat(qaEventService.findAllTopics(0, 20), contains(QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 1L)));
assertThat(qaEventService.findAllTopicsBySource(OPENAIRE_SOURCE, 0, 20),
contains(QATopicMatcher.with("ENRICH/MISSING/ABSTRACT", 1L)));
String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}";
assertThat(qaEventService.findEventsByTopicAndPage("ENRICH/MISSING/ABSTRACT", 0, 20), contains(
assertThat(qaEventService.findEventsByTopicAndPage(OPENAIRE_SOURCE, "ENRICH/MISSING/ABSTRACT", 0, 20),
contains(
pendingOpenaireEventWith("oai:www.openstarts.units.it:123456789/999991", secondItem, "Test Publication 2",
abstractMessage, "ENRICH/MISSING/ABSTRACT", 1.00d)));
@@ -285,7 +290,7 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
assertThat(qaEventService.findAllSources(0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 0L)));
assertThat(qaEventService.findAllTopics(0, 20), empty());
assertThat(qaEventService.findAllTopicsBySource(OPENAIRE_SOURCE, 0, 20), empty());
verifyNoInteractions(mockBrokerClient);
}
@@ -332,7 +337,7 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
assertThat(qaEventService.findAllSources(0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 6L)));
List<QATopic> topicList = qaEventService.findAllTopics(0, 20);
List<QATopic> topicList = qaEventService.findAllTopicsBySource(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)));
@@ -345,14 +350,16 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
+ "\"projects[0].openaireId\":\"40|corda__h2020::6e32f5eb912688f2424c68b851483ea4\","
+ "\"projects[0].title\":\"Tracking Papyrus and Parchment Paths\"}";
assertThat(qaEventService.findEventsByTopicAndPage("ENRICH/MORE/PROJECT", 0, 20), contains(
assertThat(qaEventService.findEventsByTopicAndPage(OPENAIRE_SOURCE, "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)));
String abstractMessage = "{\"abstracts[0]\":\"Missing Abstract\"}";
List<QAEvent> eventList = qaEventService.findEventsByTopicAndPage("ENRICH/MISSING/ABSTRACT", 0, 20);
List<QAEvent> eventList = qaEventService.findEventsByTopicAndPage(OPENAIRE_SOURCE, "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)));
@@ -388,7 +395,7 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
assertThat(qaEventService.findAllSources(0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 0L)));
assertThat(qaEventService.findAllTopics(0, 20), empty());
assertThat(qaEventService.findAllTopicsBySource(OPENAIRE_SOURCE, 0, 20), empty());
verify(mockBrokerClient).listSubscriptions(openaireURL, "user@test.com");
@@ -439,15 +446,16 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
assertThat(qaEventService.findAllSources(0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 6L)));
List<QATopic> topicList = qaEventService.findAllTopics(0, 20);
List<QATopic> topicList = qaEventService.findAllTopicsBySource(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("ENRICH/MORE/PROJECT", 0, 20), hasSize(1));
assertThat(qaEventService.findEventsByTopicAndPage("ENRICH/MISSING/ABSTRACT", 0, 20), hasSize(2));
assertThat(qaEventService.findEventsByTopicAndPage(OPENAIRE_SOURCE, "ENRICH/MORE/PROJECT", 0, 20), hasSize(1));
assertThat(qaEventService.findEventsByTopicAndPage(OPENAIRE_SOURCE, "ENRICH/MISSING/ABSTRACT", 0, 20),
hasSize(2));
verify(mockBrokerClient).listSubscriptions(openaireURL, "user@test.com");
verify(mockBrokerClient).downloadEvents(eq(openaireURL), eq("sub1"), any());
@@ -472,7 +480,7 @@ public class OpenaireEventsImportIT extends AbstractIntegrationTestWithDatabase
String[] args = new String[] { "import-openaire-events", "-f", getFileLocation("event-more-review.json") };
ScriptLauncher.handleScript(args, ScriptLauncher.getConfig(kernelImpl), handler, kernelImpl);
assertThat(qaEventService.findAllTopics(0, 20), contains(
assertThat(qaEventService.findAllTopicsBySource(OPENAIRE_SOURCE, 0, 20), contains(
QATopicMatcher.with("ENRICH/MORE/REVIEW", 1L)));
assertThat(qaEventService.findAllSources(0, 20), hasItem(QASourceMatcher.with(OPENAIRE_SOURCE, 1L)));

View File

@@ -31,7 +31,8 @@ public class QASourceConverter implements DSpaceConverter<QASource, QASourceRest
public QASourceRest convert(QASource modelObject, Projection projection) {
QASourceRest rest = new QASourceRest();
rest.setProjection(projection);
rest.setId(modelObject.getName());
rest.setId(modelObject.getName()
+ (modelObject.getFocus() != null ? ":" + modelObject.getFocus().toString() : ""));
rest.setLastEvent(modelObject.getLastEvent());
rest.setTotalEvents(modelObject.getTotalEvents());
return rest;

View File

@@ -31,7 +31,9 @@ public class QATopicConverter implements DSpaceConverter<QATopic, QATopicRest> {
public QATopicRest convert(QATopic modelObject, Projection projection) {
QATopicRest rest = new QATopicRest();
rest.setProjection(projection);
rest.setId(modelObject.getKey().replace("/", "!"));
rest.setId(modelObject.getSource() + ":" +
modelObject.getKey().replace("/", "!") +
(modelObject.getFocus() != null ? ":" + modelObject.getFocus().toString() : ""));
rest.setName(modelObject.getKey());
rest.setLastEvent(modelObject.getLastEvent());
rest.setTotalEvents(modelObject.getTotalEvents());

View File

@@ -24,7 +24,6 @@ public class QASourceRest extends BaseObjectRest<String> {
public static final String NAME = "qualityassurancesource";
public static final String CATEGORY = RestAddressableModel.INTEGRATION;
private String id;
private Date lastEvent;
private long totalEvents;
@@ -43,14 +42,6 @@ public class QASourceRest extends BaseObjectRest<String> {
return RestResourceController.class;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Date getLastEvent() {
return lastEvent;
}

View File

@@ -75,19 +75,19 @@ public class QAEventRestRepository extends DSpaceRestRepository<QAEventRest, Str
@SearchRestMethod(name = "findByTopic")
@PreAuthorize("hasAuthority('ADMIN')")
public Page<QAEventRest> findByTopic(Context context, @Parameter(value = "topic", required = true) String topic,
@Parameter(value = "target", required = false) UUID target,
Pageable pageable) {
String[] topicIdSplitted = topic.split(":", 3);
if (topicIdSplitted.length < 2) {
return null;
}
String sourceName = topicIdSplitted[0];
String topicName = topicIdSplitted[1].replaceAll("!", "/");
UUID target = topicIdSplitted.length == 3 ? UUID.fromString(topicIdSplitted[2]) : null;
List<QAEvent> qaEvents = null;
long count = 0L;
if (target == null) {
qaEvents = qaEventService.findEventsByTopicAndPage(topic,
pageable.getOffset(), pageable.getPageSize());
count = qaEventService.countEventsByTopic(topic);
} else {
qaEvents = qaEventService.findEventsByTopicAndPageAndTarget(topic,
pageable.getOffset(), pageable.getPageSize(), target);
count = qaEventService.countEventsByTopicAndTarget(topic, target);
}
qaEvents = qaEventService.findEventsByTopicAndPageAndTarget(sourceName, topicName,
pageable.getOffset(), pageable.getPageSize(), target);
count = qaEventService.countEventsByTopicAndTarget(sourceName, topicName, target);
if (qaEvents == null) {
return null;
}

View File

@@ -52,9 +52,12 @@ public class QAEventTopicLinkRepository extends AbstractDSpaceRestRepository imp
if (qaEvent == null) {
throw new ResourceNotFoundException("No qa event with ID: " + id);
}
QATopic topic = qaEventService.findTopicByTopicId(qaEvent.getTopic().replace("/", "!"));
String source = qaEvent.getSource();
String topicName = qaEvent.getTopic();
QATopic topic = qaEventService
.findTopicBySourceAndNameAndTarget(source, topicName, null);
if (topic == null) {
throw new ResourceNotFoundException("No topic found with id : " + id);
throw new ResourceNotFoundException("No topic found with source: " + source + " topic: " + topicName);
}
return converter.toRest(topic, projection);
}

View File

@@ -8,7 +8,10 @@
package org.dspace.app.rest.repository;
import java.util.List;
import java.util.UUID;
import org.dspace.app.rest.Parameter;
import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.model.QASourceRest;
import org.dspace.core.Context;
import org.dspace.qaevent.QASource;
@@ -49,6 +52,19 @@ public class QASourceRestRepository extends DSpaceRestRepository<QASourceRest, S
return converter.toRestPage(qaSources, pageable, count, utils.obtainProjection());
}
@SearchRestMethod(name = "byTarget")
@PreAuthorize("hasAuthority('ADMIN')")
public Page<QASourceRest> findByTarget(Context context,
@Parameter(value = "target", required = true) UUID target,
Pageable pageable) {
List<QASource> topics = qaEventService
.findAllSourcesByTarget(target, pageable.getOffset(), pageable.getPageSize());
long count = qaEventService.countSourcesByTarget(target);
if (topics == null) {
return null;
}
return converter.toRestPage(topics, pageable, count, utils.obtainProjection());
}
@Override
public Class<QASourceRest> getDomainClass() {

View File

@@ -14,6 +14,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.Parameter;
import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
import org.dspace.app.rest.model.QATopicRest;
import org.dspace.core.Context;
import org.dspace.qaevent.QATopic;
@@ -41,7 +42,14 @@ public class QATopicRestRepository extends DSpaceRestRepository<QATopicRest, Str
@Override
@PreAuthorize("hasAuthority('ADMIN')")
public QATopicRest findOne(Context context, String id) {
QATopic topic = qaEventService.findTopicByTopicId(id);
String[] topicIdSplitted = id.split(":", 3);
if (topicIdSplitted.length < 2) {
return null;
}
String sourceName = topicIdSplitted[0];
String topicName = topicIdSplitted[1].replaceAll("!", "/");
UUID target = topicIdSplitted.length == 3 ? UUID.fromString(topicIdSplitted[2]) : null;
QATopic topic = qaEventService.findTopicBySourceAndNameAndTarget(sourceName, topicName, target);
if (topic == null) {
return null;
}
@@ -49,14 +57,8 @@ public class QATopicRestRepository extends DSpaceRestRepository<QATopicRest, Str
}
@Override
@PreAuthorize("hasAuthority('ADMIN')")
public Page<QATopicRest> findAll(Context context, Pageable pageable) {
List<QATopic> topics = qaEventService.findAllTopics(pageable.getOffset(), pageable.getPageSize());
long count = qaEventService.countTopics();
if (topics == null) {
return null;
}
return converter.toRestPage(topics, pageable, count, utils.obtainProjection());
throw new RepositoryMethodNotImplementedException("Method not allowed!", "");
}
@SearchRestMethod(name = "bySource")
@@ -76,7 +78,7 @@ public class QATopicRestRepository extends DSpaceRestRepository<QATopicRest, Str
@PreAuthorize("hasAuthority('ADMIN')")
public Page<QATopicRest> findByTarget(Context context,
@Parameter(value = "target", required = true) UUID target,
@Parameter(value = "source", required = false) String source,
@Parameter(value = "source", required = true) String source,
Pageable pageable) {
List<QATopic> topics = qaEventService
.findAllTopicsBySourceAndTarget(source, target, pageable.getOffset(), pageable.getPageSize());

View File

@@ -7,9 +7,10 @@
*/
package org.dspace.app.rest;
import static org.dspace.content.QAEvent.OPENAIRE_SOURCE;
import static org.dspace.content.QAEvent.COAR_NOTIFY;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
@@ -118,9 +119,9 @@ public class LDNInboxControllerIT extends AbstractControllerIntegrationTest {
.contentType("application/ld+json")
.content(message))
.andExpect(status().isAccepted());
assertThat(qaEventService.findAllSources(0, 20), contains(QASourceMatcher.with(OPENAIRE_SOURCE, 1L)));
assertThat(qaEventService.findAllSources(0, 20), hasItem(QASourceMatcher.with(COAR_NOTIFY, 1L)));
assertThat(qaEventService.findAllTopics(0, 20), contains(
assertThat(qaEventService.findAllTopicsBySource(COAR_NOTIFY, 0, 20), contains(
QATopicMatcher.with("ENRICH/MORE/REVIEW", 1L)));
}

View File

@@ -171,8 +171,7 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", "ENRICH!MISSING!PID")
.param("target", uuid))
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID:" + uuid.toString()))
.andExpect(status().isOk()).andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", is(0)));
@@ -181,16 +180,31 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", "not-existing")
.param("target", uuid))
.param("topic", QAEvent.OPENAIRE_SOURCE + ":not-existing:" + uuid.toString()))
.andExpect(status().isOk()).andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", is(0)));
// check for an existing topic but a different source
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.COAR_NOTIFY + ":ENRICH!MISSING!PID"))
.andExpect(status().isOk()).andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", is(0)));
// check for an existing item and topic
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", "ENRICH!MISSING!PID")
.param("target", uuid))
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID:" + uuid.toString()))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(1)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
Matchers.contains(QAEventMatcher.matchQAEventEntry(event1))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(1)));
// check for an existing topic
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(1)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
Matchers.contains(QAEventMatcher.matchQAEventEntry(event1))))
@@ -218,21 +232,23 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "ENRICH!MISSING!PID"))
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(2)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
Matchers.containsInAnyOrder(QAEventMatcher.matchQAEventEntry(event1),
QAEventMatcher.matchQAEventEntry(event2))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(2)));
getClient(authToken)
.perform(get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic",
"ENRICH!MISSING!ABSTRACT"))
.perform(get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!ABSTRACT"))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(1)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
Matchers.containsInAnyOrder(QAEventMatcher.matchQAEventEntry(event4))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(1)));
getClient(authToken)
.perform(get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "not-existing"))
.perform(get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":not-existing"))
.andExpect(status().isOk()).andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", is(0)));
}
@@ -261,8 +277,9 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "ENRICH!MISSING!PID")
.param("size", "2"))
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID")
.param("size", "2"))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(2)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
Matchers.containsInAnyOrder(
@@ -271,22 +288,25 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
.andExpect(jsonPath("$._links.self.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.next.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=1"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=1"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.last.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=2"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=2"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.first.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=0"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=0"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.prev.href").doesNotExist())
.andExpect(jsonPath("$.page.size", is(2)))
@@ -295,7 +315,8 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "ENRICH!MISSING!PID")
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID")
.param("size", "2").param("page", "1"))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(2)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
@@ -305,27 +326,32 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
.andExpect(jsonPath("$._links.self.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=1"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=1"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.next.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=2"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=2"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.last.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=2"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=2"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.first.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=0"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=0"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.prev.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=0"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=0"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalPages", is(3)))
@@ -333,7 +359,8 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "ENRICH!MISSING!PID")
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID")
.param("size", "2").param("page", "2"))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(1)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
@@ -342,23 +369,27 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
.andExpect(jsonPath("$._links.self.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=2"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=2"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.next.href").doesNotExist())
.andExpect(jsonPath("$._links.last.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=2"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=2"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.first.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=0"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=0"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.prev.href",
Matchers.allOf(
Matchers.containsString("/api/integration/qualityassuranceevents/search/findByTopic?"),
Matchers.containsString("topic=ENRICH!MISSING!PID"), Matchers.containsString("page=1"),
Matchers.containsString("topic=" + QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"),
Matchers.containsString("page=1"),
Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalPages", is(3)))
@@ -386,7 +417,8 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
context.restoreAuthSystemState();
getClient()
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "ENRICH!MISSING!PID"))
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"))
.andExpect(status().isUnauthorized());
}
@@ -411,7 +443,8 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
String epersonToken = getAuthToken(eperson.getEmail(), password);
getClient(epersonToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "ENRICH!MISSING!PID"))
get("/api/integration/qualityassuranceevents/search/findByTopic")
.param("topic", QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"))
.andExpect(status().isForbidden());
}
@@ -618,11 +651,11 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
.andExpect(jsonPath("$",
hasNoJsonPath("$.metadata['dc.description.abstract']")));
// no pending qa events should be longer available
getClient(authToken).perform(get("/api/integration/qualityassurancetopics")).andExpect(status().isOk())
getClient(authToken).perform(get("/api/integration/qualityassurancesources/" + QAEvent.OPENAIRE_SOURCE))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(status().isOk())
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(0)));
// we should have stored the decision into the database as well
.andExpect(jsonPath("$.totalEvents", is(0)));
}
@Test
@@ -761,13 +794,13 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "ENRICH!MISSING!PID"))
.perform(get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic",
QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(2)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
Matchers.containsInAnyOrder(QAEventMatcher.matchQAEventEntry(event1),
QAEventMatcher.matchQAEventEntry(event2))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(2)));
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(2)));
getClient(authToken).perform(delete("/api/core/items/" + event1.getTarget()))
.andExpect(status().is(204));
@@ -776,8 +809,8 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
.andExpect(status().is(404));
getClient(authToken)
.perform(
get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic", "ENRICH!MISSING!PID"))
.perform(get("/api/integration/qualityassuranceevents/search/findByTopic").param("topic",
QAEvent.OPENAIRE_SOURCE + ":ENRICH!MISSING!PID"))
.andExpect(status().isOk()).andExpect(jsonPath("$._embedded.qualityassuranceevents", Matchers.hasSize(1)))
.andExpect(jsonPath("$._embedded.qualityassuranceevents",
Matchers.containsInAnyOrder(

View File

@@ -24,6 +24,7 @@ import org.dspace.builder.ItemBuilder;
import org.dspace.builder.QAEventBuilder;
import org.dspace.content.Collection;
import org.dspace.content.Item;
import org.dspace.content.QAEvent;
import org.dspace.services.ConfigurationService;
import org.hamcrest.Matchers;
import org.junit.Test;
@@ -41,7 +42,7 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
private ConfigurationService configurationService;
@Test
public void findAllTest() throws Exception {
public void findAllNotImplementedTest() throws Exception {
context.turnOffAuthorisationSystem();
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
@@ -63,69 +64,15 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/integration/qualityassurancetopics")).andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics",
Matchers.containsInAnyOrder(QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/PID", 2),
QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/ABSTRACT", 1),
QATopicMatcher.matchQATopicEntry("ENRICH/MORE/PID", 1))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(3)));
}
@Test
public void findAllUnauthorizedTest() throws Exception {
getClient().perform(get("/api/integration/qualityassurancetopics")).andExpect(status().isUnauthorized());
}
@Test
public void findAllForbiddenTest() throws Exception {
String authToken = getAuthToken(eperson.getEmail(), password);
getClient(authToken).perform(get("/api/integration/qualityassurancetopics")).andExpect(status().isForbidden());
}
@Test
public void findAllPaginationTest() throws Exception {
context.turnOffAuthorisationSystem();
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
//create collection
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
.withTopic("ENRICH/MISSING/PID")
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144300\"}").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 2")
.withTopic("ENRICH/MISSING/PID")
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144301\"}").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 3")
.withTopic("ENRICH/MORE/PID")
.withMessage("{\"pids[0].type\":\"pmid\",\"pids[0].value\":\"10.2307/2144302\"}").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
.withTopic("ENRICH/MISSING/ABSTRACT")
.withMessage(
"{\"abstracts[0]\": \"Descrizione delle caratteristiche...\"}")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/integration/qualityassurancetopics").param("size", "2"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics", Matchers.hasSize(2)))
.andExpect(jsonPath("$.page.size", is(2))).andExpect(jsonPath("$.page.totalElements", is(3)));
getClient(authToken)
.perform(get("/api/integration/qualityassurancetopics")
.param("size", "2")
.param("page", "1"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics", Matchers.hasSize(1)))
.andExpect(jsonPath("$.page.size", is(2))).andExpect(jsonPath("$.page.totalElements", is(3)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics"))
.andExpect(status().isMethodNotAllowed());
}
@Test
public void findOneTest() throws Exception {
context.turnOffAuthorisationSystem();
configurationService.setProperty("qaevent.sources",
new String[] { "openaire", "test-source" });
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
@@ -142,14 +89,51 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
.withTopic("ENRICH/MISSING/ABSTRACT")
.withMessage(
"{\"abstracts[0]\": \"Descrizione delle caratteristiche...\"}")
"{\"test\": \"Test...\"}")
.build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
.withSource("test-source")
.withTopic("TOPIC/TEST")
.withMessage(
"{\"abstracts[0]\": \"Descrizione delle caratteristiche...\"}")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!PID"))
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/openaire:ENRICH!MISSING!PID"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/PID", 2)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!ABSTRACT"))
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/openaire:ENRICH!MISSING!ABSTRACT"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/ABSTRACT", 1)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/test-source:TOPIC!TEST"))
.andExpect(status().isOk())
.andExpect(jsonPath("$", QATopicMatcher.matchQATopicEntry("test-source", "TOPIC/TEST", 1)));
}
@Test
public void findOneNotFoundTest() throws Exception {
context.turnOffAuthorisationSystem();
configurationService.setProperty("qaevent.sources",
new String[] { "openaire" });
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
.withTopic("ENRICH/MISSING/PID")
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144300\"}").build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
// using a wrong id
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!PID"))
.andExpect(status().isNotFound());
// using a plausible id related to an unknown source
getClient(authToken)
.perform(get("/api/integration/qualityassurancetopics/unknown-source:ENRICH!MISSING!ABSTRACT"))
.andExpect(status().isNotFound());
// using a not existing topic
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/openaire:not-existing-topic"))
.andExpect(status().isNotFound());
}
@Test
@@ -162,9 +146,9 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
.withTopic("ENRICH/MISSING/PID").build();
context.restoreAuthSystemState();
getClient().perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!PID"))
.andExpect(status().isUnauthorized());
getClient().perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!ABSTRACT"))
getClient().perform(get("/api/integration/qualityassurancetopics/openaire:ENRICH!MISSING!PID"))
.andExpect(status().isUnauthorized());
getClient().perform(get("/api/integration/qualityassurancetopics/openaire:ENRICH!MISSING!ABSTRACT"))
.andExpect(status().isUnauthorized());
}
@@ -179,9 +163,9 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
.withTopic("ENRICH/MISSING/PID").build();
context.restoreAuthSystemState();
String authToken = getAuthToken(eperson.getEmail(), password);
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!PID"))
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/openaire:ENRICH!MISSING!PID"))
.andExpect(status().isForbidden());
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!ABSTRACT"))
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/openaire:ENRICH!MISSING!ABSTRACT"))
.andExpect(status().isForbidden());
}
@@ -236,8 +220,8 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics",
Matchers.containsInAnyOrder(QATopicMatcher.matchQATopicEntry("TEST/TOPIC/2", 1),
QATopicMatcher.matchQATopicEntry("TEST/TOPIC", 2))))
Matchers.containsInAnyOrder(QATopicMatcher.matchQATopicEntry("test-source", "TEST/TOPIC/2", 1),
QATopicMatcher.matchQATopicEntry("test-source", "TEST/TOPIC", 2))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(2)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
.param("source", "test-source-2"))
@@ -247,6 +231,68 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(0)));
}
@Test
public void findBySourcePaginationTest() throws Exception {
context.turnOffAuthorisationSystem();
configurationService.setProperty("qaevent.sources",
new String[] { "openaire", "test-source", "test-source-2" });
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
//create collection
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
.withTopic("ENRICH/MISSING/PID")
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144300\"}").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 2")
.withTopic("ENRICH/MISSING/PID")
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144301\"}").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 3")
.withTopic("ENRICH/MORE/PID")
.withMessage("{\"pids[0].type\":\"pmid\",\"pids[0].value\":\"10.2307/2144302\"}").build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
.withTopic("ENRICH/MISSING/ABSTRACT")
.withMessage(
"{\"abstracts[0]\": \"Descrizione delle caratteristiche...\"}")
.build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 5")
.withTopic("TEST/TOPIC")
.withSource("test-source")
.build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 6")
.withTopic("TEST/TOPIC")
.withSource("test-source")
.build();
QAEventBuilder.createTarget(context, col1, "Science and Freedom 7")
.withTopic("TEST/TOPIC/2")
.withSource("test-source")
.build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
.param("source", QAEvent.OPENAIRE_SOURCE)
.param("size", "2"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics", Matchers.hasSize(2)))
.andExpect(jsonPath("$.page.size", is(2))).andExpect(jsonPath("$.page.totalElements", is(3)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
.param("source", QAEvent.OPENAIRE_SOURCE)
.param("size", "2")
.param("page", "1"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics", Matchers.hasSize(1)))
.andExpect(jsonPath("$.page.size", is(2))).andExpect(jsonPath("$.page.totalElements", is(3)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
.param("source", "test-source")
.param("size", "2"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics", Matchers.hasSize(2)))
.andExpect(jsonPath("$.page.size", is(2))).andExpect(jsonPath("$.page.totalElements", is(2)));
}
@Test
public void findBySourceUnauthorizedTest() throws Exception {
context.turnOffAuthorisationSystem();
@@ -316,38 +362,43 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
.withMessage("{\"pids[0].type\":\"pmid\",\"pids[0].value\":\"2144301\"}").build();
context.restoreAuthSystemState();
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("target", item1.getID().toString()))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics",
Matchers.containsInAnyOrder(QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/PID", 1),
QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/ABSTRACT", 1),
QATopicMatcher.matchQATopicEntry("TEST/TOPIC", 1),
QATopicMatcher.matchQATopicEntry("TEST/TOPIC/2", 1))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(4)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("target", item1.getID().toString())
.param("source", "openaire"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics",
Matchers.containsInAnyOrder(QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/PID", 1),
QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/ABSTRACT", 1))))
Matchers.containsInAnyOrder(
QATopicMatcher.matchQATopicEntry("openaire", "ENRICH/MISSING/PID",
item1.getID().toString(), 1),
QATopicMatcher.matchQATopicEntry("openaire", "ENRICH/MISSING/ABSTRACT",
item1.getID().toString(), 1))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(2)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("target", item2.getID().toString()))
.param("target", item2.getID().toString())
.param("source", "openaire"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics",
Matchers.containsInAnyOrder(QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/PID", 2))))
Matchers.containsInAnyOrder(
QATopicMatcher.matchQATopicEntry("openaire", "ENRICH/MISSING/PID",
item2.getID().toString(), 2))))
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(1)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("target", UUID.randomUUID().toString()))
.param("target", UUID.randomUUID().toString())
.param("source", "openaire"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics").doesNotExist())
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(0)));
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("target", item2.getID().toString())
.param("source", "test-source"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.qualityassurancetopics").doesNotExist())
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(0)));
}
@Test
@@ -362,7 +413,8 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
.withTopic("ENRICH/MISSING/PID").build();
context.restoreAuthSystemState();
getClient().perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("target", item1.getID().toString()))
.param("source", "openaire")
.param("target", item1.getID().toString()))
.andExpect(status().isUnauthorized());
}
@@ -379,7 +431,8 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
context.restoreAuthSystemState();
String authToken = getAuthToken(eperson.getEmail(), password);
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("target", item1.getID().toString()))
.param("target", item1.getID().toString())
.param("source", "test-source"))
.andExpect(status().isForbidden());
}
@@ -399,6 +452,9 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("source", "test-source"))
.andExpect(status().isBadRequest());
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/byTarget")
.param("target", item1.getID().toString()))
.andExpect(status().isBadRequest());
}
}

View File

@@ -12,6 +12,7 @@ import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.is;
import org.dspace.app.rest.model.hateoas.QATopicResource;
import org.dspace.content.QAEvent;
import org.hamcrest.Matcher;
/**
@@ -24,22 +25,40 @@ public class QATopicMatcher {
private QATopicMatcher() { }
public static Matcher<? super Object> matchQATopicEntry(String key, int totalEvents) {
public static Matcher<? super Object> matchQATopicEntry(String topicName, int totalEvents) {
return matchQATopicEntry(QAEvent.OPENAIRE_SOURCE, topicName, totalEvents);
}
public static Matcher<? super Object> matchQATopicEntry(String topicName) {
return matchQATopicEntry(QAEvent.OPENAIRE_SOURCE, topicName);
}
public static Matcher<? super Object> matchQATopicEntry(String source, String topicName, int totalEvents) {
return allOf(
hasJsonPath("$.type", is("qualityassurancetopic")),
hasJsonPath("$.name", is(key)),
hasJsonPath("$.id", is(key.replace("/", "!"))),
hasJsonPath("$.name", is(topicName)),
hasJsonPath("$.id", is(source + ":" + topicName.replace("/", "!"))),
hasJsonPath("$.totalEvents", is(totalEvents))
);
}
public static Matcher<? super Object> matchQATopicEntry(String key) {
public static Matcher<? super Object> matchQATopicEntry(String source, String topicName) {
return allOf(
hasJsonPath("$.type", is("qualityassurancetopic")),
hasJsonPath("$.name", is(key)),
hasJsonPath("$.id", is(key.replace("/", "/")))
hasJsonPath("$.name", is(topicName)),
hasJsonPath("$.id", is(source + ":" + topicName.replace("/", "!")))
);
}
public static Matcher matchQATopicEntry(String source, String topicName, String itemUuid, int totalEvents) {
return allOf(
hasJsonPath("$.type", is("qualityassurancetopic")),
hasJsonPath("$.name", is(topicName)),
hasJsonPath("$.id", is(source + ":" + topicName.replace("/", "!") + ":" + itemUuid)),
hasJsonPath("$.totalEvents", is(totalEvents))
);
}
}