Created basic IT

This commit is contained in:
Raf Ponsaerts
2019-09-04 09:23:47 +02:00
parent 5864b53555
commit a73ba83db0

View File

@@ -0,0 +1,55 @@
/**
* 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.app.rest;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
import org.hamcrest.Matchers;
import org.junit.Test;
public class AuthorityRestRepositoryIT extends AbstractControllerIntegrationTest {
@Test
public void correctQueryTest() throws Exception {
String token = getAuthToken(admin.getEmail(), password);
getClient(token).perform(
get("/api/integration/authorities/srsc/entries")
.param("metadata", "dc.subject")
.param("query", "Research")
.param("size", "1000"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.page.totalElements", Matchers.greaterThan(1)));
}
@Test
public void incorrectQueryTest() throws Exception {
String token = getAuthToken(admin.getEmail(), password);
getClient(token).perform(
get("/api/integration/authorities/srsc/entries")
.param("metadata", "dc.subject")
.param("query", "Research2")
.param("size", "1000"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.page.totalElements", Matchers.is(0)));
}
@Test
public void commonTypesTest() throws Exception {
String token = getAuthToken(admin.getEmail(), password);
getClient(token).perform(
get("/api/integration/authorities/common_types/entries")
.param("metadata", "dc.type")
.param("query", "Book")
.param("size", "1000"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.page.totalElements", Matchers.greaterThan(0)));
}
}