Merge branch 'develop' into feature/fauxEditing
This commit is contained in:
commit
ef6f92539f
113 changed files with 1463 additions and 9883 deletions
|
@ -2,9 +2,9 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.testing;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
|
|
@ -5,9 +5,9 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy;
|
|||
import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.AUTHORIZED;
|
||||
import static edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization.INCONCLUSIVE;
|
||||
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAction.SOME_LITERAL;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -4,7 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.config;
|
|||
|
||||
import static edu.cornell.mannlib.vitro.webapp.config.RevisionInfoBean.DUMMY_BEAN;
|
||||
import static edu.cornell.mannlib.vitro.webapp.config.RevisionInfoBean.LevelRevisionInfo.DUMMY_LEVEL;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
|
|
@ -5,8 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.controller.individual;
|
|||
import static edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet.N3_MIMETYPE;
|
||||
import static edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet.RDFXML_MIMETYPE;
|
||||
import static edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet.TTL_MIMETYPE;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAction.SOME_URI;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
package freemarker.ext.dump;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
package freemarker.ext.dump;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -7,10 +7,13 @@ import java.lang.reflect.Field;
|
|||
import javax.servlet.ServletContext;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.application.VitroHomeDirectory;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.Application;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.fileStorage.FileStorage;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.imageProcessor.ImageProcessor;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.tripleSource.ConfigurationTripleSource;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.tripleSource.ContentTripleSource;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
|
@ -61,6 +64,12 @@ public class ApplicationStub implements Application {
|
|||
// Un-implemented methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public VitroHomeDirectory getHomeDirectory() {
|
||||
throw new RuntimeException(
|
||||
"ApplicationStub.getHomeDirectory() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageProcessor getImageProcessor() {
|
||||
throw new RuntimeException(
|
||||
|
@ -74,4 +83,22 @@ public class ApplicationStub implements Application {
|
|||
"ApplicationStub.getFileStorage() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
throw new RuntimeException(
|
||||
"ApplicationStub.shutdown() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentTripleSource getContentTripleSource() {
|
||||
throw new RuntimeException(
|
||||
"ApplicationStub.getContentTripleSource() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationTripleSource getConfigurationTripleSource() {
|
||||
throw new RuntimeException(
|
||||
"ApplicationStub.getConfigurationTripleSource() not implemented.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue