VIVO-906 Explicitly configure the SearchIndexExcluders and DocumentModifiers.
This commit is contained in:
parent
ebb31eb081
commit
1e6b66a12c
15 changed files with 342 additions and 270 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
|
||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_RAW;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
@ -9,6 +10,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.beans.IndividualStub;
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||
|
@ -16,8 +18,6 @@ import com.hp.hpl.jena.rdf.model.Statement;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||
import edu.cornell.mannlib.vitro.webapp.searchengine.base.BaseSearchInputDocument;
|
||||
|
||||
|
@ -38,27 +38,29 @@ public class NameFieldsTest {
|
|||
doc = new BaseSearchInputDocument();
|
||||
|
||||
RDFServiceModel rdfService = new RDFServiceModel(baseModel);
|
||||
RDFServiceFactory rdfServiceFactory = new RDFServiceFactorySingle(
|
||||
rdfService);
|
||||
nameFields = new NameFields(rdfServiceFactory);
|
||||
ContextModelAccessStub models = new ContextModelAccessStub();
|
||||
models.setRDFService(CONTENT, rdfService);
|
||||
|
||||
nameFields = new NameFields();
|
||||
nameFields.setContextModels(models);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullIndividual() throws SkipIndividualException {
|
||||
public void nullIndividual() {
|
||||
SearchInputDocument expected = new BaseSearchInputDocument(doc);
|
||||
|
||||
assertResultingSearchDocument(null, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullUri() throws SkipIndividualException {
|
||||
public void nullUri() {
|
||||
SearchInputDocument expected = new BaseSearchInputDocument(doc);
|
||||
|
||||
assertResultingSearchDocument(new IndividualStub(null), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void foundNoLabels() throws SkipIndividualException {
|
||||
public void foundNoLabels() {
|
||||
SearchInputDocument expected = new BaseSearchInputDocument(doc);
|
||||
expected.addField(NAME_RAW, "");
|
||||
|
||||
|
@ -67,7 +69,7 @@ public class NameFieldsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void foundOneLabel() throws SkipIndividualException {
|
||||
public void foundOneLabel() {
|
||||
baseModel.add(stmt(INDIVIDUAL_URI, LABEL_PROPERTY_URI, "label1"));
|
||||
|
||||
SearchInputDocument expected = new BaseSearchInputDocument(doc);
|
||||
|
@ -78,7 +80,7 @@ public class NameFieldsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void foundTwoLabels() throws SkipIndividualException {
|
||||
public void foundTwoLabels() {
|
||||
baseModel.add(stmt(INDIVIDUAL_URI, LABEL_PROPERTY_URI, "label1"));
|
||||
baseModel.add(stmt(INDIVIDUAL_URI, LABEL_PROPERTY_URI, "label2"));
|
||||
|
||||
|
@ -100,7 +102,7 @@ public class NameFieldsTest {
|
|||
}
|
||||
|
||||
private void assertResultingSearchDocument(Individual ind,
|
||||
SearchInputDocument expected) throws SkipIndividualException {
|
||||
SearchInputDocument expected) {
|
||||
nameFields.modifyDocument(ind, doc);
|
||||
assertEquals(expected, doc);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*/
|
||||
package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
|
@ -11,6 +13,7 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub;
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modules.ApplicationStub;
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineStub;
|
||||
import stubs.javax.servlet.ServletContextStub;
|
||||
|
@ -25,13 +28,11 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputField;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||
|
||||
public class ThumbnailImageURLTest extends AbstractTestClass{
|
||||
RDFServiceFactory testRDF;
|
||||
ContextModelAccessStub contextModels;
|
||||
String personsURI = "http://vivo.cornell.edu/individual/individual8803";
|
||||
|
||||
/**
|
||||
|
@ -45,7 +46,8 @@ public class ThumbnailImageURLTest extends AbstractTestClass{
|
|||
Model model = ModelFactory.createDefaultModel();
|
||||
InputStream in = ThumbnailImageURLTest.class.getResourceAsStream("testPerson.n3");
|
||||
model.read(in,"","N3");
|
||||
testRDF = new RDFServiceFactorySingle( new RDFServiceModel( model ) );
|
||||
contextModels = new ContextModelAccessStub();
|
||||
contextModels.setRDFService(CONTENT, new RDFServiceModel( model ));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +57,8 @@ public class ThumbnailImageURLTest extends AbstractTestClass{
|
|||
@Test
|
||||
public void testThumbnailFieldCreatedInSearchDoc() {
|
||||
SearchInputDocument doc = ApplicationUtils.instance().getSearchEngine().createInputDocument();
|
||||
ThumbnailImageURL testMe = new ThumbnailImageURL( testRDF );
|
||||
ThumbnailImageURL testMe = new ThumbnailImageURL();
|
||||
testMe.setContextModels(contextModels);
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI(personsURI);
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
package stubs.edu.cornell.mannlib.vitro.webapp.modelaccess;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.ReasoningOption.ASSERTIONS_AND_INFERENCES;
|
||||
import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -30,6 +32,7 @@ public class ContextModelAccessStub implements ContextModelAccess {
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private final Map<ReasoningOption, WebappDaoFactory> wadfMap = new HashMap<>();
|
||||
private final Map<WhichService, RDFService> rdfServiceMap = new EnumMap<>(WhichService.class);
|
||||
|
||||
public void setWebappDaoFactory(WebappDaoFactory wadf) {
|
||||
setWebappDaoFactory(wadf, ASSERTIONS_AND_INFERENCES);
|
||||
|
@ -39,6 +42,10 @@ public class ContextModelAccessStub implements ContextModelAccess {
|
|||
ReasoningOption option) {
|
||||
wadfMap.put(option, wadf);
|
||||
}
|
||||
|
||||
public void setRDFService(WhichService which, RDFService rdfService) {
|
||||
rdfServiceMap.put(which, rdfService);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Stub methods
|
||||
|
@ -49,22 +56,20 @@ public class ContextModelAccessStub implements ContextModelAccess {
|
|||
return wadfMap.get(ASSERTIONS_AND_INFERENCES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RDFService getRDFService() {
|
||||
return getRDFService(CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RDFService getRDFService(WhichService which) {
|
||||
return rdfServiceMap.get(which);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Un-implemented methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public RDFService getRDFService() {
|
||||
throw new RuntimeException(
|
||||
"ContextModelAccessStub.getRDFService() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public RDFService getRDFService(WhichService which) {
|
||||
throw new RuntimeException(
|
||||
"ContextModelAccessStub.getRDFService() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset getDataset() {
|
||||
throw new RuntimeException(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue