mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
[CST-12108] fix failed tests
This commit is contained in:
@@ -31,7 +31,8 @@ public class QATopicConverter implements DSpaceConverter<QATopic, QATopicRest> {
|
|||||||
public QATopicRest convert(QATopic modelObject, Projection projection) {
|
public QATopicRest convert(QATopic modelObject, Projection projection) {
|
||||||
QATopicRest rest = new QATopicRest();
|
QATopicRest rest = new QATopicRest();
|
||||||
rest.setProjection(projection);
|
rest.setProjection(projection);
|
||||||
rest.setId(modelObject.getSource() + ":" + modelObject.getKey().replace("/", "!"));
|
rest.setId(modelObject.getSource() + ":" + modelObject.getKey().replace("/", "!") +
|
||||||
|
(modelObject.getFocus() != null ? ":" + modelObject.getFocus().toString() : ""));
|
||||||
rest.setName(modelObject.getKey());
|
rest.setName(modelObject.getKey());
|
||||||
rest.setLastEvent(modelObject.getLastEvent());
|
rest.setLastEvent(modelObject.getLastEvent());
|
||||||
rest.setTotalEvents(modelObject.getTotalEvents());
|
rest.setTotalEvents(modelObject.getTotalEvents());
|
||||||
|
@@ -43,11 +43,15 @@ public class QATopicRestRepository extends DSpaceRestRepository<QATopicRest, Str
|
|||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasPermission(#id, 'QUALITYASSURANCETOPIC', 'READ')")
|
@PreAuthorize("hasPermission(#id, 'QUALITYASSURANCETOPIC', 'READ')")
|
||||||
public QATopicRest findOne(Context context, String id) {
|
public QATopicRest findOne(Context context, String id) {
|
||||||
QATopic topic = qaEventService.findTopicByTopicId(id);
|
String[] topicIdSplitted = id.split(":", 3);
|
||||||
if (topic == null) {
|
if (topicIdSplitted.length < 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return converter.toRest(topic, utils.obtainProjection());
|
String sourceName = topicIdSplitted[0];
|
||||||
|
String topicName = topicIdSplitted[1].replaceAll("!", "/");
|
||||||
|
UUID target = topicIdSplitted.length == 3 ? UUID.fromString(topicIdSplitted[2]) : null;
|
||||||
|
QATopic topic = qaEventService.findTopicBySourceAndNameAndTarget(context, sourceName, topicName, target);
|
||||||
|
return (topic != null) ? converter.toRest(topic, utils.obtainProjection()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SearchRestMethod(name = "bySource")
|
@SearchRestMethod(name = "bySource")
|
||||||
|
@@ -20,6 +20,7 @@ import org.dspace.builder.CollectionBuilder;
|
|||||||
import org.dspace.builder.CommunityBuilder;
|
import org.dspace.builder.CommunityBuilder;
|
||||||
import org.dspace.builder.QAEventBuilder;
|
import org.dspace.builder.QAEventBuilder;
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
|
import org.dspace.qaevent.QANotifyPatterns;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -38,114 +39,58 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findAllTest() throws Exception {
|
public void findAllTest() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
getClient(adminToken).perform(get("/api/integration/qualityassurancetopics"))
|
||||||
.withName("Parent Community")
|
.andExpect(status().isMethodNotAllowed());
|
||||||
.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();
|
|
||||||
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")).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)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findOneTest() throws Exception {
|
public void findOneTest() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
configurationService.setProperty("qaevent.sources", new String[] { "openaire", "test-source" });
|
||||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||||
.withName("Parent Community")
|
.withName("Parent Community")
|
||||||
.build();
|
.build();
|
||||||
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
|
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity)
|
||||||
|
.withName("Collection 1")
|
||||||
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
|
||||||
.withTopic("ENRICH/MISSING/PID")
|
.withTopic(QANotifyPatterns.TOPIC_ENRICH_MISSING_PID)
|
||||||
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144300\"}").build();
|
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144300\"}")
|
||||||
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom 2")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom 2")
|
||||||
.withTopic("ENRICH/MISSING/PID")
|
.withTopic(QANotifyPatterns.TOPIC_ENRICH_MISSING_PID)
|
||||||
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144301\"}").build();
|
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144301\"}")
|
||||||
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom 3")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom 3")
|
||||||
.withTopic("ENRICH/MORE/PID")
|
.withTopic(QANotifyPatterns.TOPIC_ENRICH_MORE_PID)
|
||||||
.withMessage("{\"pids[0].type\":\"pmid\",\"pids[0].value\":\"10.2307/2144302\"}").build();
|
.withMessage("{\"pids[0].type\":\"pmid\",\"pids[0].value\":\"10.2307/2144302\"}")
|
||||||
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
|
||||||
.withTopic("ENRICH/MISSING/ABSTRACT")
|
.withTopic(org.dspace.qaevent.QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT)
|
||||||
.withMessage(
|
.withMessage("{\"test\": \"Test...\"}")
|
||||||
"{\"abstracts[0]\": \"Descrizione delle caratteristiche...\"}")
|
.build();
|
||||||
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
|
||||||
|
.withSource("test-source")
|
||||||
|
.withTopic("TOPIC/TEST")
|
||||||
|
.withMessage("{\"abstracts[0]\": \"Descrizione delle caratteristiche...\"}")
|
||||||
.build();
|
.build();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String authToken = getAuthToken(admin.getEmail(), password);
|
|
||||||
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!PID"))
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
.andExpect(jsonPath("$", QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/PID", 2)));
|
getClient(adminToken).perform(get("/api/integration/qualityassurancetopics/openaire:ENRICH!MISSING!PID"))
|
||||||
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/ENRICH!MISSING!ABSTRACT"))
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$", QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/ABSTRACT", 1)));
|
.andExpect(jsonPath("$", QATopicMatcher.matchQATopicEntry(
|
||||||
|
QANotifyPatterns.TOPIC_ENRICH_MISSING_PID, 2)));
|
||||||
|
|
||||||
|
getClient(adminToken).perform(get("/api/integration/qualityassurancetopics/openaire:ENRICH!MISSING!ABSTRACT"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$", QATopicMatcher.matchQATopicEntry(
|
||||||
|
QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1)));
|
||||||
|
|
||||||
|
getClient(adminToken).perform(get("/api/integration/qualityassurancetopics/test-source:TOPIC!TEST"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$",QATopicMatcher.matchQATopicEntry("test-source", "TOPIC/TEST", 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -184,25 +129,31 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void findBySourceTest() throws Exception {
|
public void findBySourceTest() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
configurationService.setProperty("qaevent.sources",
|
configurationService.setProperty("qaevent.sources", new String[] { "openaire","test-source","test-source-2" });
|
||||||
new String[] { "openaire", "test-source", "test-source-2" });
|
|
||||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||||
.withName("Parent Community")
|
.withName("Parent Community")
|
||||||
.build();
|
.build();
|
||||||
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
|
|
||||||
|
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity)
|
||||||
|
.withName("Collection 1")
|
||||||
|
.build();
|
||||||
|
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
|
||||||
.withTopic("ENRICH/MISSING/PID")
|
.withTopic(QANotifyPatterns.TOPIC_ENRICH_MISSING_PID)
|
||||||
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144300\"}").build();
|
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144300\"}")
|
||||||
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom 2")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom 2")
|
||||||
.withTopic("ENRICH/MISSING/PID")
|
.withTopic(QANotifyPatterns.TOPIC_ENRICH_MISSING_PID)
|
||||||
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144301\"}").build();
|
.withMessage("{\"pids[0].type\":\"doi\",\"pids[0].value\":\"10.2307/2144301\"}")
|
||||||
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom 3")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom 3")
|
||||||
.withTopic("ENRICH/MORE/PID")
|
.withTopic(QANotifyPatterns.TOPIC_ENRICH_MORE_PID)
|
||||||
.withMessage("{\"pids[0].type\":\"pmid\",\"pids[0].value\":\"10.2307/2144302\"}").build();
|
.withMessage("{\"pids[0].type\":\"pmid\",\"pids[0].value\":\"10.2307/2144302\"}")
|
||||||
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom 4")
|
||||||
.withTopic("ENRICH/MISSING/ABSTRACT")
|
.withTopic(org.dspace.qaevent.QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT)
|
||||||
.withMessage(
|
.withMessage("{\"abstracts[0]\": \"Descrizione delle caratteristiche...\"}")
|
||||||
"{\"abstracts[0]\": \"Descrizione delle caratteristiche...\"}")
|
|
||||||
.build();
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom 5")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom 5")
|
||||||
.withTopic("TEST/TOPIC")
|
.withTopic("TEST/TOPIC")
|
||||||
@@ -217,30 +168,38 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
|
|||||||
.withSource("test-source")
|
.withSource("test-source")
|
||||||
.build();
|
.build();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String authToken = getAuthToken(admin.getEmail(), password);
|
String authToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
|
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
|
||||||
.param("source", "openaire"))
|
.param("source", "openaire"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$._embedded.qualityassurancetopics",
|
.andExpect(jsonPath("$._embedded.qualityassurancetopics", Matchers.containsInAnyOrder(
|
||||||
Matchers.containsInAnyOrder(QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/PID", 2),
|
QATopicMatcher.matchQATopicEntry(QANotifyPatterns.TOPIC_ENRICH_MISSING_PID, 2),
|
||||||
QATopicMatcher.matchQATopicEntry("ENRICH/MISSING/ABSTRACT", 1),
|
QATopicMatcher.matchQATopicEntry(QANotifyPatterns.TOPIC_ENRICH_MISSING_ABSTRACT, 1),
|
||||||
QATopicMatcher.matchQATopicEntry("ENRICH/MORE/PID", 1))))
|
QATopicMatcher.matchQATopicEntry(QANotifyPatterns.TOPIC_ENRICH_MORE_PID, 1)
|
||||||
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(3)));
|
)))
|
||||||
|
.andExpect(jsonPath("$.page.size", is(20)))
|
||||||
|
.andExpect(jsonPath("$.page.totalElements", is(3)));
|
||||||
|
|
||||||
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
|
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
|
||||||
.param("source", "test-source"))
|
.param("source", "test-source"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$._embedded.qualityassurancetopics",
|
.andExpect(jsonPath("$._embedded.qualityassurancetopics", Matchers.containsInAnyOrder(
|
||||||
Matchers.containsInAnyOrder(QATopicMatcher.matchQATopicEntry("TEST/TOPIC/2", 1),
|
QATopicMatcher.matchQATopicEntry("test-source", "TEST/TOPIC/2", 1),
|
||||||
QATopicMatcher.matchQATopicEntry("TEST/TOPIC", 2))))
|
QATopicMatcher.matchQATopicEntry("test-source", "TEST/TOPIC", 2)
|
||||||
.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(get("/api/integration/qualityassurancetopics/search/bySource")
|
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
|
||||||
.param("source", "test-source-2"))
|
.param("source", "test-source-2"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(contentType))
|
.andExpect(content().contentType(contentType))
|
||||||
.andExpect(jsonPath("$._embedded.qualityassurancetopics").doesNotExist())
|
.andExpect(jsonPath("$._embedded.qualityassurancetopics").doesNotExist())
|
||||||
.andExpect(jsonPath("$.page.size", is(20))).andExpect(jsonPath("$.page.totalElements", is(0)));
|
.andExpect(jsonPath("$.page.size", is(20)))
|
||||||
|
.andExpect(jsonPath("$.page.totalElements", is(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -249,29 +208,17 @@ public class QATopicRestRepositoryIT extends AbstractControllerIntegrationTest {
|
|||||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||||
.withName("Parent Community")
|
.withName("Parent Community")
|
||||||
.build();
|
.build();
|
||||||
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build();
|
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity)
|
||||||
|
.withName("Collection 1")
|
||||||
|
.build();
|
||||||
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
|
QAEventBuilder.createTarget(context, col1, "Science and Freedom")
|
||||||
.withTopic("ENRICH/MISSING/PID").build();
|
.withTopic("ENRICH/MISSING/PID")
|
||||||
|
.build();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
getClient().perform(get("/api/integration/qualityassurancetopics/search/bySource")
|
getClient().perform(get("/api/integration/qualityassurancetopics/search/bySource")
|
||||||
.param("source", "openaire"))
|
.param("source", "openaire"))
|
||||||
.andExpect(status().isUnauthorized());
|
.andExpect(status().isUnauthorized());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void findBySourceForbiddenTest() throws Exception {
|
|
||||||
context.turnOffAuthorisationSystem();
|
|
||||||
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").build();
|
|
||||||
context.restoreAuthSystemState();
|
|
||||||
String authToken = getAuthToken(eperson.getEmail(), password);
|
|
||||||
getClient(authToken).perform(get("/api/integration/qualityassurancetopics/search/bySource")
|
|
||||||
.param("source", "openaire"))
|
|
||||||
.andExpect(status().isForbidden());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import static org.hamcrest.Matchers.allOf;
|
|||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
import org.dspace.app.rest.model.hateoas.QATopicResource;
|
import org.dspace.app.rest.model.hateoas.QATopicResource;
|
||||||
|
import org.dspace.content.QAEvent;
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,21 +25,40 @@ public class QATopicMatcher {
|
|||||||
|
|
||||||
private 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(
|
return allOf(
|
||||||
hasJsonPath("$.type", is("qualityassurancetopic")),
|
hasJsonPath("$.type", is("qualityassurancetopic")),
|
||||||
hasJsonPath("$.name", is(key)),
|
hasJsonPath("$.name", is(topicName)),
|
||||||
hasJsonPath("$.id", is(key.replace("/", "!"))),
|
hasJsonPath("$.id", is(source + ":" + topicName.replace("/", "!"))),
|
||||||
hasJsonPath("$.totalEvents", is(totalEvents))
|
hasJsonPath("$.totalEvents", is(totalEvents))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Matcher<? super Object> matchQATopicEntry(String key) {
|
public static Matcher<? super Object> matchQATopicEntry(String source, String topicName) {
|
||||||
return allOf(
|
return allOf(
|
||||||
hasJsonPath("$.type", is("qualityassurancetopic")),
|
hasJsonPath("$.type", is("qualityassurancetopic")),
|
||||||
hasJsonPath("$.name", is(key)),
|
hasJsonPath("$.name", is(topicName)),
|
||||||
hasJsonPath("$.id", is(key.replace("/", "/")))
|
hasJsonPath("$.id", is(source + ":" + topicName.replace("/", "!")))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matcher<? super Object> 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))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user