mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
solr authority
This commit is contained in:
@@ -12,14 +12,48 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.authority.PersonAuthorityValue;
|
||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class AuthorityRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
ConfigurationService configurationService;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
super.setUp();
|
||||
configurationService.setProperty("plugin.named.org.dspace.content.authority.ChoiceAuthority",
|
||||
"org.dspace.content.authority.SolrAuthority = SolrAuthorAuthority");
|
||||
|
||||
configurationService.setProperty("solr.authority.server",
|
||||
"${solr.server}/authority");
|
||||
configurationService.setProperty("choices.plugin.dc.contributor.author",
|
||||
"SolrAuthorAuthority");
|
||||
configurationService.setProperty("choices.presentation.dc.contributor.author",
|
||||
"authorLookup");
|
||||
configurationService.setProperty("authority.controlled.dc.contributor.author",
|
||||
"true");
|
||||
|
||||
configurationService.setProperty("authority.author.indexer.field.1",
|
||||
"dc.contributor.author");
|
||||
|
||||
PersonAuthorityValue person1 = new PersonAuthorityValue();
|
||||
person1.setLastName("Shirasaka");
|
||||
person1.setFirstName("Seiko");
|
||||
person1.setValue("Shirasaka, Seiko");
|
||||
person1.setField("dc_contributor_author");
|
||||
AuthorityServiceFactory.getInstance().getAuthorityIndexingService().indexContent(person1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void correctQueryTest() throws Exception {
|
||||
public void correctSrscQueryTest() throws Exception {
|
||||
String token = getAuthToken(admin.getEmail(), password);
|
||||
getClient(token).perform(
|
||||
get("/api/integration/authorities/srsc/entries")
|
||||
@@ -31,7 +65,7 @@ public class AuthorityRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incorrectQueryTest() throws Exception {
|
||||
public void noResultsSrscQueryTest() throws Exception {
|
||||
String token = getAuthToken(admin.getEmail(), password);
|
||||
getClient(token).perform(
|
||||
get("/api/integration/authorities/srsc/entries")
|
||||
@@ -47,7 +81,7 @@ public class AuthorityRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
/**
|
||||
* This functionality is currently broken, it returns all 22 values
|
||||
*/
|
||||
public void commonTypesTest() throws Exception {
|
||||
public void correctCommonTypesTest() throws Exception {
|
||||
String token = getAuthToken(admin.getEmail(), password);
|
||||
getClient(token).perform(
|
||||
get("/api/integration/authorities/common_types/entries")
|
||||
@@ -58,6 +92,18 @@ public class AuthorityRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.andExpect(jsonPath("$.page.totalElements", Matchers.is(2)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void correctSolrQueryTest() throws Exception {
|
||||
String token = getAuthToken(admin.getEmail(), password);
|
||||
getClient(token).perform(
|
||||
get("/api/integration/authorities/SolrAuthorAuthority/entries")
|
||||
.param("metadata", "dc.contributor.author")
|
||||
.param("query", "Shirasaka")
|
||||
.param("size", "1000"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.page.totalElements", Matchers.is(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void retrieveSrscValueTest() throws Exception {
|
||||
String token = getAuthToken(admin.getEmail(), password);
|
||||
@@ -88,4 +134,10 @@ public class AuthorityRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.page.totalElements", Matchers.is(1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
AuthorityServiceFactory.getInstance().getAuthorityIndexingService().cleanIndex();
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
@@ -101,6 +101,7 @@
|
||||
<field name="last_name" type="text" multiValued="false" indexed="true" stored="true" required="false"/>
|
||||
<field name="name_variant" type="text" multiValued="true" indexed="true" stored="true" required="false"/>
|
||||
<dynamicField name="label_*" type="text" multiValued="true" indexed="true" stored="true" required="false"/>
|
||||
<dynamicField name="value_*" type="text" multiValued="false" indexed="true" stored="true" required="false"/>
|
||||
<field name="all_labels" type="text" multiValued="true" indexed="true" stored="true" required="false"/>
|
||||
<copyField source="label_*" dest="all_labels"/>
|
||||
<field name="deleted" type="boolean" multiValued="false" indexed="true" stored="true" required="false"/>
|
||||
|
@@ -106,6 +106,7 @@
|
||||
<requestHandler name="standard" class="solr.SearchHandler" default="true">
|
||||
<lst name="defaults">
|
||||
<str name="echoParams">explicit</str>
|
||||
<str name="df">all_labels</str>
|
||||
</lst>
|
||||
</requestHandler>
|
||||
|
||||
|
Reference in New Issue
Block a user