Remove trailing whitespace throughout project
This commit is contained in:
parent
74b8f16aa2
commit
bd6140a8cc
1753 changed files with 24077 additions and 24077 deletions
|
@ -67,7 +67,7 @@ import org.apache.jena.rdf.model.ModelFactory;
|
|||
* <li>Create URLs from Strings without throwing checked exceptions.</li>
|
||||
* <li>Compare the contents of XML documents.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @author jeb228
|
||||
*/
|
||||
public abstract class AbstractTestClass {
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
/**
|
||||
* The create() method creates a dynamic Proxy that wraps your inner object, and
|
||||
* implements your interfaze.
|
||||
*
|
||||
*
|
||||
* It also implements the MethodCallRecorder interface (although you will need
|
||||
* to cast it), so you can find out what methods were called on the proxy.
|
||||
*/
|
||||
|
@ -113,4 +113,4 @@ public class RecordingProxy {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,15 +44,15 @@ public class IsRootUserFactoryTest extends AbstractTestClass {
|
|||
public void setup() {
|
||||
UserAccount plainUser = new UserAccount();
|
||||
plainUser.setUri(PLAIN_USER_URI);
|
||||
|
||||
|
||||
UserAccount rootUser = new UserAccount();
|
||||
rootUser.setUri(ROOT_USER_URI);
|
||||
rootUser.setRootUser(true);
|
||||
|
||||
|
||||
uaDao = new UserAccountsDaoStub();
|
||||
uaDao.addUser(plainUser);
|
||||
uaDao.addUser(rootUser);
|
||||
|
||||
|
||||
wdf = new WebappDaoFactoryStub();
|
||||
wdf.setUserAccountsDao(uaDao);
|
||||
|
||||
|
|
|
@ -42,15 +42,15 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
|
|||
/**
|
||||
* Test the function of PolicyHelper in authorizing models of additions and
|
||||
* retractions.
|
||||
*
|
||||
*
|
||||
* It is vital that these methods work even if the statements are presented in
|
||||
* the "wrong" order: one statement being authorized by a statement that appears
|
||||
* later in the list.
|
||||
*
|
||||
*
|
||||
* In order to test that, we need to create a Model that will list the
|
||||
* statements in an order that we can predict, vis. the order in which they were
|
||||
* added.
|
||||
*
|
||||
*
|
||||
* To avoid creating a SortedModel that implements dozens of methods, we instead
|
||||
* create a Proxy class that keeps the statements in order and lists them on
|
||||
* demand.
|
||||
|
@ -258,7 +258,7 @@ public class PolicyHelper_ModelsTest extends AbstractTestClass {
|
|||
/**
|
||||
* A model Proxy object built around this will list statements in the order
|
||||
* they were added.
|
||||
*
|
||||
*
|
||||
* This only works if the statements were added by a call to
|
||||
* add(Statement[]), and if they are listed by a call to listStatements().
|
||||
* If the test used other methods to add statements, or if the PolicyHelper
|
||||
|
|
|
@ -79,7 +79,7 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
|
|||
ind.setURI(SELFEDITOR_URI);
|
||||
|
||||
ids = new ArrayIdentifierBundle(new HasProfile(SELFEDITOR_URI));
|
||||
|
||||
|
||||
ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class SelfEditingPolicy_2_Test extends AbstractTestClass {
|
|||
*/
|
||||
private OntModel ontModel;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ServletContextStub ctx = new ServletContextStub();
|
||||
|
|
|
@ -34,14 +34,14 @@ import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao.FullPropertyKey;
|
|||
/**
|
||||
* If we believe that authorization will succeed regardless of user role, check
|
||||
* that it succeeds with the lowest role.
|
||||
*
|
||||
*
|
||||
* If we believe that authorization will fail regardless of user role, check
|
||||
* that it fails with the highest role.
|
||||
*
|
||||
*
|
||||
* If we believe that authorization depends on the user role, it should pass if
|
||||
* the user role is higher than or equal to the threshold, and fail if the user
|
||||
* role is less than the threshold.
|
||||
*
|
||||
*
|
||||
* Note that we can't set a threshold to be tested to either the lowest or
|
||||
* highest role, or the attempt to test with higher or lower role will throw an
|
||||
* exception.
|
||||
|
|
|
@ -59,7 +59,7 @@ public class RevisionInfoSetupTest extends AbstractTestClass {
|
|||
public void suppressMessagesFromStartupStatus() {
|
||||
setLoggerLevel(StartupStatus.class, Level.OFF);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void noResourceFile() {
|
||||
setLoggerLevel(RevisionInfoSetup.class, Level.OFF);
|
||||
|
|
|
@ -249,7 +249,7 @@ public class UserAccountsSelectorTest extends AbstractTestClass {
|
|||
// user06 has no login count: reads as 0.
|
||||
assertSelectedUris(10, "user07", "user03", "user06");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void sortByLastLoginTimeDescending() {
|
||||
UserAccountsOrdering orderBy = new UserAccountsOrdering(
|
||||
|
@ -257,7 +257,7 @@ public class UserAccountsSelectorTest extends AbstractTestClass {
|
|||
selectOnCriteria(3, 1, orderBy, "", "");
|
||||
assertSelectedUris(10, "user08", "user10", "user09");
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// filtering tests
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -274,7 +274,7 @@ public class UserAccountsSelectorTest extends AbstractTestClass {
|
|||
selectOnCriteria(20, 1, DEFAULT_ORDERING, NS_MINE + "role2", "");
|
||||
assertSelectedUris(2, "user03", "user10");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void filterAgainstNoSuchRole() {
|
||||
selectOnCriteria(20, 1, DEFAULT_ORDERING, "BogusRole", "");
|
||||
|
|
|
@ -220,13 +220,13 @@ public class ProxyRelationshipSelectorTest extends AbstractTestClass {
|
|||
|
||||
/**
|
||||
* test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* search tests: (repeat both views)
|
||||
* some results
|
||||
* no results
|
||||
* special REGEX characters
|
||||
*
|
||||
*
|
||||
* profile w/no proxies
|
||||
* profile w/proxies
|
||||
* no associated profile
|
||||
|
@ -234,7 +234,7 @@ public class ProxyRelationshipSelectorTest extends AbstractTestClass {
|
|||
* profile w/no imageUrl
|
||||
* profile w/neither
|
||||
* profile w/both
|
||||
*
|
||||
*
|
||||
* proxy w/no profiles
|
||||
* proxy w profiles:
|
||||
* no classLabel
|
||||
|
|
|
@ -30,24 +30,24 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceMod
|
|||
*/
|
||||
public class SparqlUpdateApiTest extends AbstractTestClass {
|
||||
|
||||
private final String GRAPH_URI = "http://example.org/graph";
|
||||
|
||||
private final String updateStr1 =
|
||||
private final String GRAPH_URI = "http://example.org/graph";
|
||||
|
||||
private final String updateStr1 =
|
||||
"INSERT DATA { GRAPH <" + GRAPH_URI + "> { \n" +
|
||||
" <http://here.edu/n1> a <http://here.edu/Class1> . \n" +
|
||||
" <http://here.edu/n1> a <http://here.edu/Class1> . \n" +
|
||||
"} } ; \n" +
|
||||
"INSERT { GRAPH <" + GRAPH_URI + "> { \n " +
|
||||
" ?x a <http://here.edu/Class2> . \n " +
|
||||
" ?x a <http://here.edu/Class2> . \n " +
|
||||
"} } WHERE { \n" +
|
||||
" GRAPH <" + GRAPH_URI + "> { ?x a <http://here.edu/Class1> } \n " +
|
||||
" GRAPH <" + GRAPH_URI + "> { ?x a <http://here.edu/Class1> } \n " +
|
||||
"}";
|
||||
|
||||
private final String result1 =
|
||||
private final String result1 =
|
||||
"<http://here.edu/n1> a <http://here.edu/Class1> . \n" +
|
||||
"<http://here.edu/n1> a <http://here.edu/Class2> ." ;
|
||||
|
||||
|
||||
// look at how the SimpleReasoner is set up.
|
||||
|
||||
|
||||
private Model model;
|
||||
private RDFService rdfService;
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ public class AuthenticateTest extends AbstractTestClass {
|
|||
adminPermissionSet.setUri(URI_DBA);
|
||||
adminPermissionSet.setPermissionUris(Collections
|
||||
.singleton(SimplePermission.SEE_SITE_ADMIN_PAGE.getUri()));
|
||||
|
||||
|
||||
userAccountsDao = new UserAccountsDaoStub();
|
||||
userAccountsDao.addPermissionSet(adminPermissionSet);
|
||||
for (UserAccount account : userAccounts) {
|
||||
|
|
|
@ -16,44 +16,44 @@ import org.apache.jena.rdf.model.ModelFactory;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
public class PrimitiveRdfEditTest {
|
||||
|
||||
|
||||
OntModel testModel;
|
||||
WebappDaoFactory wdf;
|
||||
|
||||
private String testN3a =
|
||||
private String testN3a =
|
||||
"<http://example.com/motorcycles/honda/vtl1000> <http://example.com/engines/displacement> \"1000cm3\" ." +
|
||||
"<http://example.com/motorcycles/honda/919> <http://example.com/engines/displacement> \"919cm3\" ." ;
|
||||
|
||||
private String testN3b =
|
||||
|
||||
private String testN3b =
|
||||
"<http://example.com/motorcycles/honda/919> <http://example.com/motorcycles/relatedTo> <http://exmaple.com/motorcycle/honda/599> ." ;
|
||||
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception { }
|
||||
|
||||
@Test
|
||||
public void testProcessChanges() throws Exception {
|
||||
OntModel writeModel = ModelFactory.createOntologyModel();
|
||||
|
||||
|
||||
int totalStmts = 3;
|
||||
|
||||
|
||||
PrimitiveRdfEdit pre = new PrimitiveRdfEdit();
|
||||
String params[] = { testN3a, testN3b };
|
||||
Set<Model> models = pre.parseRdfParam(params, "N3");
|
||||
Assert.assertNotNull(models);
|
||||
Assert.assertTrue( models.size() == 2);
|
||||
|
||||
|
||||
Assert.assertNotNull( writeModel );
|
||||
long size = writeModel.size();
|
||||
pre.processChanges("uri:fakeEditorUri", writeModel,
|
||||
pre.mergeModels(models), ModelFactory.createDefaultModel());
|
||||
Assert.assertEquals(size+totalStmts, writeModel.size());
|
||||
|
||||
|
||||
String params3[] = { testN3b };
|
||||
Set<Model> retracts = pre.parseRdfParam( params3, "N3");
|
||||
pre.processChanges("uri:fakeEditorUri", writeModel,
|
||||
Set<Model> retracts = pre.parseRdfParam( params3, "N3");
|
||||
pre.processChanges("uri:fakeEditorUri", writeModel,
|
||||
ModelFactory.createDefaultModel(), pre.mergeModels(retracts));
|
||||
Assert.assertEquals(size+totalStmts-1, writeModel.size());
|
||||
Assert.assertEquals(size+totalStmts-1, writeModel.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -21,33 +21,33 @@ import java.util.Collections;
|
|||
/**
|
||||
* Not a well-formed set of unit tests. But it's a pretty good exercise of the
|
||||
* different possibilities in the output stage.
|
||||
*
|
||||
*
|
||||
* Test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* No data - roots is null -- NONSENSICAL
|
||||
* No data - roots is empty
|
||||
*
|
||||
*
|
||||
* name
|
||||
* no name
|
||||
*
|
||||
*
|
||||
* displayRank
|
||||
* no displayRank
|
||||
*
|
||||
*
|
||||
* no child classes
|
||||
* child classes
|
||||
*
|
||||
*
|
||||
* child class has name
|
||||
* child class has no name
|
||||
*
|
||||
*
|
||||
* child class has shortDef
|
||||
* child class has no shortDef
|
||||
*
|
||||
*
|
||||
* G1 no name, displayRank, no classes
|
||||
* G2 name, no displayRank, classes
|
||||
* G2C1 no name, no shortDef
|
||||
* G2C2 name, shortdef
|
||||
*
|
||||
* G2C2 name, shortdef
|
||||
*
|
||||
* Try once with no data
|
||||
* Try with all data
|
||||
* </pre>
|
||||
|
|
|
@ -23,7 +23,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
|
|||
/**
|
||||
* Some useful methods for assembling JSON structures that will match the test
|
||||
* results.
|
||||
*
|
||||
*
|
||||
* Also, some methods for running the tests, with and without kluging the
|
||||
* results.
|
||||
*/
|
||||
|
@ -136,7 +136,7 @@ public class ListControllerTestBase extends AbstractTestClass {
|
|||
* That jsonTree would be an standard JSON array, except that it is missing
|
||||
* the enclosing brackets, so we need to add them before comparing to the
|
||||
* expected value.
|
||||
*
|
||||
*
|
||||
* Add the brackets, read the strings, and compare.
|
||||
*/
|
||||
protected static void assertMatchingJson(FreemarkerHttpServlet controller,
|
||||
|
|
|
@ -29,46 +29,46 @@ import stubs.javax.servlet.http.HttpServletRequestStub;
|
|||
/**
|
||||
* Not a well-formed set of unit tests. But it's a pretty good exercise of the
|
||||
* different possibilities in the output stage.
|
||||
*
|
||||
*
|
||||
* Test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* No data - roots is null -- NONSENSICAL
|
||||
* No data - roots is empty
|
||||
*
|
||||
*
|
||||
* Ontology is not specified
|
||||
* Ontology is specified and matches
|
||||
* Ontology is specified and does not match
|
||||
* DataProperty does not match Ontology, but has child properties that do.
|
||||
*
|
||||
*
|
||||
* Name from picklistName
|
||||
* Name from getName
|
||||
* Name from getUri
|
||||
* Name no URL? -- NONSENSICAL
|
||||
*
|
||||
*
|
||||
* InternalName from picklistName
|
||||
* InternalName missing.
|
||||
*
|
||||
*
|
||||
* Domain class no class URI
|
||||
* Domain class no class for URI
|
||||
* Domain class get picklistName from Language Aware DAO
|
||||
* Domain class use picklistName from Language Neutral DAO
|
||||
*
|
||||
*
|
||||
* Range no range URI
|
||||
* Range no datatype for URI
|
||||
* Range datatype has no name
|
||||
* Range has a name
|
||||
*
|
||||
*
|
||||
* Group no group URI
|
||||
* Group no group for URI
|
||||
* Group no name
|
||||
* Group has a name
|
||||
*
|
||||
*
|
||||
* DP1 Ont1, no name, no picklistName, no domainClass, no RangeClass, no GroupURI
|
||||
* DP2 Ont2, name, no picklistName, no domain class for URI, no range datatype for URI, no group for GroupURI
|
||||
* DP3 Ont1, picklistname, domainclass no picklistname, range datatype with no name, group has no name
|
||||
* DP4 Ont1, picklistname, domainclass w/picklistname, range datatype with name, group with name
|
||||
*
|
||||
*
|
||||
* Try once with no data
|
||||
* Try with all data and no ontology specified
|
||||
* Try with all data and Ont1, Ont2, Ont3
|
||||
|
|
|
@ -24,35 +24,35 @@ import stubs.javax.servlet.http.HttpServletRequestStub;
|
|||
/**
|
||||
* Not a well-formed set of unit tests. But it's a pretty good exercise of the
|
||||
* different possibilities in the output stage.
|
||||
*
|
||||
*
|
||||
* Test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* No data - roots is null -- NONSENSICAL
|
||||
* No data - roots is empty
|
||||
*
|
||||
*
|
||||
* name
|
||||
* no name - (unnamed group)
|
||||
*
|
||||
*
|
||||
* display rank
|
||||
* no display rank
|
||||
*
|
||||
*
|
||||
* no child properties
|
||||
* child property is data property
|
||||
* child properti is object property
|
||||
*
|
||||
*
|
||||
* child data property has no name
|
||||
* child data property has name
|
||||
* child object property has no domainPublic
|
||||
* child object property has domainPublic
|
||||
*
|
||||
*
|
||||
* G1 no name, displayRank, no classes
|
||||
* G2 name, no displayRank, classes
|
||||
* G2DP1 no name, no shortDef
|
||||
* G2DP2 name, shortdef
|
||||
* G2DP2 name, shortdef
|
||||
* G2OP1 no domainPublic, no shortDef
|
||||
* G2OP2 domainPublic, shortdef
|
||||
*
|
||||
* G2OP2 domainPublic, shortdef
|
||||
*
|
||||
* Try once with no data
|
||||
* Try with all data
|
||||
* </pre>
|
||||
|
|
|
@ -30,44 +30,44 @@ import stubs.javax.servlet.http.HttpServletRequestStub;
|
|||
/**
|
||||
* Not a well-formed set of unit tests. But it's a pretty good exercise of the
|
||||
* different possibilities in the output stage.
|
||||
*
|
||||
*
|
||||
* Test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* No data - roots is null -- NONSENSICAL
|
||||
* No data - roots is empty
|
||||
*
|
||||
*
|
||||
* Ontology is not specified
|
||||
* Ontology is specified and matches
|
||||
* Ontology is specified and does not match
|
||||
* DataProperty does not match Ontology, but has child properties that do.
|
||||
*
|
||||
*
|
||||
* Name from picklistName
|
||||
* Name from getUri
|
||||
* Name no URL? -- NONSENSICAL
|
||||
*
|
||||
*
|
||||
* InternalName from localNameWithPrefix
|
||||
* InternalName from localName
|
||||
* InternalName from URI
|
||||
*
|
||||
*
|
||||
* Domain class no class URI
|
||||
* Domain class no class for URI
|
||||
* Domain class use picklistName
|
||||
*
|
||||
*
|
||||
* Range class no class URI
|
||||
* Range class no class for URI
|
||||
* Range class use picklistName
|
||||
*
|
||||
*
|
||||
* Group no group URI
|
||||
* Group no group for URI
|
||||
* Group no name
|
||||
* Group has a name
|
||||
*
|
||||
*
|
||||
* OP1 Ont1, no picklistName, no localNameWithPrefix, no domainClass, no rangeClass, no GroupURI
|
||||
* OP2 Ont2, picklistName, no localNameWithPrefix, no domain class for URI, no range class for URI, no group for GroupURI
|
||||
* OP3 Ont1, picklistName, localNameWithPrefix, domainclass no picklistname, range class no picklistname, group has no name
|
||||
* OP4 Ont1, picklistName, localNameWithPrefix, domainclass w/picklistname, range class w/picklistname, group with name
|
||||
*
|
||||
*
|
||||
* Try once with no data
|
||||
* Try with all data and no ontology specified
|
||||
* Try with all data and Ont1, Ont2, Ont3
|
||||
|
|
|
@ -25,38 +25,38 @@ import stubs.javax.servlet.http.HttpServletRequestStub;
|
|||
/**
|
||||
* Not a well-formed set of unit tests. But it's a pretty good exercise of the
|
||||
* different possibilities in the output stage.
|
||||
*
|
||||
*
|
||||
* Test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* Ontology is not specified
|
||||
* Ontology is specified and matches
|
||||
* Ontology is specified and does not match
|
||||
*
|
||||
*
|
||||
* classes = empty
|
||||
* classes = null -- UNREALISTIC
|
||||
*
|
||||
*
|
||||
* no pickListName
|
||||
* pickListName
|
||||
*
|
||||
*
|
||||
* shortDef
|
||||
* no shortDef
|
||||
*
|
||||
*
|
||||
* no group uri
|
||||
* no group for uri
|
||||
* no name for group
|
||||
* group with name
|
||||
*
|
||||
*
|
||||
* ontology not found
|
||||
* ontology no name
|
||||
* ontology with name
|
||||
*
|
||||
*
|
||||
* VC1 - Ont1, no pickListName, no shortDef, no GroupURI, no matching Ontology
|
||||
* VC2 - Ont2, pickListName, shortDef, no group for GroupURI, ontology has no name
|
||||
* VC3 - Ont2, pickListName, shortDef, group has no name, ontology with name
|
||||
* VC4 - Ont1, pickListName, shortDef, group with name, no matching Ontology
|
||||
*
|
||||
*
|
||||
* Try once with no data
|
||||
* Try with all data and no ontology specified
|
||||
* Try with all data and Ont1, Ont2, Ont3
|
||||
|
|
|
@ -27,38 +27,38 @@ import stubs.javax.servlet.http.HttpServletRequestStub;
|
|||
/**
|
||||
* Not a well-formed set of unit tests. But it's a pretty good exercise of the
|
||||
* different possibilities in the output stage.
|
||||
*
|
||||
*
|
||||
* Test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* No data - roots is null -- NONSENSICAL
|
||||
* No data - roots is empty
|
||||
*
|
||||
*
|
||||
* Ontology is not specified
|
||||
* Ontology is specified and matches
|
||||
* Ontology is specified and does not match
|
||||
* VClass does not match Ontology, but has child properties that do.
|
||||
*
|
||||
*
|
||||
* pickListName
|
||||
* no pickListName
|
||||
*
|
||||
*
|
||||
* shortDef
|
||||
* no shortDef
|
||||
*
|
||||
*
|
||||
* Group no group URI
|
||||
* Group no group for URI
|
||||
* Group no name
|
||||
* Group has a name
|
||||
*
|
||||
*
|
||||
* No ontology for namespace
|
||||
* Ontology but no name
|
||||
* Ontology with name
|
||||
*
|
||||
*
|
||||
* DP_1A Ont1, no pickListName, no shortDef, no GroupURI, no matching Ontology
|
||||
* DP_1B Ont2, pickListName, shortDef, no group for GroupURI, ontology has no name
|
||||
* DP_1B2A Ont3, pickListName, shortDef, group has no name, ontology with name
|
||||
* DP_1B2B Ont1, pickListName, shortDef, group with name, no matching Ontology
|
||||
*
|
||||
*
|
||||
* Try once with no data
|
||||
* Try with all data and no ontology specified
|
||||
* Try with all data and Ont1, Ont2, Ont3
|
||||
|
|
|
@ -29,49 +29,49 @@ import stubs.javax.servlet.http.HttpServletRequestStub;
|
|||
/**
|
||||
* Not a well-formed set of unit tests. But it's a pretty good exercise of the
|
||||
* different possibilities in the output stage.
|
||||
*
|
||||
*
|
||||
* Test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* No data - roots is null -- NONSENSICAL
|
||||
* No data - roots is empty
|
||||
*
|
||||
*
|
||||
* Ontology is not specified
|
||||
* Ontology is specified and matches
|
||||
* Ontology is specified and does not match
|
||||
* DataProperty does not match Ontology, but has child properties that do.
|
||||
*
|
||||
*
|
||||
* Name from picklistName
|
||||
* Name from getName
|
||||
* Name from getUri
|
||||
* Name no URL? -- NONSENSICAL
|
||||
*
|
||||
*
|
||||
* InternalName from picklistName
|
||||
* InternalName missing.
|
||||
*
|
||||
*
|
||||
* Domain class no class URI
|
||||
* Domain class no class for URI
|
||||
* Domain class get picklistName from Language Aware DAO
|
||||
* Domain class use picklistName from Language Neutral DAO
|
||||
*
|
||||
*
|
||||
* Range no range URI
|
||||
* Range no datatype for URI
|
||||
* Range datatype has no name
|
||||
* Range has a name
|
||||
*
|
||||
*
|
||||
* Group no group URI
|
||||
* Group no group for URI
|
||||
* Group no name
|
||||
* Group has a name
|
||||
*
|
||||
*
|
||||
* Children no children
|
||||
* Children sorted by picklist
|
||||
*
|
||||
*
|
||||
* DP_1A Ont1, no name, no picklistName, no domainClass, no RangeClass, no GroupURI
|
||||
* DP_1B Ont2, name, no picklistName, no domain class for URI, no range datatype for URI, no group for GroupURI
|
||||
* DP_1B2A Ont1, picklistname, domainclass no picklistname, range datatype with no name, group has no name
|
||||
* DP_1B2B Ont1, picklistname(less than 1B2A), domainclass w/picklistname, range datatype with name, group with name
|
||||
*
|
||||
*
|
||||
* Try once with no data
|
||||
* Try with all data and no ontology specified
|
||||
* Try with all data and Ont1, Ont2, Ont3
|
||||
|
|
|
@ -29,48 +29,48 @@ import stubs.javax.servlet.http.HttpServletRequestStub;
|
|||
/**
|
||||
* Not a well-formed set of unit tests. But it's a pretty good exercise of the
|
||||
* different possibilities in the output stage.
|
||||
*
|
||||
*
|
||||
* Test plan:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* No data - roots is null -- NONSENSICAL
|
||||
* No data - roots is empty
|
||||
*
|
||||
*
|
||||
* Ontology is not specified
|
||||
* Ontology is specified and matches
|
||||
* Ontology is specified and does not match
|
||||
* ObjectProperty does not match Ontology, but has child properties that do.
|
||||
*
|
||||
*
|
||||
* Name from picklistName
|
||||
* Name from getLocalName
|
||||
* Name no URL? -- NONSENSICAL
|
||||
*
|
||||
*
|
||||
* InternalName from localNameWithPrefix
|
||||
* InternalName from localName
|
||||
*
|
||||
*
|
||||
* Domain class no class URI
|
||||
* Domain class no class for URI
|
||||
* Domain class get picklistName from Language Aware DAO
|
||||
* Domain class use picklistName from Language Neutral DAO
|
||||
*
|
||||
*
|
||||
* Range class no class URI
|
||||
* Range class no class for URI
|
||||
* Range class get picklistName from Language Aware DAO
|
||||
* Range class use picklistName from Language Neutral DAO
|
||||
*
|
||||
*
|
||||
* Group no group URI
|
||||
* Group no group for URI
|
||||
* Group no name
|
||||
* Group has a name
|
||||
*
|
||||
*
|
||||
* Children no children
|
||||
* Children sorted by picklist
|
||||
*
|
||||
*
|
||||
* DP_1A Ont1, no name, no localnamewithprefix, no picklistName, no domainClass, no RangeClass, no GroupURI
|
||||
* DP_1B Ont2, name, no localnamewithprefix, no picklistName, no domain class for URI, no range clqss for URI, no group for GroupURI
|
||||
* DP_1B2A Ont1, name, localnamewithprefix, picklistname, domainclass no picklistname, range class with no picklistname, group has no name
|
||||
* DP_1B2B Ont1, name, localnamewithprefix, picklistname(less than 1B2A), domain class w/picklistname, range class w/picklistname, group with name
|
||||
*
|
||||
*
|
||||
* Try once with no data
|
||||
* Try with all data and no ontology specified
|
||||
* Try with all data and Ont1, Ont2, Ont3
|
||||
|
|
|
@ -20,26 +20,26 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||
|
||||
public class UrlBuilderTest extends AbstractTestClass {
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetUrl() {
|
||||
UrlBuilder.contextPath = "/vivo";
|
||||
|
||||
|
||||
String path1 = "/individual";
|
||||
Assert.assertEquals("/vivo/individual", UrlBuilder.getUrl(path1));
|
||||
|
||||
|
||||
int portalId = 1;
|
||||
String path2 = "/individual?home=" + portalId;
|
||||
Assert.assertEquals("/vivo/individual?home=1", UrlBuilder.getUrl(path2));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetUrlWithEmptyContext() {
|
||||
UrlBuilder.contextPath = "";
|
||||
String path = "/individual";
|
||||
Assert.assertEquals(path, UrlBuilder.getUrl(path));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetUrlWithParams() {
|
||||
UrlBuilder.contextPath = "/vivo";
|
||||
|
@ -58,16 +58,16 @@ public class UrlBuilderTest extends AbstractTestClass {
|
|||
ParamMap params = new ParamMap();
|
||||
String vClassUri = "http://vivoweb.org/ontology/core#FacultyMember";
|
||||
params.put("vclassId", vClassUri);
|
||||
Assert.assertEquals("/vivo/individuallist?vclassId=http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23FacultyMember", UrlBuilder.getUrl(path, params));
|
||||
Assert.assertEquals("/vivo/individuallist?vclassId=http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23FacultyMember", UrlBuilder.getUrl(path, params));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDecodeUrl() {
|
||||
String vClassUri = "http://vivoweb.org/ontology/core#FacultyMember";
|
||||
String vClassUriEncoded = "http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23FacultyMember";
|
||||
Assert.assertEquals(vClassUri, UrlBuilder.urlDecode(vClassUriEncoded));
|
||||
Assert.assertEquals(vClassUri, UrlBuilder.urlDecode(vClassUriEncoded));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testUtf8Encode(){
|
||||
|
@ -83,43 +83,43 @@ public class UrlBuilderTest extends AbstractTestClass {
|
|||
public void testDecodeUtf8Url() {
|
||||
String vClassUri = "http://vivoweb.org/ontology/core#FacultyMember\u2605"; // \u2605 is Unicode for a five-pointed star.
|
||||
String vClassUriEncoded = "http%3A%2F%2Fvivoweb.org%2Fontology%2Fcore%23FacultyMember%E2%98%85";
|
||||
Assert.assertEquals(vClassUri, UrlBuilder.urlDecode(vClassUriEncoded));
|
||||
Assert.assertEquals(vClassUri, UrlBuilder.urlDecode(vClassUriEncoded));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testGetIndividualProfileURI(){
|
||||
VitroRequest vreq = makeMockVitroRequest( "http://example.com/individual/");
|
||||
UrlBuilder.contextPath = "http://example.com";
|
||||
|
||||
|
||||
String uri = "http://example.com/individual/n2343";
|
||||
String url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
|
||||
Assert.assertEquals("http://example.com/display/n2343", url);
|
||||
|
||||
uri = "http://example.com/individual/bob";
|
||||
|
||||
uri = "http://example.com/individual/bob";
|
||||
url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
|
||||
Assert.assertEquals("http://example.com/display/bob",url);
|
||||
|
||||
uri = "http://nondefaultNS.com/individual/n2343";
|
||||
|
||||
uri = "http://nondefaultNS.com/individual/n2343";
|
||||
url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
|
||||
Assert.assertEquals("http://example.com/individual?uri=" + URLEncoder.encode(uri), url);
|
||||
|
||||
uri = "http://example.com/individual#n2343";
|
||||
|
||||
uri = "http://example.com/individual#n2343";
|
||||
url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
|
||||
Assert.assertEquals("http://example.com/individual?uri=" + URLEncoder.encode(uri), url);
|
||||
|
||||
uri = "http://example.com/individual/5LNCannotStartWithNumber";
|
||||
|
||||
uri = "http://example.com/individual/5LNCannotStartWithNumber";
|
||||
url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
|
||||
Assert.assertEquals("http://example.com/individual?uri=" + URLEncoder.encode(uri), url);
|
||||
Assert.assertEquals("http://example.com/individual?uri=" + URLEncoder.encode(uri), url);
|
||||
}
|
||||
|
||||
protected VitroRequest makeMockVitroRequest( final String defaultNS){
|
||||
HttpServletRequest req = createMock( HttpServletRequest.class );
|
||||
|
||||
protected VitroRequest makeMockVitroRequest( final String defaultNS){
|
||||
HttpServletRequest req = createMock( HttpServletRequest.class );
|
||||
return new VitroRequest(req){
|
||||
|
||||
|
||||
@Override
|
||||
public String getParameter(String key){ return null; }
|
||||
|
||||
|
||||
@Override
|
||||
public WebappDaoFactory getWebappDaoFactory(){
|
||||
return makeMockWDF(defaultNS);
|
||||
|
@ -131,34 +131,34 @@ public class UrlBuilderTest extends AbstractTestClass {
|
|||
wdf.setDefaultNamespace("http://example.com/individual/");
|
||||
ApplicationDaoStub aDao = new ApplicationDaoStub(){
|
||||
@Override
|
||||
public boolean isExternallyLinkedNamespace(String ns){
|
||||
public boolean isExternallyLinkedNamespace(String ns){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
};
|
||||
wdf.setApplicationDao( aDao );
|
||||
return wdf;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIsUriInDefaultNamespace(){
|
||||
public void testIsUriInDefaultNamespace(){
|
||||
String[][] examples = {
|
||||
{ "http://example.com/individual/n3234", "http://example.com/individual/"},
|
||||
{ "http://example.com/individual#n3234", "http://example.com/individual#"},
|
||||
{ "http://example.com:8080/individual/n3234", "http://example.com:8080/individual/"},
|
||||
{ "http://example.com:8080/individual#n3234", "http://example.com:8080/individual#"}
|
||||
{ "http://example.com:8080/individual#n3234", "http://example.com:8080/individual#"}
|
||||
};
|
||||
|
||||
for( String[] example : examples ){
|
||||
Assert.assertTrue("expected '"+ example[0] + "' to be in the default NS of '"+example[1]+"'",
|
||||
UrlBuilder.isUriInDefaultNamespace(example[0], example[1]));
|
||||
}
|
||||
|
||||
String[][] counterExamples = {
|
||||
UrlBuilder.isUriInDefaultNamespace(example[0], example[1]));
|
||||
}
|
||||
|
||||
String[][] counterExamples = {
|
||||
{ "http://example.com/individual/5LNCannotStartWithNumber", "http://example.com/individual/" }
|
||||
};
|
||||
for( String[] example : counterExamples ){
|
||||
Assert.assertFalse("expected '"+ example[0] + "' to NOT be in the default NS of '"+example[1]+"'",
|
||||
UrlBuilder.isUriInDefaultNamespace(example[0], example[1]));
|
||||
UrlBuilder.isUriInDefaultNamespace(example[0], example[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,14 @@ public class JSONReconcileServletTest extends AbstractTestClass {
|
|||
@Before
|
||||
public void setup() throws Exception {
|
||||
ApplicationStub.setup(new ServletContextStub(), new SearchEngineStub());
|
||||
|
||||
|
||||
request = new HttpServletRequestStub();
|
||||
request.setRequestUrl(new URL("http://vivo.this.that/reconcile"));
|
||||
request.setMethod("POST");
|
||||
response = new HttpServletResponseStub();
|
||||
reconcile = new JSONReconcileServlet();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getMetadata() {
|
||||
int serverPort = 8080;
|
||||
|
@ -62,7 +62,7 @@ public class JSONReconcileServletTest extends AbstractTestClass {
|
|||
Assert.assertNotNull("output should not be null", jsonResult);
|
||||
Assert.assertEquals("schemaSpaceOutput", defaultNamespace, schemaSpaceOutput);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getQuery() {
|
||||
// contruct query
|
||||
|
@ -85,7 +85,7 @@ public class JSONReconcileServletTest extends AbstractTestClass {
|
|||
testAssertTrue(messagePrefix + orgType, orgType, searchQuery.toString());
|
||||
testAssertTrue(messagePrefix + nameType, orgType, searchQuery.toString());
|
||||
}
|
||||
|
||||
|
||||
private void testAssertTrue(String message, String inputStr, String resultStr) {
|
||||
try {
|
||||
Pattern regex = Pattern.compile(inputStr, Pattern.CASE_INSENSITIVE);
|
||||
|
|
|
@ -44,14 +44,14 @@ public class JsonServletTest extends AbstractTestClass {
|
|||
|
||||
/**
|
||||
* Test plan
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* GetEntitiesByVClass, GetEntitiesByVClassContinuation
|
||||
* from ents_edit.js
|
||||
* ents_edit_head.jsp
|
||||
* (there is an ents_edit.jsp, invoked from EntityEditController, which does not seem to invoke ents_edit.js)
|
||||
*
|
||||
*
|
||||
* GetSearchIndividualsByVClass
|
||||
* Mock out search engine and IndividualDao
|
||||
* invoked by BrowseDataGetter.java
|
||||
|
@ -59,7 +59,7 @@ public class JsonServletTest extends AbstractTestClass {
|
|||
* invoked by ClassGroupPageData.java
|
||||
* >>>> Bring up "People" tab.
|
||||
* invoked by BrowseWidget.java
|
||||
*
|
||||
*
|
||||
* GetSearchIndividualsByVClasses
|
||||
* Mock out search engine and IndividualDao
|
||||
* invoked by IndividualsForClassesDataGetter.java
|
||||
|
@ -70,7 +70,7 @@ public class JsonServletTest extends AbstractTestClass {
|
|||
* MenuManagementEdit.java
|
||||
* MenuManagementController.java
|
||||
* extended in vivo by InternalClassesDataGetter, also invoked by SelectDataGetterUtils
|
||||
*
|
||||
*
|
||||
* GetDataForPage
|
||||
* Mock out PageDao
|
||||
* </pre>
|
||||
|
@ -142,7 +142,7 @@ public class JsonServletTest extends AbstractTestClass {
|
|||
* concrete class instead of an interface, so we can't replace the instance
|
||||
* with one we like better. Furthermore, VClassGroupCache has a private
|
||||
* constructor, so we can't change its behavior at all.
|
||||
*
|
||||
*
|
||||
* Also test: success but no VClasses found, success with one VClass,
|
||||
* success with multiple VClasses. In each case, confirm proper status,
|
||||
* character encoding, and content type on the response.
|
||||
|
|
|
@ -33,71 +33,71 @@ public class NewURIMakerVitroTest extends AbstractTestClass{
|
|||
newResources.put("page", null);
|
||||
newResources.put("menuItem", null);
|
||||
newResources.put("dataGetter", null);
|
||||
|
||||
|
||||
//Setup webappdaofactory
|
||||
WebappDaoFactoryJena wadf = this.setupWebappDaoFactory();
|
||||
NewURIMakerVitro nv = new NewURIMakerVitro(wadf);
|
||||
|
||||
|
||||
//Now test for new URI
|
||||
HashMap<String,String> varToNewURIs = new HashMap<String,String>();
|
||||
HashMap<String,String> varToNewURIs = new HashMap<String,String>();
|
||||
try {
|
||||
for (String key : newResources.keySet()) {
|
||||
String prefix = newResources.get(key);
|
||||
String uri = nv.getUnusedNewURI(prefix);
|
||||
varToNewURIs.put(key, uri);
|
||||
}
|
||||
String uri = nv.getUnusedNewURI(prefix);
|
||||
varToNewURIs.put(key, uri);
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
System.out.println("Error occurred " + ex);
|
||||
}
|
||||
|
||||
|
||||
//Ensure that URIs are not included more than once
|
||||
List<String> values = new ArrayList<String>(varToNewURIs.values());
|
||||
Set<String> valuesSet = new HashSet<String>(varToNewURIs.values());
|
||||
assertTrue(valuesSet.size() == values.size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNonNullNamespace() {
|
||||
//Three items needs new URIs assigned in the default namespace
|
||||
//Var name to namespace, in this case null to denote default namespace
|
||||
Map<String,String> newResources = new HashMap<String, String>();
|
||||
newResources.put("page", "http://displayOntology/test/n12");
|
||||
|
||||
|
||||
|
||||
|
||||
//Setup webappdaofactory
|
||||
WebappDaoFactoryJena wadf = this.setupWebappDaoFactory();
|
||||
NewURIMakerVitro nv = new NewURIMakerVitro(wadf);
|
||||
|
||||
|
||||
//Now test for new URI
|
||||
HashMap<String,String> varToNewURIs = new HashMap<String,String>();
|
||||
HashMap<String,String> varToNewURIs = new HashMap<String,String>();
|
||||
try {
|
||||
for (String key : newResources.keySet()) {
|
||||
String prefix = newResources.get(key);
|
||||
String uri = nv.getUnusedNewURI(prefix);
|
||||
varToNewURIs.put(key, uri);
|
||||
}
|
||||
String uri = nv.getUnusedNewURI(prefix);
|
||||
varToNewURIs.put(key, uri);
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
System.out.println("Error occurred " + ex);
|
||||
}
|
||||
|
||||
|
||||
//Ensure that URIs are not included more than once
|
||||
List<String> values = new ArrayList<String>(varToNewURIs.values());
|
||||
Set<String> valuesSet = new HashSet<String>(varToNewURIs.values());
|
||||
assertTrue(valuesSet.size() == values.size());
|
||||
}
|
||||
|
||||
|
||||
private WebappDaoFactoryJena setupWebappDaoFactory() {
|
||||
String defaultNamespace= "http://vivo.mannlib.cornell.edu/individual/";
|
||||
String testNamespace = "http://displayOntology/test/";
|
||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
ontModel.add(
|
||||
ontModel.createResource(defaultNamespace + "n234"),
|
||||
RDF.type,
|
||||
RDF.type,
|
||||
OWL.Thing);
|
||||
ontModel.add(
|
||||
ontModel.createResource(testNamespace + "n234"),
|
||||
RDF.type,
|
||||
RDF.type,
|
||||
OWL.Thing);
|
||||
OntModelSelector selector = new SimpleOntModelSelector(ontModel);
|
||||
//Set up default namespace somewhere?
|
||||
|
|
|
@ -36,7 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
|||
* Test that the IndividualFiltering class filters by statements as much as
|
||||
* possible. That way the filter can consider the subject of the statement as
|
||||
* well as the predicate, when deciding whether to authorize the request.
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* Start with six properties and a filter that recognizes them.
|
||||
* DATA_HIDDEN -- never approved
|
||||
|
@ -44,13 +44,13 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
|||
* DATA_MAYBE -- only approved in statements with subject of SPECIAL URI.
|
||||
* OBJECT_HIDDEN -- never approved
|
||||
* OBJECT_VISIBLE -- always approved
|
||||
* OBJECT_MAYBE -- only approved in statements with subject or object of SPECIAL URI.
|
||||
*
|
||||
* Test all of the filtering methods on two filtered individuals.
|
||||
* OBJECT_MAYBE -- only approved in statements with subject or object of SPECIAL URI.
|
||||
*
|
||||
* Test all of the filtering methods on two filtered individuals.
|
||||
* One is SPECIAL_URI, and should see the MAYBE properties.
|
||||
* One is ordinary, and should not see the MAYBE properties.
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* This is a simplification of a "self-editing" filter, which shows some
|
||||
* properties, hides others, and allows some of the hidden ones in statements,
|
||||
* depending on the subject and/or object of the statement.
|
||||
|
|
|
@ -21,77 +21,77 @@ public class VitroFiltersFactoryTest {
|
|||
|
||||
// @Test
|
||||
// public void testSunsetWindowFilterOnListOfEnts() {
|
||||
// DateTime easyDate = new org.joda.time.DateTime(2005,1,1,0,0,0,0); //2005-01-01
|
||||
// DateTime easyDate = new org.joda.time.DateTime(2005,1,1,0,0,0,0); //2005-01-01
|
||||
// Date givenDate = easyDate.toDate();
|
||||
//
|
||||
//
|
||||
// VitroFilters vf = FiltersForTabs.getSunsetWindowFilter(givenDate);
|
||||
// Assert.assertNotNull(vf);
|
||||
// checkFilterForNull(vf);
|
||||
//
|
||||
//
|
||||
// List<Individual> ents = new LinkedList();
|
||||
// for( int i = 0; i< 10; i++){
|
||||
// Individual ent = new IndividualImpl();
|
||||
// ent.setSunrise( null );
|
||||
// ent.setSunset( null );
|
||||
// ents.add(ent);
|
||||
// ents.add(ent);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// BaseFiltering bf = new BaseFiltering();
|
||||
// List filtered = bf.filter(ents,vf.getIndividualFilter());
|
||||
// Assert.assertNotNull(filtered);
|
||||
// Assert.assertTrue("expcted to filter no entities, filtered out " + (10-filtered.size()),
|
||||
// Assert.assertTrue("expcted to filter no entities, filtered out " + (10-filtered.size()),
|
||||
// filtered.size() == 10);
|
||||
//
|
||||
//
|
||||
// Individual ent = new IndividualImpl();
|
||||
// ent.setSunrise( easyDate.minusDays(3).toDate() );
|
||||
// ent.setSunset( easyDate.plusDays(3).toDate() );
|
||||
// ents.add(ent);
|
||||
//
|
||||
//
|
||||
// filtered = bf.filter(ents,vf.getIndividualFilter());
|
||||
// Assert.assertNotNull(filtered);
|
||||
// Assert.assertTrue("expcted to filter no entities, filtered out " + (11-filtered.size()),
|
||||
// Assert.assertTrue("expcted to filter no entities, filtered out " + (11-filtered.size()),
|
||||
// filtered.size() == 11);
|
||||
//
|
||||
//
|
||||
// ent = new IndividualImpl();
|
||||
// ent.setSunrise( easyDate.minusDays(100).toDate() );
|
||||
// ent.setSunset( easyDate.minusDays(110).toDate() );
|
||||
// ents.add(ent);
|
||||
//
|
||||
//
|
||||
// filtered = bf.filter(ents,vf.getIndividualFilter());
|
||||
// Assert.assertNotNull(filtered);
|
||||
// Assert.assertTrue("expcted to filter one entity, filtered out " + (12-filtered.size()),
|
||||
// Assert.assertTrue("expcted to filter one entity, filtered out " + (12-filtered.size()),
|
||||
// filtered.size() == 11);
|
||||
//
|
||||
//
|
||||
// long count = Summarize.count(ents,vf.getIndividualFilter());
|
||||
// Assert.assertTrue("expected 12, got " + ents.size(), ents.size() == 12);
|
||||
// Assert.assertTrue("expected count of 11, got " + count , count == 11);
|
||||
//
|
||||
//
|
||||
// long a = 20000;
|
||||
// int b = (int)a;
|
||||
// Assert.assertTrue( b == 20000);
|
||||
// }
|
||||
|
||||
|
||||
// @Test
|
||||
// public void testGetSunsetWindowFilter() {
|
||||
// DateTime easyDate = new org.joda.time.DateTime(2005,1,1,0,0,0,0); //2005-01-01
|
||||
// DateTime easyDate = new org.joda.time.DateTime(2005,1,1,0,0,0,0); //2005-01-01
|
||||
// Date givenDate = easyDate.toDate();
|
||||
//
|
||||
//
|
||||
// VitroFilters vf = FiltersForTabs.getSunsetWindowFilter(givenDate);
|
||||
// Assert.assertNotNull(vf);
|
||||
// checkFilterForNull(vf);
|
||||
//
|
||||
//
|
||||
// Individual ent = new IndividualImpl();
|
||||
// ent.setSunrise( easyDate.minusDays(3).toDate() );
|
||||
// ent.setSunset( easyDate.plusDays(3).toDate() );
|
||||
// Assert.assertTrue(vf.getIndividualFilter().fn( ent ) );
|
||||
//
|
||||
//
|
||||
// ent.setSunrise( easyDate.toDate() );
|
||||
// Assert.assertTrue("items should be not filtered on first sunrise day", vf.getIndividualFilter().fn(ent));
|
||||
//
|
||||
//
|
||||
// ent.setSunrise( easyDate.minusDays(3).toDate() );
|
||||
// ent.setSunset( easyDate.minusDays( 2 ).toDate() );
|
||||
// Assert.assertFalse("should be sunset and filtered out", vf.getIndividualFilter().fn( ent ));
|
||||
//
|
||||
//
|
||||
// ent.setSunrise( easyDate.plusDays(3).toDate() );
|
||||
// ent.setSunset( easyDate.plusDays( 10 ).toDate() );
|
||||
// Assert.assertFalse("should not yet be sunrised and filtered out", vf.getIndividualFilter().fn( ent ));
|
||||
|
@ -99,20 +99,20 @@ public class VitroFiltersFactoryTest {
|
|||
// ent.setSunrise( null );
|
||||
// ent.setSunset( null );
|
||||
// Assert.assertTrue("nulls should not throw exceptions and and not be filtered out", vf.getIndividualFilter().fn( ent ));
|
||||
//
|
||||
//
|
||||
// //should work with webapp too
|
||||
// Individual entwa = new IndividualImpl();
|
||||
// entwa.setSunrise( easyDate.minusDays(3).toDate() );
|
||||
// entwa.setSunset( easyDate.plusDays(3).toDate() );
|
||||
// Assert.assertTrue(vf.getIndividualFilter().fn( entwa ) );
|
||||
//
|
||||
//
|
||||
// entwa.setSunrise( easyDate.toDate() );
|
||||
// Assert.assertTrue("items should be not filtered on first sunrise day", vf.getIndividualFilter().fn(entwa));
|
||||
//
|
||||
//
|
||||
// entwa.setSunrise( easyDate.minusDays(3).toDate() );
|
||||
// entwa.setSunset( easyDate.minusDays( 2 ).toDate() );
|
||||
// Assert.assertFalse("should be sunset and filtered out", vf.getIndividualFilter().fn( entwa ));
|
||||
//
|
||||
//
|
||||
// entwa.setSunrise( easyDate.plusDays(3).toDate() );
|
||||
// entwa.setSunset( easyDate.plusDays( 10 ).toDate() );
|
||||
// Assert.assertFalse("should not yet be sunrised and filtered out", vf.getIndividualFilter().fn( entwa ));
|
||||
|
@ -124,18 +124,18 @@ public class VitroFiltersFactoryTest {
|
|||
// //ObjectPropertyStatements
|
||||
// ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
|
||||
// ops.setObject(entwa);
|
||||
//
|
||||
//
|
||||
// entwa.setSunrise( easyDate.minusDays(3).toDate() );
|
||||
// entwa.setSunset( easyDate.plusDays(3).toDate() );
|
||||
// Assert.assertTrue(vf.getIndividualFilter().fn( entwa ) );
|
||||
//
|
||||
//
|
||||
// entwa.setSunrise( easyDate.toDate() );
|
||||
// Assert.assertTrue("items should be not filtered on first sunrise day", vf.getObjectPropertyStatementFilter().fn(ops));
|
||||
//
|
||||
//
|
||||
// entwa.setSunrise( easyDate.minusDays(3).toDate() );
|
||||
// entwa.setSunset( easyDate.minusDays( 2 ).toDate() );
|
||||
// Assert.assertFalse("should be sunset and filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
|
||||
//
|
||||
//
|
||||
// entwa.setSunrise( easyDate.plusDays(3).toDate() );
|
||||
// entwa.setSunset( easyDate.plusDays( 10 ).toDate() );
|
||||
// Assert.assertFalse("should not yet be sunrised and filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
|
||||
|
@ -143,10 +143,10 @@ public class VitroFiltersFactoryTest {
|
|||
// entwa.setSunrise( null );
|
||||
// entwa.setSunset( null );
|
||||
// Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getObjectPropertyStatementFilter().fn(ops));
|
||||
//
|
||||
//
|
||||
// ops.setSunrise( null );
|
||||
// ops.setSunset( null );
|
||||
// Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getObjectPropertyStatementFilter().fn( ops ) );
|
||||
// Assert.assertTrue("null should not throw exceptions and should not be filtered out", vf.getObjectPropertyStatementFilter().fn( ops ) );
|
||||
//
|
||||
// //DataPropertyStatements
|
||||
// DataPropertyStatement dps = new DataPropertyStatementImpl();
|
||||
|
@ -160,7 +160,7 @@ public class VitroFiltersFactoryTest {
|
|||
//
|
||||
// dps.setSunrise( null );
|
||||
// dps.setSunset( null );
|
||||
// Assert.assertTrue("should be not throw exceptions and should not be filtered out", vf.getDataPropertyStatementFilter().fn( dps ) );
|
||||
// Assert.assertTrue("should be not throw exceptions and should not be filtered out", vf.getDataPropertyStatementFilter().fn( dps ) );
|
||||
//
|
||||
// }
|
||||
|
||||
|
@ -169,20 +169,20 @@ public class VitroFiltersFactoryTest {
|
|||
VitroFilters vf = VitroFilterUtils.getTestFilter();
|
||||
checkFilterForNull(vf);
|
||||
ArrayList<Individual> ents = new ArrayList<Individual>();
|
||||
|
||||
|
||||
String[] names = {"Greg", "gary", "bob", "Sue", "jim" };
|
||||
for( String name : names){
|
||||
Individual ent = new IndividualImpl();
|
||||
ent.setName(name);
|
||||
ents.add(ent);
|
||||
ents.add(ent);
|
||||
}
|
||||
|
||||
|
||||
BaseFiltering bf = new BaseFiltering();
|
||||
List<Individual> filteredEnts = bf.filter(ents,vf.getIndividualFilter());
|
||||
Assert.assertNotNull(filteredEnts);
|
||||
Assert.assertEquals("did not filter correctly", 2, filteredEnts.size());
|
||||
}
|
||||
|
||||
Assert.assertEquals("did not filter correctly", 2, filteredEnts.size());
|
||||
}
|
||||
|
||||
public void checkFilterForNull(VitroFilters vf){
|
||||
Assert.assertNotNull("filter was null", vf);
|
||||
Assert.assertNotNull("getClassFilter was null", vf.getClassFilter());
|
||||
|
@ -193,14 +193,14 @@ public class VitroFiltersFactoryTest {
|
|||
Assert.assertNotNull("getIndividualFilter was null", vf.getIndividualFilter());
|
||||
Assert.assertNotNull("getVClassGroupFilter was null", vf.getVClassGroupFilter());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testRoleLevelFilter(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean ACCEPT= true;
|
||||
private boolean REJECT= false;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,48 +20,48 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class DataPropertyDaoJenaTest extends AbstractTestClass {
|
||||
|
||||
|
||||
@Test
|
||||
// Test that the DataPropertyDaoJena::updateDataProperty method will only update the jena model for
|
||||
// Test that the DataPropertyDaoJena::updateDataProperty method will only update the jena model for
|
||||
// those properties in DataProperty that have a different value from what is already in the
|
||||
// jena model for that property.
|
||||
//
|
||||
// jena model for that property.
|
||||
//
|
||||
// Specifically, updateDataProperty method should not remove a statement from the model and
|
||||
// then add the same statement back in. The reason for this is that in vitro the "immutable" properties
|
||||
// are stored in a sub-model and the user-editable properties are stored in a super-model and
|
||||
// all updates are performed against the super-model, so removing and then re-adding
|
||||
// the same statement may result in a change of state (if the statement was in the sub-model
|
||||
// all updates are performed against the super-model, so removing and then re-adding
|
||||
// the same statement may result in a change of state (if the statement was in the sub-model
|
||||
// it will migrate to the super-model) because of the way jena handles additions and
|
||||
// deletions with respect to super and sub models. This migration of statements may cause
|
||||
// undesirable behavior in the vitro application.
|
||||
|
||||
|
||||
public void minimalUpdates(){
|
||||
|
||||
|
||||
// 1. create two models and attach one as a sub-model of the other
|
||||
// 2. populate the sub-model with one statement for each of the 13 properties represented in DataProperty
|
||||
// 3. save the state of both the sub-model and the super-model
|
||||
// 4. populate a DataProperty object with the data in the (combined) model and call the updateDataProperty
|
||||
// (having made no changes to the DataProperty object)
|
||||
// 5. verify that both the sub-model and the super-model are unchanged
|
||||
|
||||
|
||||
String propertyURI = "http://vivoweb.org/ontology/core#addressCity";
|
||||
|
||||
OntModel superModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); // this simulates the user-editable ontology in vivo
|
||||
OntModel subModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); // this simulates the core ontology in vivo
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
String rdfsLabel = "this is the rdfs label";
|
||||
String lang = "en-US";
|
||||
|
||||
|
||||
// populate sub-model
|
||||
DatatypeProperty property1 = subModel.createDatatypeProperty(propertyURI);
|
||||
|
||||
property1.setLabel(rdfsLabel,lang);
|
||||
DatatypeProperty property1 = subModel.createDatatypeProperty(propertyURI);
|
||||
|
||||
property1.setLabel(rdfsLabel,lang);
|
||||
property1.setPropertyValue(RDFS.domain, subModel.createResource("http://thisIsTheDomainClassURI"));
|
||||
property1.setPropertyValue(RDFS.range, subModel.createResource("http://thisIsTheRangeClassURI"));
|
||||
property1.addProperty(RDF.type, OWL.FunctionalProperty);
|
||||
|
@ -74,37 +74,37 @@ public class DataPropertyDaoJenaTest extends AbstractTestClass {
|
|||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#selfEditor"));
|
||||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT), subModel.createResource("http://vitro.mannlib.cornell.edu/ns/vitro/role#editor"));
|
||||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_INPROPERTYGROUPANNOT), subModel.createResource("http://thisIsTheInPropertyGroupURI"));
|
||||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT), subModel.createResource("http://thisIsTheCustomFormEntryURI"));
|
||||
|
||||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT), subModel.createResource("http://thisIsTheCustomFormEntryURI"));
|
||||
|
||||
// Save copies of sub-model and super-model
|
||||
|
||||
|
||||
// uncommment the next two lines to debug failures
|
||||
//System.out.println("**Before updating data property:");
|
||||
//System.out.println("**Before updating data property:");
|
||||
//printModels(superModel, subModel);
|
||||
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
OntModel origSubModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
OntModel origSubModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
origSubModel.add(subModel);
|
||||
OntModel origSuperModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel origSuperModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
origSuperModel.add(superModel);
|
||||
|
||||
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
// Populate the DataProperty with the data in the sub-model and then update the combined model
|
||||
// (from the unchanged object).
|
||||
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena(superModel);
|
||||
DataPropertyDaoJena dpdj = (DataPropertyDaoJena) wdfj.getDataPropertyDao();
|
||||
DataProperty dataProperty = dpdj.getDataPropertyByURI(propertyURI); // the DataProperty will be populated
|
||||
// with the information already in
|
||||
DataProperty dataProperty = dpdj.getDataPropertyByURI(propertyURI); // the DataProperty will be populated
|
||||
// with the information already in
|
||||
// the jena model.
|
||||
|
||||
|
||||
Assert.assertEquals(dataProperty.getPublicName(), property1.getLabel(lang));
|
||||
|
||||
dpdj.updateDataProperty(dataProperty); // we haven't changed any values here, so
|
||||
|
||||
|
||||
Assert.assertEquals(dataProperty.getPublicName(), property1.getLabel(lang));
|
||||
|
||||
dpdj.updateDataProperty(dataProperty); // we haven't changed any values here, so
|
||||
// the models should be unchanged.
|
||||
|
||||
|
||||
// Verify that the sub-model and super-model are both unchanged
|
||||
|
||||
// uncommment the next two lines to debug failures
|
||||
|
@ -112,26 +112,26 @@ public class DataPropertyDaoJenaTest extends AbstractTestClass {
|
|||
//printModels(superModel,subModel);
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
|
||||
//modtime affects the diff but we don't care about that difference
|
||||
wipeOutModTime(origSubModel);
|
||||
wipeOutModTime(origSuperModel);
|
||||
wipeOutModTime(subModel);
|
||||
wipeOutModTime(superModel);
|
||||
|
||||
Assert.assertTrue(subModel.isIsomorphicWith(origSubModel));
|
||||
Assert.assertTrue(superModel.isIsomorphicWith(origSuperModel));
|
||||
|
||||
|
||||
Assert.assertTrue(subModel.isIsomorphicWith(origSubModel));
|
||||
Assert.assertTrue(superModel.isIsomorphicWith(origSuperModel));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void printModels(OntModel superModel, OntModel subModel) {
|
||||
|
||||
// Detach the submodel for printing to get an accurate
|
||||
// account of what is in each.
|
||||
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
|
||||
System.out.println("\nThe sub-model has " + subModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------");
|
||||
subModel.writeAll(System.out,"N3",null);
|
||||
|
@ -139,14 +139,14 @@ public class DataPropertyDaoJenaTest extends AbstractTestClass {
|
|||
System.out.println("\nThe super-model has " + superModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------");
|
||||
superModel.write(System.out,"N3",null);
|
||||
|
||||
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wipeOutModTime(Model model){
|
||||
model.removeAll(null, model.createProperty(VitroVocabulary.MODTIME), null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -38,66 +38,66 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|||
public class JenaBaseDaoTest {
|
||||
String isDependentRelation =
|
||||
" <"+VitroVocabulary.PROPERTY_STUBOBJECTPROPERTYANNOT+"> \"true\"^^xsd:boolean .\n" ;
|
||||
|
||||
String nosePropIsDependentRel =
|
||||
|
||||
String nosePropIsDependentRel =
|
||||
"<"+VitroVocabulary.PROPERTY_STUBOBJECTPROPERTYANNOT+"> rdf:type owl:AnnotationProperty .\n" +
|
||||
" ex:hasNose " + isDependentRelation;
|
||||
|
||||
String prefixesN3 =
|
||||
|
||||
String prefixesN3 =
|
||||
"@prefix vitro: <" + VitroVocabulary.vitroURI + "> . \n" +
|
||||
"@prefix xsd: <" + XSD.getURI() + "> . \n " +
|
||||
"@prefix xsd: <" + XSD.getURI() + "> . \n " +
|
||||
"@prefix rdf: <" + RDF.getURI() + "> . \n"+
|
||||
"@prefix rdfs: <" + RDFS.getURI() + "> . \n"+
|
||||
"@prefix owl: <" + OWL.getURI() + "> . \n" +
|
||||
"@prefix ex: <http://example.com/> . \n" ;
|
||||
|
||||
|
||||
@Test
|
||||
public void smartRemoveTestForIndivdiualDelete(){
|
||||
|
||||
String n3 = prefixesN3 +
|
||||
|
||||
String n3 = prefixesN3 +
|
||||
"ex:prop1 rdf:type owl:ObjectProperty ." +
|
||||
"ex:prop1 rdfs:label \"Prop 1 Dependent Relation\" ." +
|
||||
"ex:prop1 " + isDependentRelation;
|
||||
|
||||
|
||||
Model readInModel = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
|
||||
OntModel ontModel = ModelFactory.createOntologyModel();
|
||||
ontModel.add(readInModel);
|
||||
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena( ontModel);
|
||||
|
||||
|
||||
try {
|
||||
ObjectProperty prop1 = wdfj.getObjectPropertyDao().getObjectPropertyByURI("http://example.com/prop1");
|
||||
Assert.assertNotNull(prop1);
|
||||
|
||||
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI("http://example.com/bob");
|
||||
ind.setName("Smith, Bob");
|
||||
|
||||
wdfj.getIndividualDao().insertNewIndividual(ind);
|
||||
|
||||
ind.setName("Smith, Bob");
|
||||
|
||||
wdfj.getIndividualDao().insertNewIndividual(ind);
|
||||
|
||||
Individual indxyz = new IndividualImpl();
|
||||
indxyz.setURI("http://example.com/depResXYZ");
|
||||
indxyz.setName("depResXYZ");
|
||||
wdfj.getIndividualDao().insertNewIndividual(indxyz);
|
||||
|
||||
indxyz.setName("depResXYZ");
|
||||
wdfj.getIndividualDao().insertNewIndividual(indxyz);
|
||||
|
||||
Individual indAbc = new IndividualImpl();
|
||||
indAbc.setURI("http://example.com/depResNested");
|
||||
indAbc.setName("depResNested");
|
||||
wdfj.getIndividualDao().insertNewIndividual(indAbc);
|
||||
|
||||
indAbc.setName("depResNested");
|
||||
wdfj.getIndividualDao().insertNewIndividual(indAbc);
|
||||
|
||||
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
|
||||
ops.setSubjectURI("http://example.com/bob");
|
||||
ops.setPropertyURI("http://example.com/prop1");
|
||||
ops.setObjectURI("http://example.com/depResXYZ");
|
||||
wdfj.getObjectPropertyStatementDao().insertNewObjectPropertyStatement(ops);
|
||||
|
||||
|
||||
ops = new ObjectPropertyStatementImpl();
|
||||
ops.setSubjectURI("http://example.com/depResXYZ");
|
||||
ops.setPropertyURI("http://example.com/prop1");
|
||||
ops.setObjectURI("http://example.com/depResNested");
|
||||
wdfj.getObjectPropertyStatementDao().insertNewObjectPropertyStatement(ops);
|
||||
|
||||
|
||||
wdfj.getIndividualDao().deleteIndividual("http://example.com/depResXYZ");
|
||||
|
||||
|
||||
String expected =
|
||||
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . "+
|
||||
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ."+
|
||||
|
@ -109,7 +109,7 @@ public class JenaBaseDaoTest {
|
|||
" a owl:ObjectProperty ; " +
|
||||
" rdfs:label \"Prop 1 Dependent Relation\" ; " +
|
||||
isDependentRelation ;
|
||||
|
||||
|
||||
Model expectedModel = (ModelFactory.createOntologyModel()).read(new StringReader(expected), "", "N3");
|
||||
|
||||
assertEquivalentModels(expectedModel, ontModel);
|
||||
|
@ -117,19 +117,19 @@ public class JenaBaseDaoTest {
|
|||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void smartRemoveTestForObjPropStmtDelete(){
|
||||
String n3 = prefixesN3 +
|
||||
String n3 = prefixesN3 +
|
||||
"ex:prop1 rdf:type owl:ObjectProperty ." +
|
||||
"ex:prop1 rdfs:label \"Prop 1 Dependent Relation\" ." +
|
||||
"ex:prop1 " + isDependentRelation;
|
||||
|
||||
|
||||
Model readInModel = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
|
||||
OntModel model = ModelFactory.createOntologyModel();
|
||||
model.add(readInModel);
|
||||
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena( model);
|
||||
|
||||
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena( model);
|
||||
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI("http://example.com/bob");
|
||||
ind.setName("Smith, Bob");
|
||||
|
@ -138,43 +138,43 @@ public class JenaBaseDaoTest {
|
|||
} catch (InsertException e) {
|
||||
Assert.fail("Could not create new Individual Smith, Bob");
|
||||
}
|
||||
|
||||
|
||||
Individual indxyz = new IndividualImpl();
|
||||
indxyz.setURI("http://example.com/depResXYZ");
|
||||
indxyz.setName("depResXYZ");
|
||||
try {
|
||||
wdfj.getIndividualDao().insertNewIndividual(indxyz);
|
||||
wdfj.getIndividualDao().insertNewIndividual(indxyz);
|
||||
} catch (InsertException e) {
|
||||
Assert.fail("Could not create new Individual depResXYZ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Individual indAbc = new IndividualImpl();
|
||||
indAbc.setURI("http://example.com/depResNested");
|
||||
indAbc.setName("depResNested");
|
||||
try {
|
||||
wdfj.getIndividualDao().insertNewIndividual(indAbc);
|
||||
wdfj.getIndividualDao().insertNewIndividual(indAbc);
|
||||
} catch (InsertException e) {
|
||||
Assert.fail("Could not create new Individual depResNested");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
|
||||
ops.setSubjectURI("http://example.com/bob");
|
||||
ops.setPropertyURI("http://example.com/prop1");
|
||||
ops.setObjectURI("http://example.com/depResXYZ");
|
||||
wdfj.getObjectPropertyStatementDao().insertNewObjectPropertyStatement(ops);
|
||||
|
||||
|
||||
ops = new ObjectPropertyStatementImpl();
|
||||
ops.setSubjectURI("http://example.com/depResXYZ");
|
||||
ops.setPropertyURI("http://example.com/prop1");
|
||||
ops.setObjectURI("http://example.com/depResNested");
|
||||
wdfj.getObjectPropertyStatementDao().insertNewObjectPropertyStatement(ops);
|
||||
|
||||
|
||||
ops = new ObjectPropertyStatementImpl();
|
||||
ops.setSubjectURI("http://example.com/bob");
|
||||
ops.setPropertyURI("http://example.com/prop1");
|
||||
ops.setObjectURI("http://example.com/depResXYZ");
|
||||
wdfj.getObjectPropertyStatementDao().deleteObjectPropertyStatement(ops);
|
||||
|
||||
|
||||
String expected =
|
||||
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . "+
|
||||
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ."+
|
||||
|
@ -186,59 +186,59 @@ public class JenaBaseDaoTest {
|
|||
" a owl:ObjectProperty ; " +
|
||||
" rdfs:label \"Prop 1 Dependent Relation\" ; " +
|
||||
isDependentRelation ;
|
||||
|
||||
Model expectedModel = (ModelFactory.createOntologyModel()).read(new StringReader(expected), "", "N3");
|
||||
|
||||
|
||||
Model expectedModel = (ModelFactory.createOntologyModel()).read(new StringReader(expected), "", "N3");
|
||||
|
||||
assertEquivalentModels(expectedModel, model);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void smartRemoveTestForObjPropDelete(){
|
||||
String n3 = prefixesN3 +
|
||||
public void smartRemoveTestForObjPropDelete(){
|
||||
String n3 = prefixesN3 +
|
||||
"ex:prop1 rdf:type owl:ObjectProperty ." +
|
||||
"ex:prop1 rdfs:label \"Prop 1 Dependent Relation\" ." +
|
||||
"ex:prop1 " + isDependentRelation;
|
||||
|
||||
|
||||
Model readInModel = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
|
||||
OntModel ontModel = ModelFactory.createOntologyModel();
|
||||
ontModel.add(readInModel);
|
||||
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena( ontModel);
|
||||
|
||||
|
||||
try {
|
||||
ObjectProperty prop1 = wdfj.getObjectPropertyDao().getObjectPropertyByURI("http://example.com/prop1");
|
||||
Assert.assertNotNull(prop1);
|
||||
|
||||
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI("http://example.com/bob");
|
||||
ind.setName("Smith, Bob");
|
||||
|
||||
wdfj.getIndividualDao().insertNewIndividual(ind);
|
||||
|
||||
ind.setName("Smith, Bob");
|
||||
|
||||
wdfj.getIndividualDao().insertNewIndividual(ind);
|
||||
|
||||
Individual indxyz = new IndividualImpl();
|
||||
indxyz.setURI("http://example.com/depResXYZ");
|
||||
indxyz.setName("depResXYZ");
|
||||
wdfj.getIndividualDao().insertNewIndividual(indxyz);
|
||||
|
||||
indxyz.setName("depResXYZ");
|
||||
wdfj.getIndividualDao().insertNewIndividual(indxyz);
|
||||
|
||||
Individual indAbc = new IndividualImpl();
|
||||
indAbc.setURI("http://example.com/depResNested");
|
||||
indAbc.setName("depResNested");
|
||||
wdfj.getIndividualDao().insertNewIndividual(indAbc);
|
||||
|
||||
indAbc.setName("depResNested");
|
||||
wdfj.getIndividualDao().insertNewIndividual(indAbc);
|
||||
|
||||
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
|
||||
ops.setSubjectURI("http://example.com/bob");
|
||||
ops.setPropertyURI("http://example.com/prop1");
|
||||
ops.setObjectURI("http://example.com/depResXYZ");
|
||||
wdfj.getObjectPropertyStatementDao().insertNewObjectPropertyStatement(ops);
|
||||
|
||||
|
||||
ops = new ObjectPropertyStatementImpl();
|
||||
ops.setSubjectURI("http://example.com/depResXYZ");
|
||||
ops.setPropertyURI("http://example.com/prop1");
|
||||
ops.setObjectURI("http://example.com/depResNested");
|
||||
wdfj.getObjectPropertyStatementDao().insertNewObjectPropertyStatement(ops);
|
||||
|
||||
|
||||
wdfj.getObjectPropertyDao().deleteObjectProperty(prop1);
|
||||
|
||||
|
||||
String expected =
|
||||
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . "+
|
||||
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ."+
|
||||
|
@ -246,18 +246,18 @@ public class JenaBaseDaoTest {
|
|||
"@prefix owl: <http://www.w3.org/2002/07/owl#> . "+
|
||||
"<http://example.com/bob> a owl:Thing ; " +
|
||||
" rdfs:label \"Smith, Bob\"@en-US . " ;
|
||||
|
||||
|
||||
Model expectedModel = (ModelFactory.createOntologyModel()).read(new StringReader(expected), "", "N3");
|
||||
|
||||
|
||||
assertEquivalentModels(expectedModel, ontModel);
|
||||
} catch (InsertException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
// public void smartRemoveTestForObjPropDelete(){
|
||||
//
|
||||
//
|
||||
// OntModel model = ModelFactory.createOntologyModel();
|
||||
// WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena( model );
|
||||
//
|
||||
|
@ -269,7 +269,7 @@ public class JenaBaseDaoTest {
|
|||
// } catch (InsertException e1) {
|
||||
// Assert.fail("could not create class for dependentResourc");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /* Need to have an Object Property */
|
||||
// ObjectProperty op = new ObjectProperty();
|
||||
// op.setURI("http://example.com/prop1");
|
||||
|
@ -278,7 +278,7 @@ public class JenaBaseDaoTest {
|
|||
// } catch (InsertException e1) {
|
||||
// Assert.fail("Could not create object property.");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// Individual ind = new IndividualImpl();
|
||||
// ind.setURI("http://example.com/bob");
|
||||
// ind.setName("Smith, Bob");
|
||||
|
@ -287,48 +287,48 @@ public class JenaBaseDaoTest {
|
|||
// } catch (InsertException e) {
|
||||
// Assert.fail("Could not create new Individual Smith, Bob");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// Individual indxyz = new IndividualImpl();
|
||||
// indxyz.setURI("http://example.com/depResXYZ");
|
||||
// indxyz.setName("depResXYZ");
|
||||
// //indxyz.setVClassURI(VitroVocabulary.DEPENDENT_RESOURCE);
|
||||
// try {
|
||||
// wdfj.getIndividualDao().insertNewIndividual(indxyz);
|
||||
// wdfj.getIndividualDao().insertNewIndividual(indxyz);
|
||||
// } catch (InsertException e) {
|
||||
// Assert.fail("Could not create new Individual depResXYZ");
|
||||
// }
|
||||
// }
|
||||
//// StmtIterator it = model.listStatements(model.createResource("http://example.com/depResXYZ"),
|
||||
//// RDF.type, model.createResource(VitroVocabulary.DEPENDENT_RESOURCE));
|
||||
//// Assert.assertTrue("depResXYZ did not get rdf:type vitro:dependentResource" ,
|
||||
//// it != null && it.nextStatement() != null);
|
||||
//
|
||||
//
|
||||
// Individual indAbc = new IndividualImpl();
|
||||
// indAbc.setURI("http://example.com/depResNested");
|
||||
// indAbc.setName("depResNested");
|
||||
//// indAbc.setVClassURI(VitroVocabulary.DEPENDENT_RESOURCE);
|
||||
// try {
|
||||
// wdfj.getIndividualDao().insertNewIndividual(indAbc);
|
||||
// wdfj.getIndividualDao().insertNewIndividual(indAbc);
|
||||
// } catch (InsertException e) {
|
||||
// Assert.fail("Could not create new Individual depResNested");
|
||||
// }
|
||||
// }
|
||||
//// it = model.listStatements(model.createResource("http://example.com/depResNested"),
|
||||
//// RDF.type, model.createResource(VitroVocabulary.DEPENDENT_RESOURCE));
|
||||
//// Assert.assertTrue("depResNested did not get rdf:type vitro:dependentResource" ,
|
||||
//// it != null && it.nextStatement() != null);
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ObjectPropertyStatement ops = new ObjectPropertyStatementImpl();
|
||||
// ops.setSubjectURI("http://example.com/bob");
|
||||
// ops.setPropertyURI("http://example.com/prop1");
|
||||
// ops.setObjectURI("http://example.com/depResXYZ");
|
||||
// wdfj.getObjectPropertyStatementDao().insertNewObjectPropertyStatement(ops);
|
||||
//
|
||||
//
|
||||
// ops = new ObjectPropertyStatementImpl();
|
||||
// ops.setSubjectURI("http://example.com/depResXYZ");
|
||||
// ops.setPropertyURI("http://example.com/prop1");
|
||||
// ops.setObjectURI("http://example.com/depResNested");
|
||||
// wdfj.getObjectPropertyStatementDao().insertNewObjectPropertyStatement(ops);
|
||||
//
|
||||
//
|
||||
// String expected = "<rdf:RDF\n"+
|
||||
// " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"+
|
||||
// " xmlns:j.0=\"http://vitro.mannlib.cornell.edu/ns/vitro/0.7#\"\n"+
|
||||
|
@ -346,18 +346,18 @@ public class JenaBaseDaoTest {
|
|||
// " <rdf:type rdf:resource=\"http://www.w3.org/2002/07/owl#Class\"/>\n"+
|
||||
// " </rdf:Description>\n"+
|
||||
// "</rdf:RDF>";
|
||||
//
|
||||
//
|
||||
// wdfj.getObjectPropertyDao().deleteObjectProperty(op);
|
||||
//
|
||||
//
|
||||
// Model expectedModel = (ModelFactory.createOntologyModel()).read(new StringReader(expected), "", "RDF/XML");
|
||||
//
|
||||
//
|
||||
// //modtime times make it difficult to compare graphs
|
||||
// wipeOutModTime(expectedModel);
|
||||
// wipeOutModTime(model);
|
||||
// Assert.assertTrue( model.isIsomorphicWith(expectedModel));
|
||||
// Assert.assertTrue( model.isIsomorphicWith(expectedModel));
|
||||
// }
|
||||
|
||||
@Test
|
||||
@Test
|
||||
/**
|
||||
* Tests that any statements with a property as predicate are removed
|
||||
* when the property itself is removed
|
||||
|
@ -365,9 +365,9 @@ public class JenaBaseDaoTest {
|
|||
public void testABoxAssertionsRemovedWhenPropertyRemoved() throws InsertException {
|
||||
OntModel preModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel postModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
|
||||
WebappDaoFactoryJena preWadf = new WebappDaoFactoryJena(preModel);
|
||||
|
||||
|
||||
// make some other stuff that won't be deleted
|
||||
ObjectProperty objPropNotForDeletion = new ObjectProperty();
|
||||
objPropNotForDeletion.setURI("http://dont.delete.me/objProp");
|
||||
|
@ -384,13 +384,13 @@ public class JenaBaseDaoTest {
|
|||
dataPropStmtNotForDeletion.setIndividualURI("http://individual.example.org/a/");
|
||||
dataPropStmtNotForDeletion.setDatapropURI(dataPropNotForDeletion.getURI());
|
||||
dataPropStmtNotForDeletion.setData("junk");
|
||||
|
||||
|
||||
// copy the not-for-deletion data to the postModel
|
||||
postModel.add(preModel);
|
||||
|
||||
|
||||
// Make some properties and assertions that should be deleted.
|
||||
// After deletion, the "preModel" should match the "postModel," which
|
||||
// only contains the not-for-deletion statements.
|
||||
// only contains the not-for-deletion statements.
|
||||
ObjectProperty objProp = new ObjectProperty();
|
||||
objProp.setURI("http://example.org/objProp");
|
||||
preWadf.getObjectPropertyDao().insertObjectProperty(objProp);
|
||||
|
@ -407,18 +407,18 @@ public class JenaBaseDaoTest {
|
|||
dataPropStmtForDeletion.setDatapropURI(dataProp.getURI());
|
||||
dataPropStmtForDeletion.setData("I will be deleted!");
|
||||
preWadf.getDataPropertyStatementDao().insertNewDataPropertyStatement(dataPropStmtForDeletion);
|
||||
|
||||
// delete the object property and the data property.
|
||||
|
||||
// delete the object property and the data property.
|
||||
// The abox assertions should go with them.
|
||||
preWadf.getObjectPropertyDao().deleteObjectProperty(objProp);
|
||||
preWadf.getDataPropertyDao().deleteDataProperty(dataProp);
|
||||
|
||||
|
||||
// the preModel and the postModel should now have the same statements
|
||||
//Assert.assertTrue(preModel.isIsomorphicWith(postModel));
|
||||
Assert.assertTrue(preModel.size() == postModel.size());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
/**
|
||||
* Test that removing classes or properties used in restrictions
|
||||
|
@ -428,35 +428,35 @@ public class JenaBaseDaoTest {
|
|||
public void testPreventInvalidRestrictionsOnDeletion() {
|
||||
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
WebappDaoFactoryJena wadf = new WebappDaoFactoryJena(m);
|
||||
|
||||
|
||||
String ns = "http://example.org/ontology/";
|
||||
String class1URI = ns + "Class1";
|
||||
String class2URI = ns + "Class2";
|
||||
String propURI = ns + "property";
|
||||
|
||||
|
||||
OntClass class1 = m.createClass(class1URI);
|
||||
OntClass class2 = m.createClass(class2URI);
|
||||
OntProperty prop = m.createObjectProperty(propURI);
|
||||
Restriction rest = m.createAllValuesFromRestriction(null, prop, class2);
|
||||
class1.addSuperClass(rest);
|
||||
|
||||
|
||||
ObjectProperty op = wadf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
|
||||
wadf.getObjectPropertyDao().deleteObjectProperty(op);
|
||||
|
||||
|
||||
Assert.assertEquals(class1.listSuperClasses().toSet().size(), 0);
|
||||
Assert.assertEquals(m.size(), 2); // just rdf:type owl:Class for Class1 and Class2
|
||||
|
||||
|
||||
prop = m.createObjectProperty(propURI);
|
||||
rest = m.createAllValuesFromRestriction(null, prop, class2);
|
||||
class1.addSuperClass(rest);
|
||||
|
||||
|
||||
VClass vclass = wadf.getVClassDao().getVClassByURI(class2URI);
|
||||
wadf.getVClassDao().deleteVClass(vclass);
|
||||
|
||||
|
||||
Assert.assertEquals(class1.listSuperClasses().toSet().size(), 0);
|
||||
Assert.assertEquals(m.size(), 2); // just rdf:type for Class1 and Prop
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the contents of the expected model with the actual model (not counting modification times).
|
||||
|
@ -483,6 +483,6 @@ public class JenaBaseDaoTest {
|
|||
private void wipeOutModTime(Model model){
|
||||
model.removeAll(null, model.createProperty(VitroVocabulary.MODTIME), null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,17 +23,17 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.MenuItem;
|
|||
|
||||
|
||||
public class MenuDaoJenaTest extends AbstractTestClass {
|
||||
|
||||
|
||||
OntModel displayModel;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Suppress error logging.
|
||||
setLoggerLevel(RDFDefaultErrorHandler.class, Level.OFF);
|
||||
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
InputStream in = MenuDaoJenaTest.class.getResourceAsStream("resources/menuForTest.n3");
|
||||
model.read(in,"","N3");
|
||||
model.read(in,"","N3");
|
||||
displayModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,model);
|
||||
}
|
||||
|
||||
|
@ -42,64 +42,64 @@ public class MenuDaoJenaTest extends AbstractTestClass {
|
|||
SimpleOntModelSelector sos = new SimpleOntModelSelector( ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM));
|
||||
sos.setDisplayModel(displayModel);
|
||||
MenuDaoJena menuDaoJena = new MenuDaoJena(new WebappDaoFactoryJena(sos));
|
||||
|
||||
MainMenu menu = menuDaoJena.getMainMenu( "notImportant" );
|
||||
|
||||
|
||||
MainMenu menu = menuDaoJena.getMainMenu( "notImportant" );
|
||||
|
||||
try{
|
||||
Class clz = UrlBuilder.class;
|
||||
Field f = clz.getDeclaredField( "contextPath" );
|
||||
f.setAccessible(true);
|
||||
f.set(null, "bogusUrlContextPath");
|
||||
f.set(null, "bogusUrlContextPath");
|
||||
}catch(Exception e){
|
||||
Assert.fail(e.toString());
|
||||
}
|
||||
|
||||
|
||||
Assert.assertNotNull(menu);
|
||||
Assert.assertNotNull( menu.getItems() );
|
||||
Assert.assertEquals(5, menu.getItems().size());
|
||||
|
||||
|
||||
//The nulls in getUrl() are from the UrlBuilder not being setup correctly.
|
||||
//it should be fine.
|
||||
|
||||
|
||||
MenuItem item = menu.getItems().get(0);
|
||||
Assert.assertNotNull(item);
|
||||
Assert.assertEquals("Home",item.getLinkText());
|
||||
Assert.assertEquals("bogusUrlContextPath/home",item.getUrl());
|
||||
|
||||
|
||||
item = menu.getItems().get(1);
|
||||
Assert.assertNotNull(item);
|
||||
Assert.assertEquals("People",item.getLinkText());
|
||||
Assert.assertEquals("bogusUrlContextPath/people",item.getUrl());
|
||||
|
||||
|
||||
item = menu.getItems().get(2);
|
||||
Assert.assertNotNull(item);
|
||||
Assert.assertEquals("Publications",item.getLinkText());
|
||||
Assert.assertEquals("bogusUrlContextPath/publications",item.getUrl());
|
||||
|
||||
|
||||
item = menu.getItems().get(3);
|
||||
Assert.assertNotNull(item);
|
||||
Assert.assertEquals("Events",item.getLinkText());
|
||||
Assert.assertEquals("bogusUrlContextPath/events",item.getUrl());
|
||||
|
||||
|
||||
item = menu.getItems().get(4);
|
||||
Assert.assertNotNull(item);
|
||||
Assert.assertEquals("Organizations",item.getLinkText());
|
||||
Assert.assertEquals("bogusUrlContextPath/organizations",item.getUrl());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void isActiveTest(){
|
||||
SimpleOntModelSelector sos = new SimpleOntModelSelector( ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM));
|
||||
sos.setDisplayModel(displayModel);
|
||||
MenuDaoJena menuDaoJena = new MenuDaoJena(new WebappDaoFactoryJena(sos));
|
||||
|
||||
MenuDaoJena menuDaoJena = new MenuDaoJena(new WebappDaoFactoryJena(sos));
|
||||
|
||||
//First arg is the page the user is on. Second arg is the urlmapping of the menu item.
|
||||
Assert.assertTrue( menuDaoJena.isActive("/", "/") );
|
||||
Assert.assertTrue( menuDaoJena.isActive("/people", "/people") );
|
||||
|
||||
|
||||
Assert.assertFalse( menuDaoJena.isActive("/people", "/") );
|
||||
Assert.assertFalse( menuDaoJena.isActive("/", "/people") );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
|
||||
public class ObjectPropertyDaoJenaTest extends AbstractTestClass {
|
||||
|
||||
public class ObjectPropertyDaoJenaTest extends AbstractTestClass {
|
||||
|
||||
@Test
|
||||
public void testCollateBySubclass(){
|
||||
/* Check that we can save collateBySubclass */
|
||||
OntModel model = ModelFactory.createOntologyModel();
|
||||
WebappDaoFactory wdf = new WebappDaoFactoryJena(model);
|
||||
|
||||
|
||||
ObjectProperty op1 = new ObjectProperty();
|
||||
String propURI = "http://example.com/testObjectProp" ;
|
||||
String propURI = "http://example.com/testObjectProp" ;
|
||||
op1.setURI(propURI);
|
||||
Assert.assertFalse(op1.getCollateBySubclass());
|
||||
try {
|
||||
|
@ -35,34 +35,34 @@ public class ObjectPropertyDaoJenaTest extends AbstractTestClass {
|
|||
ObjectProperty op2 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
|
||||
Assert.assertNotNull(op2);
|
||||
Assert.assertFalse(op2.getCollateBySubclass());
|
||||
|
||||
|
||||
op2.setCollateBySubclass(true);
|
||||
wdf.getObjectPropertyDao().updateObjectProperty(op2);
|
||||
|
||||
|
||||
ObjectProperty op3 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
|
||||
Assert.assertNotNull(op3);
|
||||
Assert.assertTrue(op3.getCollateBySubclass());
|
||||
|
||||
|
||||
op3.setCollateBySubclass(false);
|
||||
wdf.getObjectPropertyDao().updateObjectProperty(op3);
|
||||
|
||||
|
||||
ObjectProperty op4 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
|
||||
Assert.assertNotNull(op4);
|
||||
Assert.assertFalse(op4.getCollateBySubclass());
|
||||
|
||||
|
||||
} catch (InsertException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStubObjectProperty(){
|
||||
/* Check that we can save collateBySubclass */
|
||||
OntModel model = ModelFactory.createOntologyModel();
|
||||
WebappDaoFactory wdf = new WebappDaoFactoryJena(model);
|
||||
|
||||
|
||||
ObjectProperty op1 = new ObjectProperty();
|
||||
String propURI = "http://example.com/testObjectProp" ;
|
||||
String propURI = "http://example.com/testObjectProp" ;
|
||||
op1.setURI(propURI);
|
||||
Assert.assertFalse(op1.getStubObjectRelation());
|
||||
try {
|
||||
|
@ -70,42 +70,42 @@ public class ObjectPropertyDaoJenaTest extends AbstractTestClass {
|
|||
ObjectProperty op2 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
|
||||
Assert.assertNotNull(op2);
|
||||
Assert.assertFalse(op2.getStubObjectRelation());
|
||||
|
||||
|
||||
op2.setStubObjectRelation(true);
|
||||
wdf.getObjectPropertyDao().updateObjectProperty(op2);
|
||||
|
||||
|
||||
ObjectProperty op3 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
|
||||
Assert.assertNotNull(op3);
|
||||
Assert.assertTrue(op3.getStubObjectRelation());
|
||||
|
||||
|
||||
op3.setStubObjectRelation(false);
|
||||
wdf.getObjectPropertyDao().updateObjectProperty(op3);
|
||||
|
||||
|
||||
ObjectProperty op4 = wdf.getObjectPropertyDao().getObjectPropertyByURI(propURI);
|
||||
Assert.assertNotNull(op4);
|
||||
Assert.assertFalse(op4.getStubObjectRelation());
|
||||
|
||||
|
||||
} catch (InsertException e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
// Test that the ObjectPropertyDaoJena::updateProperty method will only update the jena model for
|
||||
// Test that the ObjectPropertyDaoJena::updateProperty method will only update the jena model for
|
||||
// those properties in ObjectProperty that have a different value from what is already in the
|
||||
// jena model for that property.
|
||||
//
|
||||
// jena model for that property.
|
||||
//
|
||||
// Specifically, updateProperty method should not remove a statement from the model and
|
||||
// then add the same statement back in. The reason for this is that in vitro the "immutable" properties
|
||||
// are stored in a sub-model and the user-editable properties are stored in a super-model and
|
||||
// all updates are performed against the super-model, so removing and then re-adding
|
||||
// the same statement may result in a change of state (if the statement was in the sub-model
|
||||
// all updates are performed against the super-model, so removing and then re-adding
|
||||
// the same statement may result in a change of state (if the statement was in the sub-model
|
||||
// it will migrate to the super-model) because of the way jena handles additions and
|
||||
// deletions with respect to super and sub models. This migration of statements may cause
|
||||
// undesirable behavior in the vitro application.
|
||||
|
||||
|
||||
public void minimalUpdates(){
|
||||
|
||||
|
||||
// 1. create two models and attach one as a sub-model of the other
|
||||
// 2. populate the sub-model with one statement for each of the properties represented in ObjectProperty
|
||||
// TODO still need to populate more of the properties, and set up some inverse and parent and inverse of
|
||||
|
@ -114,26 +114,26 @@ public class ObjectPropertyDaoJenaTest extends AbstractTestClass {
|
|||
// 4. populate an ObjectProperty object with the data in the (combined) model and call the updateProperty
|
||||
// (having made no changes to the ObjectProperty object)
|
||||
// 5. verify that both the sub-model and the super-model are unchanged
|
||||
|
||||
|
||||
String propertyURI = "http://example.com/testObjectProp";
|
||||
|
||||
OntModel superModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); // this simulates the user-editable ontology in vivo
|
||||
OntModel subModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); // this simulates the core ontology in vivo
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
String rdfsLabel = "this is the rdfs label";
|
||||
String lang = "en-US";
|
||||
|
||||
|
||||
// populate sub-model
|
||||
org.apache.jena.ontology.ObjectProperty property1 = subModel.createObjectProperty(propertyURI);
|
||||
|
||||
property1.setLabel(rdfsLabel,lang);
|
||||
|
||||
|
||||
property1.setLabel(rdfsLabel,lang);
|
||||
|
||||
property1.convertToTransitiveProperty();
|
||||
property1.convertToSymmetricProperty();
|
||||
property1.convertToFunctionalProperty();
|
||||
property1.convertToInverseFunctionalProperty();
|
||||
|
||||
|
||||
property1.setPropertyValue(RDFS.domain, subModel.createResource("http://thisIsTheDomainClassURI"));
|
||||
property1.setPropertyValue(RDFS.range, subModel.createResource("http://thisIsTheRangeClassURI"));
|
||||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.EXAMPLE_ANNOT), subModel.createTypedLiteral("this is the example"));
|
||||
|
@ -150,62 +150,62 @@ public class ObjectPropertyDaoJenaTest extends AbstractTestClass {
|
|||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_INPROPERTYGROUPANNOT), subModel.createResource("http://thisIsTheInPropertyGroupURI"));
|
||||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT), subModel.createResource("http://thisIsTheCustomFormEntryURI"));
|
||||
property1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_SELECTFROMEXISTINGANNOT), subModel.createTypedLiteral(true));
|
||||
|
||||
|
||||
// Save copies of sub-model and super-model
|
||||
|
||||
|
||||
// uncommment the next two lines to debug failures
|
||||
//System.out.println("**Before updating data property:");
|
||||
//printModels(superModel, subModel);
|
||||
|
||||
//System.out.println("**Before updating data property:");
|
||||
//printModels(superModel, subModel);
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
OntModel origSubModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
OntModel origSubModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
origSubModel.add(subModel);
|
||||
OntModel origSuperModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel origSuperModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
origSuperModel.add(superModel);
|
||||
|
||||
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
// Populate the ObjectProperty with the data in the sub-model and then update the combined model
|
||||
// (from the unchanged object).
|
||||
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena(superModel);
|
||||
ObjectPropertyDaoJena pdj = (ObjectPropertyDaoJena) wdfj.getObjectPropertyDao();
|
||||
ObjectProperty objectProperty = pdj.getObjectPropertyByURI(propertyURI); // the Property will be populated
|
||||
// with the information already in
|
||||
ObjectProperty objectProperty = pdj.getObjectPropertyByURI(propertyURI); // the Property will be populated
|
||||
// with the information already in
|
||||
// the jena model.
|
||||
|
||||
|
||||
|
||||
|
||||
// check RDFS label here
|
||||
|
||||
pdj.updateObjectProperty(objectProperty); // we haven't changed any values here, so
|
||||
|
||||
pdj.updateObjectProperty(objectProperty); // we haven't changed any values here, so
|
||||
// the models should be unchanged.
|
||||
|
||||
|
||||
// Verify that the sub-model and super-model are both unchanged
|
||||
|
||||
// uncommment the next two lines to debug failures
|
||||
//System.out.println("\n**After updating data property:");
|
||||
//printModels(superModel,subModel);
|
||||
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
|
||||
//modtime affects the diff but we don't care about that difference
|
||||
wipeOutModTime(origSubModel);
|
||||
wipeOutModTime(origSuperModel);
|
||||
wipeOutModTime(subModel);
|
||||
wipeOutModTime(superModel);
|
||||
|
||||
Assert.assertTrue(subModel.isIsomorphicWith(origSubModel));
|
||||
Assert.assertTrue(superModel.isIsomorphicWith(origSuperModel));
|
||||
|
||||
Assert.assertTrue(subModel.isIsomorphicWith(origSubModel));
|
||||
Assert.assertTrue(superModel.isIsomorphicWith(origSuperModel));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void printModels(OntModel superModel, OntModel subModel) {
|
||||
|
||||
// Detach the submodel for printing to get an accurate
|
||||
// account of what is in each.
|
||||
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
|
||||
System.out.println("\nThe sub-model has " + subModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------");
|
||||
subModel.writeAll(System.out,"N3",null);
|
||||
|
@ -213,15 +213,15 @@ public class ObjectPropertyDaoJenaTest extends AbstractTestClass {
|
|||
System.out.println("\nThe super-model has " + superModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------");
|
||||
superModel.write(System.out,"N3",null);
|
||||
|
||||
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wipeOutModTime(Model model){
|
||||
model.removeAll(null, model.createProperty(VitroVocabulary.MODTIME), null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@ public class ObjectPropertyStatementDaoJenaTest {
|
|||
*/
|
||||
@Test
|
||||
public void testN3WithSameAs() {
|
||||
|
||||
|
||||
String n3WithSameAs = " <http://example.com/bob> = <http://example.com/robert> .";
|
||||
|
||||
|
||||
try{
|
||||
Model m = ModelFactory.createDefaultModel();
|
||||
m.read(n3WithSameAs, null, "N3");
|
||||
fail( "If this test fails it means that jena now correctly parses = when reading N3.");
|
||||
}catch(Exception ex ){
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@ public class OntModelSegementationTest {
|
|||
public void setUpWebappDaoFactoryJena() {
|
||||
wadf = new WebappDaoFactoryJena(new SimpleOntModelSelector());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUserAccountModel() {
|
||||
|
||||
|
||||
UserAccountsDao uadao = wadf.getUserAccountsDao();
|
||||
OntModelSelector oms = wadf.getOntModelSelector();
|
||||
|
||||
|
@ -46,14 +46,14 @@ public class OntModelSegementationTest {
|
|||
user.setFirstName("Chuck");
|
||||
user.setLastName("Roast");
|
||||
user.setExternalAuthId("chuckroast");
|
||||
|
||||
|
||||
uadao.insertUserAccount(user);
|
||||
Assert.assertTrue(oms.getUserAccountsModel().size() > 0);
|
||||
Assert.assertTrue(oms.getFullModel().size() == 0);
|
||||
Assert.assertTrue(oms.getABoxModel().size() == 0);
|
||||
Assert.assertTrue(oms.getTBoxModel().size() == 0);
|
||||
Assert.assertTrue(oms.getApplicationMetadataModel().size() == 0);
|
||||
|
||||
|
||||
user.setEmailAddress("todd@somewhere");
|
||||
uadao.updateUserAccount(user);
|
||||
Assert.assertTrue(oms.getUserAccountsModel().size() > 0);
|
||||
|
@ -61,154 +61,154 @@ public class OntModelSegementationTest {
|
|||
Assert.assertTrue(oms.getABoxModel().size() == 0);
|
||||
Assert.assertTrue(oms.getTBoxModel().size() == 0);
|
||||
Assert.assertTrue(oms.getApplicationMetadataModel().size() == 0);
|
||||
|
||||
|
||||
uadao.deleteUserAccount(user.getUri());
|
||||
Assert.assertTrue(oms.getUserAccountsModel().size() == 0);
|
||||
Assert.assertTrue(oms.getFullModel().size() == 0);
|
||||
Assert.assertTrue(oms.getABoxModel().size() == 0);
|
||||
Assert.assertTrue(oms.getTBoxModel().size() == 0);
|
||||
Assert.assertTrue(oms.getApplicationMetadataModel().size() == 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void testApplicationMetadataModel() throws InsertException {
|
||||
|
||||
|
||||
PortalDao pdao = wadf.getPortalDao();
|
||||
TabDao tdao = wadf.getTabDao();
|
||||
VClassGroupDao vcgdao = wadf.getVClassGroupDao();
|
||||
PropertyGroupDao pgdao = wadf.getPropertyGroupDao();
|
||||
OntModelSelector oms = wadf.getOntModelSelector();
|
||||
|
||||
|
||||
this.assertAllModelsExceptAppMetadataAreEmpty(oms);
|
||||
|
||||
|
||||
//insert a portal
|
||||
Portal portal = new Portal();
|
||||
portal.setPortalId(1);
|
||||
portal.setAppName("test portal");
|
||||
pdao.insertPortal(portal);
|
||||
this.assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
//insert a tab
|
||||
Tab tab = new Tab();
|
||||
tab.setTitle("test tab");
|
||||
int tabId = tdao.insertTab(tab);
|
||||
tab.setTabId(tabId);
|
||||
this.assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
//insert a classgroup
|
||||
VClassGroup group = new VClassGroup();
|
||||
group.setURI("http://example.org/classgroup");
|
||||
group.setPublicName("test group");
|
||||
vcgdao.insertNewVClassGroup(group);
|
||||
this.assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
//insert a property group
|
||||
PropertyGroup pgroup = new PropertyGroup();
|
||||
pgroup.setURI("http://example.org/propertygroup");
|
||||
pgroup.setName("test property group");
|
||||
pgdao.insertNewPropertyGroup(pgroup);
|
||||
this.assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
portal.setAppName("updated portal");
|
||||
tab.setTitle("updated tab");
|
||||
group.setPublicName("updated group");
|
||||
pgroup.setName("updated property group");
|
||||
|
||||
|
||||
pdao.updatePortal(portal);
|
||||
this.assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
tdao.updateTab(tab);
|
||||
this.assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
vcgdao.updateVClassGroup(group);
|
||||
this.assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
pgdao.updatePropertyGroup(pgroup);
|
||||
this.assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
tdao.deleteTab(tab);
|
||||
vcgdao.deleteVClassGroup(group);
|
||||
pgdao.deletePropertyGroup(pgroup);
|
||||
|
||||
|
||||
this.assertAllModelsExceptAppMetadataAreEmpty(oms);
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@Test
|
||||
public void testTBoxModel() throws InsertException {
|
||||
|
||||
|
||||
OntModelSelector oms = wadf.getOntModelSelector();
|
||||
VClassDao vcDao = wadf.getVClassDao();
|
||||
ObjectPropertyDao opDao = wadf.getObjectPropertyDao();
|
||||
DataPropertyDao dpDao = wadf.getDataPropertyDao();
|
||||
OntologyDao oDao = wadf.getOntologyDao();
|
||||
|
||||
|
||||
VClass vclass = new VClass();
|
||||
vclass.setURI("http://example.org/vclass");
|
||||
vcDao.insertNewVClass(vclass);
|
||||
this.assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
ObjectProperty op = new ObjectProperty();
|
||||
op.setURI("http://example.org/objectProperty");
|
||||
opDao.insertObjectProperty(op);
|
||||
this.assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
DataProperty dp = new DataProperty();
|
||||
dp.setURI("http://example.org/dataProperty");
|
||||
dpDao.insertDataProperty(dp);
|
||||
this.assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
Ontology o = new Ontology();
|
||||
o.setURI("http://example.org/");
|
||||
oDao.insertNewOntology(o);
|
||||
this.assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
vclass.setName("vclass");
|
||||
op.setDomainPublic("objectProperty");
|
||||
dp.setPublicName("dataProperty");
|
||||
o.setName("ontology");
|
||||
|
||||
|
||||
vcDao.updateVClass(vclass);
|
||||
this.assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
opDao.updateObjectProperty(op);
|
||||
this.assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
dpDao.updateDataProperty(dp);
|
||||
this.assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
oDao.updateOntology(o);
|
||||
this.assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
vcDao.deleteVClass(vclass);
|
||||
opDao.deleteObjectProperty(op);
|
||||
dpDao.deleteDataProperty(dp);
|
||||
oDao.deleteOntology(o);
|
||||
|
||||
|
||||
this.assertAllModelsExceptAppMetadataAreEmpty(oms);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAboxModel() throws InsertException {
|
||||
|
||||
|
||||
OntModelSelector oms = wadf.getOntModelSelector();
|
||||
IndividualDao iDao = wadf.getIndividualDao();
|
||||
|
||||
|
||||
Individual ind = new IndividualImpl("http://example.org/individual");
|
||||
iDao.insertNewIndividual(ind);
|
||||
this.assertABoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
ind.setName("ind");
|
||||
iDao.updateIndividual(ind);
|
||||
this.assertABoxModelNonemptyAndAllOtherModelsAreEmpty(oms);
|
||||
|
||||
|
||||
iDao.deleteIndividual(ind);
|
||||
this.assertAllModelsExceptAppMetadataAreEmpty(oms);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void assertAllModelsExceptAppMetadataAreEmpty(OntModelSelector oms) {
|
||||
|
@ -218,7 +218,7 @@ public class OntModelSegementationTest {
|
|||
Assert.assertTrue(oms.getTBoxModel().size() == 0);
|
||||
Assert.assertTrue(oms.getUserAccountsModel().size() == 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
private void assertMetadataModelNonemptyAndAllOtherModelsAreEmpty(OntModelSelector oms) {
|
||||
Assert.assertTrue(oms.getApplicationMetadataModel().size() > 0);
|
||||
|
@ -228,7 +228,7 @@ public class OntModelSegementationTest {
|
|||
Assert.assertTrue(oms.getUserAccountsModel().size() == 0);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
private void assertTBoxModelNonemptyAndAllOtherModelsAreEmpty(OntModelSelector oms) {
|
||||
Assert.assertTrue(oms.getTBoxModel().size() > 0);
|
||||
Assert.assertTrue(oms.getFullModel().size() == oms.getTBoxModel().size());
|
||||
|
@ -236,7 +236,7 @@ public class OntModelSegementationTest {
|
|||
Assert.assertTrue(oms.getApplicationMetadataModel().size() == 0);
|
||||
Assert.assertTrue(oms.getUserAccountsModel().size() == 0);
|
||||
}
|
||||
|
||||
|
||||
private void assertABoxModelNonemptyAndAllOtherModelsAreEmpty(OntModelSelector oms) {
|
||||
Assert.assertTrue(oms.getABoxModel().size() > 0);
|
||||
Assert.assertTrue(oms.getFullModel().size() == oms.getABoxModel().size());
|
||||
|
@ -244,7 +244,7 @@ public class OntModelSegementationTest {
|
|||
Assert.assertTrue(oms.getApplicationMetadataModel().size() == 0);
|
||||
Assert.assertTrue(oms.getUserAccountsModel().size() == 0);
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testConcurrency() throws InsertException {
|
||||
|
@ -260,32 +260,32 @@ public class OntModelSegementationTest {
|
|||
v.setName("blah " + i);
|
||||
wadf.getVClassDao().updateVClass(v);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class ClassLister implements Runnable {
|
||||
|
||||
|
||||
private WebappDaoFactory wadf;
|
||||
|
||||
|
||||
public ClassLister(WebappDaoFactory wadf) {
|
||||
this.wadf = wadf;
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
|
||||
|
||||
//int vclassTotal = wadf.getVClassDao().getAllVclasses().size();
|
||||
|
||||
|
||||
for (int i = 0; i < 1500; i++) {
|
||||
|
||||
|
||||
wadf.getVClassDao().getAllVclasses().size();
|
||||
|
||||
|
||||
// if (vclassTotal != wadf.getVClassDao().getAllVclasses().size()) {
|
||||
// throw new RuntimeException("Inconsistent VClass list size");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,115 +23,115 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|||
public class PropertyInstanceDaoJenaTest {
|
||||
String isDependentRelation =
|
||||
" <"+VitroVocabulary.PROPERTY_STUBOBJECTPROPERTYANNOT+"> \"true\"^^xsd:boolean .\n" ;
|
||||
|
||||
String nosePropIsDependentRel =
|
||||
|
||||
String nosePropIsDependentRel =
|
||||
"<"+VitroVocabulary.PROPERTY_STUBOBJECTPROPERTYANNOT+"> rdf:type owl:AnnotationProperty .\n" +
|
||||
" ex:hasNose " + isDependentRelation;
|
||||
|
||||
String prefixesN3 =
|
||||
|
||||
String prefixesN3 =
|
||||
"@prefix vitro: <" + VitroVocabulary.vitroURI + "> . \n" +
|
||||
"@prefix xsd: <" + XSD.getURI() + "> . \n " +
|
||||
"@prefix ex: <http://example.com/> . \n" +
|
||||
"@prefix ex: <http://example.com/> . \n" +
|
||||
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . \n"+
|
||||
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n"+
|
||||
"@prefix owl: <http://www.w3.org/2002/07/owl#> . \n";
|
||||
|
||||
|
||||
|
||||
void printModels(Model expected, Model result){
|
||||
System.out.println("Expected:");
|
||||
expected.write(System.out);
|
||||
System.out.println("Result:");
|
||||
result.write(System.out);
|
||||
result.write(System.out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void testStmtNonForceDelete() {
|
||||
String n3 =
|
||||
String n3 =
|
||||
prefixesN3 +
|
||||
" ex:bob ex:hasNose ex:nose1 . \n" +
|
||||
" ex:nose1 ex:hasHair ex:hair23. \n" +
|
||||
" ex:hair23 ex:hasHairCount \"23\". " ;
|
||||
|
||||
String expected =
|
||||
prefixesN3 +
|
||||
" ex:nose1 ex:hasHair ex:hair23. \n" +
|
||||
" ex:hair23 ex:hasHairCount \"23\". " ;
|
||||
|
||||
Model model = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
|
||||
OntModel ontModel = ModelFactory.createOntologyModel();
|
||||
ontModel.add(model.listStatements());
|
||||
WebappDaoFactory wdf = new WebappDaoFactoryJena(ontModel);
|
||||
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement("http://example.com/bob", "http://example.com/hasNose", "http://example.com/nose1");
|
||||
|
||||
Model expectedModel = (ModelFactory.createDefaultModel()).read(new StringReader(expected), "", "N3");
|
||||
wipeOutModTime(ontModel);
|
||||
//Model resultModel = ModelFactory.createDefaultModel().add(ontModel.listStatements());
|
||||
|
||||
boolean same = expectedModel.isIsomorphicWith( ontModel.getBaseModel() );
|
||||
if( ! same ) printModels( expectedModel, ontModel.getBaseModel());
|
||||
Assert.assertTrue( same );
|
||||
}
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void testStmtSimpleForceDelete() {
|
||||
String n3=
|
||||
prefixesN3 +
|
||||
nosePropIsDependentRel +
|
||||
"ex:hasHair " + isDependentRelation +
|
||||
" ex:bob ex:hasNose ex:nose1 . \n" +
|
||||
" ex:nose1 ex:hasHair ex:hair23. \n" +
|
||||
" ex:hair23 ex:hasHairCount \"23\". " ;
|
||||
String expected =
|
||||
" ex:hair23 ex:hasHairCount \"23\". " ;
|
||||
|
||||
String expected =
|
||||
prefixesN3 +
|
||||
nosePropIsDependentRel +
|
||||
"ex:hasHair " + isDependentRelation ;
|
||||
|
||||
" ex:nose1 ex:hasHair ex:hair23. \n" +
|
||||
" ex:hair23 ex:hasHairCount \"23\". " ;
|
||||
|
||||
Model model = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
|
||||
OntModel ontModel = ModelFactory.createOntologyModel();
|
||||
ontModel.add(model.listStatements());
|
||||
ontModel.add(model.listStatements());
|
||||
WebappDaoFactory wdf = new WebappDaoFactoryJena(ontModel);
|
||||
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement("http://example.com/bob", "http://example.com/hasNose", "http://example.com/nose1");
|
||||
|
||||
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement("http://example.com/bob", "http://example.com/hasNose", "http://example.com/nose1");
|
||||
|
||||
Model expectedModel = (ModelFactory.createDefaultModel()).read(new StringReader(expected), "", "N3");
|
||||
wipeOutModTime(ontModel);
|
||||
//Model resultModel = ModelFactory.createDefaultModel().add(ontModel.listStatements());
|
||||
|
||||
|
||||
boolean same = expectedModel.isIsomorphicWith( ontModel.getBaseModel() );
|
||||
if( ! same ) printModels( expectedModel, ontModel.getBaseModel());
|
||||
Assert.assertTrue( same );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void testStmtSimpleForceDelete() {
|
||||
String n3=
|
||||
prefixesN3 +
|
||||
nosePropIsDependentRel +
|
||||
"ex:hasHair " + isDependentRelation +
|
||||
" ex:bob ex:hasNose ex:nose1 . \n" +
|
||||
" ex:nose1 ex:hasHair ex:hair23. \n" +
|
||||
" ex:hair23 ex:hasHairCount \"23\". " ;
|
||||
String expected =
|
||||
prefixesN3 +
|
||||
nosePropIsDependentRel +
|
||||
"ex:hasHair " + isDependentRelation ;
|
||||
|
||||
Model model = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
|
||||
OntModel ontModel = ModelFactory.createOntologyModel();
|
||||
ontModel.add(model.listStatements());
|
||||
WebappDaoFactory wdf = new WebappDaoFactoryJena(ontModel);
|
||||
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement("http://example.com/bob", "http://example.com/hasNose", "http://example.com/nose1");
|
||||
|
||||
Model expectedModel = (ModelFactory.createDefaultModel()).read(new StringReader(expected), "", "N3");
|
||||
wipeOutModTime(ontModel);
|
||||
//Model resultModel = ModelFactory.createDefaultModel().add(ontModel.listStatements());
|
||||
|
||||
boolean same = expectedModel.isIsomorphicWith( ontModel.getBaseModel() );
|
||||
if( ! same ) printModels( expectedModel, ontModel.getBaseModel());
|
||||
Assert.assertTrue( same );
|
||||
}
|
||||
|
||||
@org.junit.Test
|
||||
public void testStmtForceDeleteWithLiterals() {
|
||||
String n3 =
|
||||
String n3 =
|
||||
prefixesN3 +
|
||||
nosePropIsDependentRel +
|
||||
"ex:hasHair " + isDependentRelation +
|
||||
" ex:bob ex:a \"Bob\". \n" +
|
||||
" ex:bob ex:hasNose ex:nose1 . \n" +
|
||||
" ex:bob ex:hasNose ex:nose1 . \n" +
|
||||
" ex:nose1 ex:a \"this is a literal\". \n" +
|
||||
" ex:nose1 ex:b \"2343\" . \n" +
|
||||
" ex:nose1 ex:hasHair ex:hair23. \n" +
|
||||
" ex:hair23 ex:hasHairCount \"23\". " ;
|
||||
|
||||
String expected =
|
||||
|
||||
String expected =
|
||||
prefixesN3 +
|
||||
nosePropIsDependentRel +
|
||||
"ex:hasHair " + isDependentRelation +
|
||||
" ex:bob ex:a \"Bob\". \n" ;
|
||||
|
||||
|
||||
Model model = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
|
||||
OntModel ontModel = ModelFactory.createOntologyModel();
|
||||
ontModel.add(model.listStatements());
|
||||
ontModel.add(model.listStatements());
|
||||
WebappDaoFactory wdf = new WebappDaoFactoryJena(ontModel);
|
||||
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement("http://example.com/bob", "http://example.com/hasNose", "http://example.com/nose1");
|
||||
|
||||
wdf.getPropertyInstanceDao().deleteObjectPropertyStatement("http://example.com/bob", "http://example.com/hasNose", "http://example.com/nose1");
|
||||
|
||||
Model expectedModel = (ModelFactory.createDefaultModel()).read(new StringReader(expected), "", "N3");
|
||||
wipeOutModTime(ontModel);
|
||||
//Model resultModel = ModelFactory.createDefaultModel().add(ontModel.listStatements());
|
||||
|
||||
|
||||
boolean same = expectedModel.isIsomorphicWith( ontModel.getBaseModel() );
|
||||
if( ! same ) printModels( expectedModel, ontModel.getBaseModel());
|
||||
Assert.assertTrue( same );
|
||||
|
@ -140,7 +140,7 @@ public class PropertyInstanceDaoJenaTest {
|
|||
void wipeOutModTime(Model model){
|
||||
model.removeAll(null, model.createProperty(VitroVocabulary.MODTIME), null);
|
||||
}
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void testGetAllPossiblePropInstForIndividual() {
|
||||
String n3 = prefixesN3 +
|
||||
|
@ -171,35 +171,35 @@ public class PropertyInstanceDaoJenaTest {
|
|||
"owl:allValuesFrom ex:Organism ] . \n" +
|
||||
"ex:Person rdfs:subClassOf [ a owl:Restriction ; \n" +
|
||||
"owl:onProperty ex:hasSpore ; \n" +
|
||||
"owl:someValuesFrom ex:Spore ] . \n" +
|
||||
"owl:someValuesFrom ex:Spore ] . \n" +
|
||||
"ex:bob a ex:Person ; a ex:Agent . \n";
|
||||
|
||||
|
||||
// The applicable properties for bob should be:
|
||||
// 1. hasMold (values from Mold)
|
||||
// 2. hasSpore (values from Organism)
|
||||
// 3. hasFungus (values from Fungus)
|
||||
|
||||
|
||||
OntModel ontModel = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM));
|
||||
ontModel.read(new StringReader(n3), null, "N3");
|
||||
|
||||
|
||||
WebappDaoFactory wadf = new WebappDaoFactoryJena(ontModel);
|
||||
Assert.assertEquals(4, wadf.getObjectPropertyDao().getAllObjectProperties().size());
|
||||
Assert.assertEquals(6, wadf.getVClassDao().getAllVclasses().size());
|
||||
Assert.assertNotNull(wadf.getIndividualDao().getIndividualByURI("http://example.com/bob"));
|
||||
|
||||
|
||||
Collection<PropertyInstance> pinsts = wadf.getPropertyInstanceDao()
|
||||
.getAllPossiblePropInstForIndividual("http://example.com/bob");
|
||||
|
||||
|
||||
Assert.assertEquals(3, pinsts.size());
|
||||
|
||||
|
||||
Map<String, String> propToRange = new HashMap<String,String>();
|
||||
for (PropertyInstance pi : pinsts) {
|
||||
propToRange.put(pi.getPropertyURI(), pi.getRangeClassURI());
|
||||
}
|
||||
|
||||
|
||||
Assert.assertEquals("http://example.com/Mold", propToRange.get("http://example.com/hasMold"));
|
||||
Assert.assertEquals("http://example.com/Organism", propToRange.get("http://example.com/hasSpore"));
|
||||
Assert.assertEquals("http://example.com/Fungus", propToRange.get("http://example.com/hasFungus"));
|
||||
|
||||
Assert.assertEquals("http://example.com/Fungus", propToRange.get("http://example.com/hasFungus"));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ public class UserAccountsDaoJenaTest extends AbstractTestClass {
|
|||
ps3.setLabel("Role 3");
|
||||
ps3.setForPublic(true);
|
||||
expected.add(ps3);
|
||||
|
||||
|
||||
assertCorrectPermissionSets(expected, dao.getAllPermissionSets());
|
||||
}
|
||||
|
||||
|
|
|
@ -20,47 +20,47 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class VClassDaoTest {
|
||||
|
||||
|
||||
@Test
|
||||
// Test that the VClassDaoJena::updateVClass method will only update the jena model for
|
||||
// Test that the VClassDaoJena::updateVClass method will only update the jena model for
|
||||
// those properties in VClass that have a different value from what is already in the
|
||||
// jena model for that property.
|
||||
//
|
||||
// jena model for that property.
|
||||
//
|
||||
// Specifically, VClass should not remove a statement from the model and then add the
|
||||
// same statement back in. The reason for this is that in vivo the "immutable" properties
|
||||
// are stored in a sub-model and the user-editable properties are stored in a super-model and
|
||||
// all updates are performed against the super-model, so removing and then re-adding
|
||||
// the same statement may result in a change of state (if the statement was in the sub-model
|
||||
// all updates are performed against the super-model, so removing and then re-adding
|
||||
// the same statement may result in a change of state (if the statement was in the sub-model
|
||||
// it will migrate to the super-model) because of the way jena handles additions and
|
||||
// deletions with respect to super and sub models. This migration of statements may cause
|
||||
// undesirable behavior in the vivo/vitro application.
|
||||
|
||||
|
||||
public void modelIsolation(){
|
||||
|
||||
|
||||
// 1. create two models and attach one as a sub-model of the other
|
||||
// 2. populate the sub-model with one statement for each of the 14 properties represented in VClass
|
||||
// 3. save the state of both the sub-model and the super-model
|
||||
// 4. populate a VClass object with the data in the (combined) model and call the updateVClass method
|
||||
// 5. verify that both the sub-model and the super-model are unchanged
|
||||
|
||||
|
||||
String class1URI = "http://test.vivo/AcademicDegree";
|
||||
|
||||
OntModel superModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); // this simulates the user-editable ontology in vivo
|
||||
OntModel subModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); // this simulates the core ontology in vivo
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
String rdfsLabel = "this is the rdfs label";
|
||||
String lang = "en-US";
|
||||
|
||||
|
||||
// populate sub-model
|
||||
OntClass class1 = subModel.createClass(class1URI);
|
||||
|
||||
class1.setLabel(rdfsLabel,lang); //rdfs:label
|
||||
|
||||
class1.setLabel(rdfsLabel,lang); //rdfs:label
|
||||
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.IN_CLASSGROUP), subModel.createResource("http://thisIsTheClassGroupURI"));
|
||||
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.SHORTDEF), subModel.createTypedLiteral("this is the short definition"));
|
||||
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.EXAMPLE_ANNOT), subModel.createTypedLiteral("this is the example - why is this a string?"));
|
||||
|
@ -75,36 +75,36 @@ public class VClassDaoTest {
|
|||
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMDISPLAYVIEWANNOT), subModel.createTypedLiteral("this is the custom display view annotation"));
|
||||
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMSHORTVIEWANNOT), subModel.createTypedLiteral("this is the custom short view annotation"));
|
||||
class1.setPropertyValue(subModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMSEARCHVIEWANNOT), subModel.createTypedLiteral("this is the custom search view annotation"));
|
||||
|
||||
|
||||
|
||||
|
||||
// Save copies of sub-model and super-model
|
||||
|
||||
|
||||
// uncommment the next two lines to debug failures
|
||||
//System.out.println("**Before updating VClass:");
|
||||
//System.out.println("**Before updating VClass:");
|
||||
//printModels(superModel, subModel);
|
||||
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
OntModel origSubModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
OntModel origSubModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
origSubModel.add(subModel);
|
||||
OntModel origSuperModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel origSuperModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
origSuperModel.add(superModel);
|
||||
|
||||
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
// Populate the VClass with the data in the sub-model and then update the combined model
|
||||
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena(superModel);
|
||||
VClassDaoJena vcdj = (VClassDaoJena) wdfj.getVClassDao();
|
||||
VClass vClass = vcdj.getVClassByURI(class1URI); // the VClass will be populated with the
|
||||
// information already in the jena model.
|
||||
|
||||
|
||||
|
||||
|
||||
assertEquals(vClass.getName(), class1.getLabel(lang)); //
|
||||
|
||||
|
||||
vcdj.updateVClass(vClass); // we haven't changed any values here, so
|
||||
|
||||
|
||||
vcdj.updateVClass(vClass); // we haven't changed any values here, so
|
||||
// the models should be unchanged.
|
||||
|
||||
|
||||
// Verify that the sub-model and super-model are both unchanged
|
||||
|
||||
// uncommment the next two lines to debug failures
|
||||
|
@ -112,26 +112,26 @@ public class VClassDaoTest {
|
|||
//printModels(superModel,subModel);
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
|
||||
//modtime affects the diff but we don't care about that difference
|
||||
wipeOutModTime(origSubModel);
|
||||
wipeOutModTime(origSuperModel);
|
||||
wipeOutModTime(subModel);
|
||||
wipeOutModTime(superModel);
|
||||
|
||||
assertTrue(subModel.isIsomorphicWith(origSubModel));
|
||||
assertTrue(superModel.isIsomorphicWith(origSuperModel));
|
||||
|
||||
|
||||
assertTrue(subModel.isIsomorphicWith(origSubModel));
|
||||
assertTrue(superModel.isIsomorphicWith(origSuperModel));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void printModels(OntModel superModel, OntModel subModel) {
|
||||
|
||||
// Detach the submodel for printing to get an accurate
|
||||
// account of what is in each.
|
||||
|
||||
|
||||
superModel.removeSubModel(subModel);
|
||||
|
||||
|
||||
System.out.println("\nThe sub-model has " + subModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------");
|
||||
subModel.writeAll(System.out,"N3",null);
|
||||
|
@ -139,17 +139,17 @@ public class VClassDaoTest {
|
|||
System.out.println("\nThe super-model has " + superModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------");
|
||||
superModel.write(System.out,"N3",null);
|
||||
|
||||
|
||||
superModel.addSubModel(subModel);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wipeOutModTime(Model model){
|
||||
model.removeAll(null, model.createProperty(VitroVocabulary.MODTIME), null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getVClassesForPropertyTest(){
|
||||
String lang = "en-US";
|
||||
|
@ -157,47 +157,47 @@ public class VClassDaoTest {
|
|||
String subClassAURI = "http://example.com/SUB_class_A";
|
||||
String subClassBURI = "http://example.com/SUB_class_B";
|
||||
String propURI = "http://example.com/PROP";
|
||||
|
||||
|
||||
String propNoRangeURI = "http://example.com/PROP_NO_RANGE";
|
||||
|
||||
|
||||
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
|
||||
//Define super class and sub classes
|
||||
|
||||
|
||||
//Define super class and sub classes
|
||||
OntClass superClass = model.createClass( superClassURI );
|
||||
superClass.addLabel("SUPER",lang);
|
||||
superClass.setPropertyValue(model.createProperty(VitroVocabulary.IN_CLASSGROUP), model.createResource("http://thisIsTheClassGroupURI"));
|
||||
superClass.addSuperClass( OWL.Thing );
|
||||
|
||||
|
||||
OntClass subA = model.createClass(subClassAURI);
|
||||
subA.addLabel("subA",lang);
|
||||
subA.setPropertyValue(model.createProperty(VitroVocabulary.IN_CLASSGROUP), model.createResource("http://thisIsTheClassGroupURI"));
|
||||
superClass.addSubClass(subA);
|
||||
|
||||
|
||||
OntClass subB = model.createClass(subClassBURI);
|
||||
subB.addLabel("subB",lang);
|
||||
subB.setPropertyValue(model.createProperty(VitroVocabulary.IN_CLASSGROUP), model.createResource("http://thisIsTheClassGroupURI"));
|
||||
superClass.addSubClass(subB);
|
||||
|
||||
|
||||
//Define property using the super class
|
||||
ObjectProperty prop = model.createObjectProperty( propURI );
|
||||
prop.setLabel("PROP", lang);
|
||||
prop.setRange( superClass );
|
||||
|
||||
|
||||
ObjectProperty propNoRange = model.createObjectProperty( propNoRangeURI );
|
||||
propNoRange.setLabel("PROP_NO_RANGE", lang);
|
||||
|
||||
|
||||
WebappDaoFactoryJena wdfj = new WebappDaoFactoryJena(model);
|
||||
|
||||
|
||||
List<VClass> classesForProp = wdfj.getVClassDao().getVClassesForProperty(propURI, true);
|
||||
assertNotNull( classesForProp );
|
||||
assertEquals(3, classesForProp.size());
|
||||
|
||||
|
||||
List<VClass> classesForPropNoRange = wdfj.getVClassDao().getVClassesForProperty(propNoRangeURI, true);
|
||||
assertNotNull( classesForPropNoRange );
|
||||
assertEquals(0, classesForPropNoRange.size());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ public class VClassGroupCacheTest {
|
|||
|
||||
@Test
|
||||
public void testIsVClassGroupNameChange() {
|
||||
|
||||
|
||||
|
||||
|
||||
//protected static boolean isVClassGroupNameChange(Statement stmt, OntModel jenaOntModel) {
|
||||
|
||||
String rdf =
|
||||
|
||||
String rdf =
|
||||
"core:Summer \n" +
|
||||
" a owl:Class ; \n" +
|
||||
" rdfs:label \"Spring and toast 3\"@en-US ; \n" +
|
||||
|
@ -45,36 +45,36 @@ public class VClassGroupCacheTest {
|
|||
" <http://vitro.mannlib.cornell.edu/ns/vitro/role#public> ; \n" +
|
||||
" vitro:shortDef \"sfsfe\"^^xsd:string ; \n" +
|
||||
" owl:equivalentClass core:Summer . ";
|
||||
|
||||
|
||||
OntModel om = ModelFactory.createOntologyModel();
|
||||
om.read( new StringReader( prefixes + rdf) , null , "N3");
|
||||
|
||||
|
||||
Statement stmt = ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource("http://vivoweb.org/ontology/core#Summer"),
|
||||
RDFS.label,
|
||||
ResourceFactory.createPlainLiteral("some old label"));
|
||||
|
||||
|
||||
boolean isNameChange = VClassGroupCache.isClassNameChange(stmt, om);
|
||||
Assert.assertTrue("Expected it to be a name change but it wasn't.", isNameChange);
|
||||
|
||||
|
||||
stmt = ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource("http://vivoweb.org/ontology/core#bogus"),
|
||||
ResourceFactory.createProperty("http://example.com/nonLabelProperty"),
|
||||
ResourceFactory.createPlainLiteral("some old label"));
|
||||
|
||||
|
||||
boolean notNameChange = ! VClassGroupCache.isClassNameChange(stmt, om);
|
||||
Assert.assertTrue("Expected it to NOT be a name change but it was.", notNameChange);
|
||||
|
||||
|
||||
stmt = ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource("http://vivoweb.org/ontology/core#bogus"),
|
||||
RDFS.label,
|
||||
ResourceFactory.createPlainLiteral("some old label"));
|
||||
|
||||
|
||||
notNameChange = ! VClassGroupCache.isClassNameChange(stmt, om);
|
||||
Assert.assertTrue("Expected it to NOT be a name change but it was.", notNameChange);
|
||||
}
|
||||
|
||||
static final String prefixes =
|
||||
static final String prefixes =
|
||||
"@prefix dc: <http://purl.org/dc/elements/1.1/> . \n" +
|
||||
"@prefix pvs: <http://vivoweb.org/ontology/provenance-support#> . \n" +
|
||||
"@prefix geo: <http://aims.fao.org/aos/geopolitical.owl#> . \n" +
|
||||
|
@ -97,6 +97,6 @@ public class VClassGroupCacheTest {
|
|||
"@prefix dcelem: <http://purl.org/dc/elements/1.1/> . \n" +
|
||||
"@prefix ero: <http://purl.obolibrary.org/obo/> . \n" +
|
||||
" \n" ;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -44,15 +44,15 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class VClassJenaTest {
|
||||
|
||||
|
||||
@Test
|
||||
// NIHVIVO-1157 introduced VClassJena.java, a lazy-loading version of VClass.java.
|
||||
// NIHVIVO-1157 introduced VClassJena.java, a lazy-loading version of VClass.java.
|
||||
// Per instructions from Brian L., this test tests that for one randomly selected Class,
|
||||
// the getter methods in VClassJena return the same values as would have been
|
||||
// returned by the pre-NIHVIVO-1157 VClass (which would have been set by the
|
||||
|
@ -62,27 +62,27 @@ public class VClassJenaTest {
|
|||
// maybe more stable) if the values returned by the VClassJena getter methods
|
||||
// are tested against hard-coded values (which could be set now based on the
|
||||
// model code)
|
||||
|
||||
|
||||
public void correctValues(){
|
||||
|
||||
|
||||
// 1. create a model and populate it with the data for one class
|
||||
// 2. retrieve the OntClass for the target class by URI
|
||||
// 3. populate a VClass instance from the OntClass instance, as it would have been
|
||||
// 3. populate a VClass instance from the OntClass instance, as it would have been
|
||||
// populated pre-NIHVIVO-1157 (with the deleted vClassWebappFromOntClass, copied here)
|
||||
// 4. populate a VClassJena instance as is done with the current application code
|
||||
// 5. verify that the getter methods on the VClassJena and VClass instances return the same values
|
||||
|
||||
|
||||
String class1URI = "http://test.vivo/AcademicDegree";
|
||||
|
||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
String rdfsLabel = "this is the rdfs label";
|
||||
String lang = "en-US";
|
||||
|
||||
|
||||
// populate sub-model
|
||||
OntClass class1 = ontModel.createClass(class1URI);
|
||||
|
||||
class1.setLabel(rdfsLabel,lang); //rdfs:label
|
||||
|
||||
class1.setLabel(rdfsLabel,lang); //rdfs:label
|
||||
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.IN_CLASSGROUP), ontModel.createResource("http://thisIsTheClassGroupURI"));
|
||||
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.SHORTDEF), ontModel.createTypedLiteral("this is the short definition"));
|
||||
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.EXAMPLE_ANNOT), ontModel.createTypedLiteral("this is the example"));
|
||||
|
@ -97,51 +97,51 @@ public class VClassJenaTest {
|
|||
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMDISPLAYVIEWANNOT), ontModel.createTypedLiteral("this is the custom display view annotation"));
|
||||
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMSHORTVIEWANNOT), ontModel.createTypedLiteral("this is the custom short view annotation"));
|
||||
class1.setPropertyValue(ontModel.createProperty(VitroVocabulary.PROPERTY_CUSTOMSEARCHVIEWANNOT), ontModel.createTypedLiteral("this is the custom search view annotation"));
|
||||
|
||||
|
||||
WebappDaoFactoryJena wadf = new WebappDaoFactoryJena(ontModel);
|
||||
|
||||
// Populate a VClass instance...old style
|
||||
|
||||
VClass vClass = vClassWebappFromOntClass(class1,wadf);
|
||||
|
||||
// Populate a VClassJena instance...modern style
|
||||
|
||||
VClassJena vClassJena = new VClassJena(class1, wadf);
|
||||
|
||||
|
||||
// Check that the getters from the VClass and the VClassJena return the same values
|
||||
|
||||
Assert.assertEquals(vClassJena.getName(), vClass.getName());
|
||||
Assert.assertEquals(vClassJena.getLocalNameWithPrefix(), vClass.getLocalNameWithPrefix());
|
||||
|
||||
Assert.assertEquals(vClassJena.getPickListName(), vClass.getPickListName());
|
||||
Assert.assertEquals(vClassJena.getExample(), vClass.getExample());
|
||||
Assert.assertEquals(vClassJena.getDescription(), vClass.getDescription());
|
||||
Assert.assertEquals(vClassJena.getShortDef(), vClass.getShortDef());
|
||||
Assert.assertEquals(vClassJena.getDisplayRank(), vClass.getDisplayRank());
|
||||
Assert.assertEquals(vClassJena.getGroupURI(), vClass.getGroupURI());
|
||||
Assert.assertEquals(vClassJena.getCustomEntryForm(), vClass.getCustomEntryForm());
|
||||
Assert.assertEquals(vClassJena.getCustomShortView(), vClass.getCustomShortView());
|
||||
Assert.assertEquals(vClassJena.getCustomSearchView(), vClass.getCustomSearchView());
|
||||
Assert.assertEquals(vClassJena.getSearchBoost(), vClass.getSearchBoost());
|
||||
|
||||
WebappDaoFactoryJena wadf = new WebappDaoFactoryJena(ontModel);
|
||||
|
||||
// Populate a VClass instance...old style
|
||||
|
||||
VClass vClass = vClassWebappFromOntClass(class1,wadf);
|
||||
|
||||
// Populate a VClassJena instance...modern style
|
||||
|
||||
VClassJena vClassJena = new VClassJena(class1, wadf);
|
||||
|
||||
|
||||
// Check that the getters from the VClass and the VClassJena return the same values
|
||||
|
||||
Assert.assertEquals(vClassJena.getName(), vClass.getName());
|
||||
Assert.assertEquals(vClassJena.getLocalNameWithPrefix(), vClass.getLocalNameWithPrefix());
|
||||
|
||||
Assert.assertEquals(vClassJena.getPickListName(), vClass.getPickListName());
|
||||
Assert.assertEquals(vClassJena.getExample(), vClass.getExample());
|
||||
Assert.assertEquals(vClassJena.getDescription(), vClass.getDescription());
|
||||
Assert.assertEquals(vClassJena.getShortDef(), vClass.getShortDef());
|
||||
Assert.assertEquals(vClassJena.getDisplayRank(), vClass.getDisplayRank());
|
||||
Assert.assertEquals(vClassJena.getGroupURI(), vClass.getGroupURI());
|
||||
Assert.assertEquals(vClassJena.getCustomEntryForm(), vClass.getCustomEntryForm());
|
||||
Assert.assertEquals(vClassJena.getCustomShortView(), vClass.getCustomShortView());
|
||||
Assert.assertEquals(vClassJena.getCustomSearchView(), vClass.getCustomSearchView());
|
||||
Assert.assertEquals(vClassJena.getSearchBoost(), vClass.getSearchBoost());
|
||||
Assert.assertEquals(vClassJena.getHiddenFromDisplayBelowRoleLevel(), vClass.getHiddenFromDisplayBelowRoleLevel());
|
||||
Assert.assertEquals(vClassJena.getProhibitedFromUpdateBelowRoleLevel(), vClass.getProhibitedFromUpdateBelowRoleLevel());
|
||||
Assert.assertEquals(vClassJena.getHiddenFromPublishBelowRoleLevel(), vClass.getHiddenFromPublishBelowRoleLevel());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModels(OntModel ontModel) {
|
||||
|
||||
|
||||
System.out.println("\nThe model has " + ontModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------");
|
||||
ontModel.writeAll(System.out,"N3",null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// The following class and methods are pre-NIHVIVO-1157 code for
|
||||
// populating a VClass. Original comments included.
|
||||
|
||||
|
@ -156,12 +156,12 @@ public class VClassJenaTest {
|
|||
protected AnnotationProperty LOCAL_PROPERTY_CUSTOMDISPLAYVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMDISPLAYVIEWANNOT);
|
||||
protected AnnotationProperty LOCAL_PROPERTY_CUSTOMSHORTVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMSHORTVIEWANNOT);
|
||||
protected AnnotationProperty LOCAL_PROPERTY_CUSTOMSEARCHVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMSEARCHVIEWANNOT);
|
||||
protected AnnotationProperty LOCAL_HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
|
||||
protected AnnotationProperty LOCAL_PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
|
||||
protected AnnotationProperty LOCAL_HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
|
||||
protected AnnotationProperty LOCAL_HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
|
||||
protected AnnotationProperty LOCAL_PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
|
||||
protected AnnotationProperty LOCAL_HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
|
||||
protected AnnotationProperty LOCAL_IN_CLASSGROUP = _constModel.createAnnotationProperty(VitroVocabulary.IN_CLASSGROUP);
|
||||
|
||||
|
||||
|
||||
|
||||
private VClass vClassWebappFromOntClass(OntClass cls, WebappDaoFactoryJena wadf) {
|
||||
VClass vcw = new VClass();
|
||||
cls.getModel().enterCriticalSection(Lock.READ);
|
||||
|
@ -187,7 +187,7 @@ public class VClassJenaTest {
|
|||
} catch (Exception e) {
|
||||
System.out.println("error retrieving vitro:inClassGroup property value for "+cls.getURI());
|
||||
}
|
||||
|
||||
|
||||
vcw.setShortDef(getPropertyStringValue(cls,LOCAL_SHORTDEF));
|
||||
vcw.setExample(getPropertyStringValue(cls,LOCAL_EXAMPLE_ANNOT));
|
||||
vcw.setDescription(getPropertyStringValue(cls,LOCAL_DESCRIPTION_ANNOT));
|
||||
|
@ -198,7 +198,7 @@ public class VClassJenaTest {
|
|||
vcw.setCustomShortView(getPropertyStringValue(cls,LOCAL_PROPERTY_CUSTOMSHORTVIEWANNOT));
|
||||
vcw.setCustomSearchView(getPropertyStringValue(cls,LOCAL_PROPERTY_CUSTOMSEARCHVIEWANNOT));
|
||||
vcw.setSearchBoost(getPropertyFloatValue(cls,LOCAL_SEARCH_BOOST_ANNOT));
|
||||
|
||||
|
||||
//There might be multiple HIDDEN_FROM_EDIT_DISPLAY_ANNOT properties, only use the highest
|
||||
StmtIterator it = cls.listProperties(LOCAL_HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
|
||||
BaseResourceBean.RoleLevel hiddenRoleLevel = null;
|
||||
|
@ -209,13 +209,13 @@ public class VClassJenaTest {
|
|||
Resource res = (Resource)obj.as(Resource.class);
|
||||
if( res != null && res.getURI() != null ){
|
||||
BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI());
|
||||
if( roleFromModel != null &&
|
||||
if( roleFromModel != null &&
|
||||
(hiddenRoleLevel == null || roleFromModel.compareTo(hiddenRoleLevel) > 0 )){
|
||||
hiddenRoleLevel = roleFromModel;
|
||||
hiddenRoleLevel = roleFromModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vcw.setHiddenFromDisplayBelowRoleLevel(hiddenRoleLevel);//this might get set to null
|
||||
|
||||
//There might be multiple PROHIBITED_FROM_UPDATE_DISPLAY_ANNOT properties, only use the highest
|
||||
|
@ -228,15 +228,15 @@ public class VClassJenaTest {
|
|||
Resource res = (Resource)obj.as(Resource.class);
|
||||
if( res != null && res.getURI() != null ){
|
||||
BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI());
|
||||
if( roleFromModel != null &&
|
||||
if( roleFromModel != null &&
|
||||
(prohibitedRoleLevel == null || roleFromModel.compareTo(prohibitedRoleLevel) > 0 )){
|
||||
prohibitedRoleLevel = roleFromModel;
|
||||
prohibitedRoleLevel = roleFromModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vcw.setProhibitedFromUpdateBelowRoleLevel(prohibitedRoleLevel);//this might get set to null
|
||||
|
||||
|
||||
//There might be multiple LOCAL_HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT properties, only use the highest
|
||||
it = cls.listProperties(LOCAL_HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
|
||||
BaseResourceBean.RoleLevel publishRoleLevel = null;
|
||||
|
@ -247,13 +247,13 @@ public class VClassJenaTest {
|
|||
Resource res = (Resource)obj.as(Resource.class);
|
||||
if( res != null && res.getURI() != null ){
|
||||
BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI());
|
||||
if( roleFromModel != null &&
|
||||
if( roleFromModel != null &&
|
||||
(publishRoleLevel == null || roleFromModel.compareTo(publishRoleLevel) > 0 )){
|
||||
publishRoleLevel = roleFromModel;
|
||||
publishRoleLevel = roleFromModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vcw.setHiddenFromPublishBelowRoleLevel(publishRoleLevel);//this might get set to null
|
||||
|
||||
} finally {
|
||||
|
@ -262,12 +262,12 @@ public class VClassJenaTest {
|
|||
return vcw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getLabelForClass(OntClass cls,boolean withPrefix,boolean forPickList,WebappDaoFactoryJena wadf) {
|
||||
cls.getModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
if (cls.isAnon()) {
|
||||
if (cls.isRestriction()) {
|
||||
if (cls.isRestriction()) {
|
||||
Restriction rest = cls.asRestriction();
|
||||
OntProperty onProperty = rest.getOnProperty();
|
||||
String labelStr = "restriction on " + getLabelOrId(onProperty) + ": ";
|
||||
|
@ -282,7 +282,7 @@ public class VClassJenaTest {
|
|||
fillerRes = svfRest.getSomeValuesFrom();
|
||||
labelStr += "some values from ";
|
||||
}
|
||||
if (fillerRes.canAs(OntClass.class)) {
|
||||
if (fillerRes.canAs(OntClass.class)) {
|
||||
OntClass avf = (OntClass) fillerRes.as(OntClass.class);
|
||||
labelStr += getLabelForClass(avf,withPrefix,forPickList,wadf);
|
||||
} else {
|
||||
|
@ -291,7 +291,7 @@ public class VClassJenaTest {
|
|||
} catch (Exception e) {
|
||||
labelStr += "???";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (rest.isHasValueRestriction()) {
|
||||
HasValueRestriction hvRest = rest.asHasValueRestriction();
|
||||
labelStr += "has value ";
|
||||
|
@ -300,7 +300,7 @@ public class VClassJenaTest {
|
|||
if (fillerNode.isResource()) {
|
||||
labelStr += getLabelOrId((OntResource)fillerNode.as(OntResource.class));
|
||||
} else {
|
||||
labelStr += ((Literal) fillerNode.as(Literal.class)).getLexicalForm();
|
||||
labelStr += ((Literal) fillerNode.as(Literal.class)).getLexicalForm();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
labelStr += "???";
|
||||
|
@ -356,10 +356,10 @@ public class VClassJenaTest {
|
|||
OntologyDao oDao=wadf.getOntologyDao();
|
||||
Ontology o = (Ontology)oDao.getOntologyByURI(cls.getNameSpace());
|
||||
if (o!=null) {
|
||||
if (withPrefix) {
|
||||
if (withPrefix) {
|
||||
return(o.getPrefix()==null?(o.getName()==null?"unspec:"+getLabelOrId(cls):o.getName()+":"+getLabelOrId(cls)):o.getPrefix()+":"+getLabelOrId(cls));
|
||||
} else {
|
||||
return(getLabelOrId(cls)+(o.getPrefix()==null?(o.getName()==null?" (unspec)":" ("+o.getName()+")"):" ("+o.getPrefix()+")"));
|
||||
return(getLabelOrId(cls)+(o.getPrefix()==null?(o.getName()==null?" (unspec)":" ("+o.getName()+")"):" ("+o.getPrefix()+")"));
|
||||
}
|
||||
} else {
|
||||
return getLabelOrId(cls);
|
||||
|
@ -373,7 +373,7 @@ public class VClassJenaTest {
|
|||
cls.getModel().leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String getLabelOrId(OntResource r) {
|
||||
String label = null;
|
||||
r.getOntModel().enterCriticalSection(Lock.READ);
|
||||
|
@ -386,45 +386,45 @@ public class VClassJenaTest {
|
|||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private final boolean ALSO_TRY_NO_LANG = true;
|
||||
/**
|
||||
* works through list of PREFERRED_LANGUAGES to find an appropriate
|
||||
* label, or NULL if not found.
|
||||
* works through list of PREFERRED_LANGUAGES to find an appropriate
|
||||
* label, or NULL if not found.
|
||||
*/
|
||||
|
||||
|
||||
protected String getLabel(OntResource r){
|
||||
String label = null;
|
||||
r.getOntModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
try {
|
||||
// try rdfs:label with preferred languages
|
||||
label = tryPropertyForPreferredLanguages( r, RDFS.label, ALSO_TRY_NO_LANG );
|
||||
|
||||
|
||||
// try vitro:label with preferred languages
|
||||
if ( label == null ) {
|
||||
label = tryPropertyForPreferredLanguages( r, r.getModel().getProperty(VitroVocabulary.label), ALSO_TRY_NO_LANG );
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
r.getOntModel().leaveCriticalSection();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
private String tryPropertyForPreferredLanguages( OntResource r, Property p, boolean alsoTryNoLang ) {
|
||||
String label = null;
|
||||
List<RDFNode> labels = (List<RDFNode>) r.listPropertyValues(p).toList();
|
||||
|
||||
|
||||
String lang = "en-US";
|
||||
label = getLabel2(lang,labels);
|
||||
|
||||
|
||||
if ( label == null && alsoTryNoLang ) {
|
||||
label = getLabel2("", labels);
|
||||
}
|
||||
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
private String getLabel2(String lang, List<RDFNode>labelList) {
|
||||
for (RDFNode label : labelList) {
|
||||
if (label.isLiteral()) {
|
||||
|
@ -440,30 +440,30 @@ public class VClassJenaTest {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the local name, bnode or URI of the resource.
|
||||
* Get the local name, bnode or URI of the resource.
|
||||
*/
|
||||
protected String getLocalNameOrId(OntResource r){
|
||||
String label = null;
|
||||
r.getOntModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
try {
|
||||
String localName = r.getLocalName();
|
||||
if (localName != null) {
|
||||
label = localName;
|
||||
} else if (r.isAnon()) {
|
||||
label = r.getId().toString();
|
||||
} else {
|
||||
label = r.getURI();
|
||||
}
|
||||
label = r.getURI();
|
||||
}
|
||||
} finally {
|
||||
r.getOntModel().leaveCriticalSection();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected String getPropertyStringValue(OntResource res, Property dataprop) {
|
||||
if (dataprop != null) {
|
||||
try {
|
||||
|
@ -483,11 +483,11 @@ public class VClassJenaTest {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected int getPropertyNonNegativeIntValue(OntResource res, Property dataprop) {
|
||||
|
||||
|
||||
if (dataprop != null) {
|
||||
|
||||
|
||||
try {
|
||||
return ((Literal)res.getPropertyValue(dataprop)).getInt();
|
||||
} catch (Exception e) {
|
||||
|
@ -498,7 +498,7 @@ public class VClassJenaTest {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected Float getPropertyFloatValue(OntResource res, Property prop){
|
||||
if( prop != null ){
|
||||
try{
|
||||
|
@ -509,11 +509,11 @@ public class VClassJenaTest {
|
|||
}else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public synchronized boolean isBooleanClassExpression(OntClass cls) {
|
||||
return (cls.isComplementClass() || cls.isIntersectionClass() || cls.isUnionClass());
|
||||
}
|
||||
|
||||
|
||||
protected String getClassURIStr(Resource cls) {
|
||||
if (cls.isAnon()) {
|
||||
return VitroVocabulary.PSEUDO_BNODE_NS+cls.getId().toString();
|
||||
|
|
|
@ -21,104 +21,104 @@ import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
|||
public class ProhibitedFromSearchTest {
|
||||
String SEARCH_CONFIG_URI = DisplayVocabulary.SEARCH_INDEX_URI;
|
||||
String TEST_CLASS = "http://vivoweb.org/ontology/test/bogus#Class5";
|
||||
|
||||
String n3 =
|
||||
|
||||
String n3 =
|
||||
"@prefix : <http://vitro.mannlib.cornell.edu/ns/vitroDisplay#> . \n" +
|
||||
"@prefix vivo: <http://vivoweb.org/ontology/test/bogus#> . \n" +
|
||||
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . \n"+
|
||||
"<"+SEARCH_CONFIG_URI+"> rdf:type :ProhibitedFromSearch ;\n" +
|
||||
"<"+SEARCH_CONFIG_URI+"> rdf:type :ProhibitedFromSearch ;\n" +
|
||||
" <" + DisplayVocabulary.EXCLUDE_CLASS.getURI() + "> vivo:Class2, vivo:Class3, vivo:Class4, <"+TEST_CLASS+"> .\n" ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testBuildingProhibited(){
|
||||
Model r = ModelFactory.createDefaultModel().read(new StringReader(n3), null, "N3");
|
||||
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
m.add( r.listStatements() );
|
||||
|
||||
Assert.assertTrue(m.size() > 4);
|
||||
|
||||
Assert.assertTrue(m.size() > 4);
|
||||
ProhibitedFromSearch pfs = new ProhibitedFromSearch( SEARCH_CONFIG_URI , m);
|
||||
Assert.assertNotNull(pfs.prohibitedClasses);
|
||||
Assert.assertTrue(pfs.prohibitedClasses.size() == 4);
|
||||
Assert.assertTrue(pfs.isClassProhibitedFromSearch(TEST_CLASS));
|
||||
Assert.assertTrue(!pfs.isClassProhibitedFromSearch("http://someOtherClass.com/test"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNotFound(){
|
||||
Model r = ModelFactory.createDefaultModel().read(new StringReader(n3), null, "N3");
|
||||
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
m.add( r.listStatements() );
|
||||
|
||||
Assert.assertTrue(m.size() > 4);
|
||||
|
||||
Assert.assertTrue(m.size() > 4);
|
||||
ProhibitedFromSearch pfs = new ProhibitedFromSearch( "http://NotFound.com/inModel", m);
|
||||
Assert.assertNotNull(pfs.prohibitedClasses);
|
||||
Assert.assertTrue(pfs.prohibitedClasses.size() == 0);
|
||||
Assert.assertTrue(!pfs.isClassProhibitedFromSearch(TEST_CLASS));
|
||||
Assert.assertTrue(!pfs.isClassProhibitedFromSearch("http://someOtherClass.com/test"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testListener(){
|
||||
Model r = ModelFactory.createDefaultModel().read(new StringReader(n3), null, "N3");
|
||||
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
m.add( r.listStatements() );
|
||||
m.add( r.listStatements() );
|
||||
Assert.assertTrue(m.size() > 4);
|
||||
|
||||
|
||||
ProhibitedFromSearch pfs = new ProhibitedFromSearch( SEARCH_CONFIG_URI , m);
|
||||
Assert.assertTrue(pfs.prohibitedClasses.size() == 4);
|
||||
|
||||
|
||||
Resource bougsClass3 = ResourceFactory.createResource("http://example.com/bougsClass3");
|
||||
Resource searchConfig = ResourceFactory.createResource(SEARCH_CONFIG_URI);
|
||||
Resource searchConfig = ResourceFactory.createResource(SEARCH_CONFIG_URI);
|
||||
m.add(searchConfig, DisplayVocabulary.EXCLUDE_CLASS, bougsClass3);
|
||||
Assert.assertEquals(5, pfs.prohibitedClasses.size());
|
||||
|
||||
|
||||
m.remove(searchConfig, DisplayVocabulary.EXCLUDE_CLASS, bougsClass3);
|
||||
Assert.assertEquals(4, pfs.prohibitedClasses.size());
|
||||
|
||||
|
||||
Resource bougsClass4 = ResourceFactory.createResource("http://vivoweb.org/ontology/test/bogus#Class4");
|
||||
m.remove(searchConfig, DisplayVocabulary.EXCLUDE_CLASS, bougsClass4);
|
||||
Assert.assertEquals(3, pfs.prohibitedClasses.size());
|
||||
Assert.assertEquals(3, pfs.prohibitedClasses.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testListenerAbnormal(){
|
||||
Model r = ModelFactory.createDefaultModel().read(new StringReader(n3), null, "N3");
|
||||
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
m.add( r.listStatements() );
|
||||
m.add( r.listStatements() );
|
||||
Assert.assertTrue(m.size() > 4);
|
||||
|
||||
|
||||
ProhibitedFromSearch pfs = new ProhibitedFromSearch( SEARCH_CONFIG_URI , m);
|
||||
Assert.assertTrue(pfs.prohibitedClasses.size() == 4);
|
||||
int originalSize = pfs.prohibitedClasses.size();
|
||||
|
||||
|
||||
Literal bogusLiteral = ResourceFactory.createPlainLiteral("some bogus literal");
|
||||
Resource searchConfig = ResourceFactory.createResource(SEARCH_CONFIG_URI);
|
||||
Resource searchConfig = ResourceFactory.createResource(SEARCH_CONFIG_URI);
|
||||
m.add(searchConfig, DisplayVocabulary.EXCLUDE_CLASS, bogusLiteral);
|
||||
Assert.assertEquals(originalSize, pfs.prohibitedClasses.size());
|
||||
Assert.assertEquals(originalSize, pfs.prohibitedClasses.size());
|
||||
m.remove(searchConfig, DisplayVocabulary.EXCLUDE_CLASS, bogusLiteral);
|
||||
Assert.assertEquals(originalSize, pfs.prohibitedClasses.size());
|
||||
|
||||
|
||||
Resource anonRes = ResourceFactory.createResource();
|
||||
m.remove(searchConfig, DisplayVocabulary.EXCLUDE_CLASS, anonRes);
|
||||
Assert.assertEquals(originalSize, pfs.prohibitedClasses.size());
|
||||
Assert.assertEquals(originalSize, pfs.prohibitedClasses.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPrimaryIndex(){
|
||||
String primaryIndexN3 =
|
||||
public void testPrimaryIndex(){
|
||||
String primaryIndexN3 =
|
||||
"<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#SearchIndex>" +
|
||||
"<http://vitro.mannlib.cornell.edu/ontologies/display/1.1#excludeClass>" +
|
||||
"<http://vivoweb.org/ontology/core#NonAcademic> . ";
|
||||
|
||||
"<http://vivoweb.org/ontology/core#NonAcademic> . ";
|
||||
|
||||
Model r = ModelFactory.createDefaultModel().read(new StringReader(primaryIndexN3), null, "N3");
|
||||
OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
m.add( r.listStatements() );
|
||||
|
||||
Assert.assertTrue(m.size() == 1);
|
||||
|
||||
Assert.assertTrue(m.size() == 1);
|
||||
ProhibitedFromSearch pfs = new ProhibitedFromSearch( DisplayVocabulary.SEARCH_INDEX_URI, m);
|
||||
Assert.assertNotNull(pfs.prohibitedClasses);
|
||||
Assert.assertEquals(1, pfs.prohibitedClasses.size() );
|
||||
|
|
|
@ -106,19 +106,19 @@ public class EditLiteralTest {
|
|||
Assert.assertFalse( EditLiteral.equalLiterals(
|
||||
new EditLiteral("dog", (String)"http://someUri", (String)null ),
|
||||
new EditLiteral("catFood", (String)"http://someUri", (String)null )
|
||||
));
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testBug2(){
|
||||
|
||||
|
||||
Literal a2 = new EditLiteral("<ul><li>Stephen G. Yusem is the senior partner of High, Swartz, Roberts & Seidel in Norristown, Pennsylvania. <br /></li><li>He has been certified as a mediator for the United States District Court for the Eastern District of Pennsylvania since 1991. <br /></li><li>He is a Fellow of the College of Commercial Arbitrators, a member of the Chartered Institute of Arbitrators, a panelist on the CPR Roster of Distinguished Neutrals and a past director of the Commercial Section of the Association for Conflict Resolution. <br /></li><li>He co-chairs the Arbitration Committee of the Dispute Resolution Section of the American Bar Association and is a former member of the Arbitration Faculty of the American Arbitration Association. <br /></li><li>He is a past president of the Montgomery County (PA) Bar Association and was Founding President of the Montgomery County Bar Foundation. He co-teaches Dispute Resolution: Negotiation, Mediation and Arbitration in the fall semester.</li></ul>",
|
||||
"http://www.w3.org/2001/XMLSchema#string","");
|
||||
Literal b2 = new EditLiteral("<ul><li>Stephen G. Yusem is the senior partner of High, Swartz, Roberts & Seidel in Norristown, Pennsylvania. <br /></li><li>He has been certified as a mediator for the United States District Court for the Eastern District of Pennsylvania since 1991. <br /></li></ul>",
|
||||
"http://www.w3.org/2001/XMLSchema#string",null);
|
||||
Assert.assertFalse( EditLiteral.equalLiterals( a2, b2 ) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,25 +20,25 @@ public class EditN3UtilsTest {
|
|||
public void testStripInvalidXMLChars() {
|
||||
Model m = ModelFactory.createDefaultModel();
|
||||
String containsInvalidXMLChars = "Blah \u0001blah \u0002blah\uDDDD";
|
||||
String clean = "Blah blah blah";
|
||||
|
||||
String clean = "Blah blah blah";
|
||||
|
||||
// add a statement with the literal incompatible with XML to model m
|
||||
m.add(m.createResource(), RDFS.label, containsInvalidXMLChars);
|
||||
|
||||
|
||||
Assert.assertFalse(isSerializableAsXML(m));
|
||||
|
||||
|
||||
String stripped = N3EditUtils.stripInvalidXMLChars(
|
||||
containsInvalidXMLChars);
|
||||
Assert.assertEquals(clean, stripped);
|
||||
|
||||
|
||||
// clear the model of any statements
|
||||
m.removeAll();
|
||||
// add a statement with a literal that has been stripped of bad chars
|
||||
m.add(m.createResource(), RDFS.label, stripped);
|
||||
|
||||
Assert.assertTrue(isSerializableAsXML(m));
|
||||
|
||||
Assert.assertTrue(isSerializableAsXML(m));
|
||||
}
|
||||
|
||||
|
||||
private boolean isSerializableAsXML(Model m) {
|
||||
try {
|
||||
NullOutputStream nullStream = new NullOutputStream();
|
||||
|
@ -48,5 +48,5 @@ public class EditN3UtilsTest {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,28 +18,28 @@ public class BasicValidationVTwoTest {
|
|||
String res;
|
||||
res = bv.validate("httpUrl", "http://example.com/index");
|
||||
Assert.assertEquals(res, BasicValidationVTwo.SUCCESS);
|
||||
|
||||
|
||||
res = bv.validate("httpUrl", "http://example.com/index?bogus=skjd%20skljd&something=sdkf");
|
||||
Assert.assertEquals(res, BasicValidationVTwo.SUCCESS);
|
||||
|
||||
|
||||
res = bv.validate("httpUrl", "http://example.com/index#2.23?bogus=skjd%20skljd&something=sdkf");
|
||||
Assert.assertEquals(res, BasicValidationVTwo.SUCCESS);
|
||||
Assert.assertEquals(res, BasicValidationVTwo.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testEmptyValidate(){
|
||||
BasicValidationVTwo bv = new BasicValidationVTwo(Collections.EMPTY_MAP);
|
||||
|
||||
BasicValidationVTwo bv = new BasicValidationVTwo(Collections.EMPTY_MAP);
|
||||
|
||||
Assert.assertEquals(
|
||||
bv.validate("nonempty", null)
|
||||
, BasicValidationVTwo.REQUIRED_FIELD_EMPTY_MSG);
|
||||
|
||||
|
||||
|
||||
Assert.assertEquals(
|
||||
bv.validate("nonempty", "")
|
||||
, BasicValidationVTwo.REQUIRED_FIELD_EMPTY_MSG);
|
||||
|
||||
|
||||
Assert.assertEquals(
|
||||
bv.validate("nonempty", "some value")
|
||||
, BasicValidationVTwo.SUCCESS);
|
||||
|
|
|
@ -19,18 +19,18 @@ public class EditConfigurationUtilsTest {
|
|||
public void testGetEditKey() {
|
||||
HttpServletRequestStub req = new HttpServletRequestStub();
|
||||
req.addParameter("datapropKey", "2343");
|
||||
|
||||
|
||||
Integer hash = EditConfigurationUtils.getDataHash(new VitroRequest(req));
|
||||
Assert.assertNotNull(hash);
|
||||
Assert.assertEquals(new Integer(2343), hash);
|
||||
|
||||
|
||||
req = new HttpServletRequestStub();
|
||||
|
||||
|
||||
|
||||
req = new HttpServletRequestStub();
|
||||
|
||||
hash = EditConfigurationUtils.getDataHash(new VitroRequest(req));
|
||||
Assert.assertNull( hash);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,26 +22,26 @@ import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
|||
|
||||
public class EditN3GeneratorVTwoTest {
|
||||
static EditN3GeneratorVTwo gen = new EditN3GeneratorVTwo();
|
||||
|
||||
|
||||
@Test
|
||||
public void testVarAtEndOfString(){
|
||||
public void testVarAtEndOfString(){
|
||||
String result = gen.subInNonBracketedURIS("newRes", "<http://someuri.com/n23", "?newRes");
|
||||
Assert.assertEquals("<http://someuri.com/n23", result);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNullTarget(){
|
||||
List<String> targets = Arrays.asList("?var",null,null,"?var");
|
||||
|
||||
Map<String,List<String>> keyToValues = new HashMap<String,List<String>>();
|
||||
List<String> targets = Arrays.asList("?var",null,null,"?var");
|
||||
|
||||
Map<String,List<String>> keyToValues = new HashMap<String,List<String>>();
|
||||
keyToValues.put("var", Arrays.asList("ABC"));
|
||||
keyToValues.put("var2", Arrays.asList((String)null));
|
||||
keyToValues.put("var2", Arrays.asList((String)null));
|
||||
/* test for exception */
|
||||
gen.subInMultiUris(null, targets);
|
||||
gen.subInMultiUris(keyToValues, null);
|
||||
gen.subInMultiUris(keyToValues, targets);
|
||||
|
||||
Map<String,List<Literal>> keyToLiterals = new HashMap<String,List<Literal>>();
|
||||
|
||||
Map<String,List<Literal>> keyToLiterals = new HashMap<String,List<Literal>>();
|
||||
keyToLiterals.put("var", Arrays.asList( ResourceFactory.createTypedLiteral("String")));
|
||||
keyToLiterals.put("var2", Arrays.asList( (Literal)null));
|
||||
/* test for exception */
|
||||
|
@ -49,81 +49,81 @@ public class EditN3GeneratorVTwoTest {
|
|||
gen.subInMultiLiterals(keyToLiterals, null);
|
||||
gen.subInMultiLiterals(null, targets);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testPunctAfterVarName(){
|
||||
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,");
|
||||
|
||||
Map<String,List<String>> keyToValues = new HashMap<String,List<String>>();
|
||||
public void testPunctAfterVarName(){
|
||||
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,");
|
||||
|
||||
Map<String,List<String>> keyToValues = new HashMap<String,List<String>>();
|
||||
keyToValues.put("var", Arrays.asList("ABC"));
|
||||
|
||||
|
||||
gen.subInMultiUris(keyToValues, targets);
|
||||
Assert.assertNotNull(targets);
|
||||
Assert.assertEquals(4,targets.size());
|
||||
|
||||
|
||||
Assert.assertEquals("<ABC>.", targets.get(0));
|
||||
Assert.assertEquals("<ABC>;", targets.get(1));
|
||||
Assert.assertEquals("<ABC>]", targets.get(2));
|
||||
Assert.assertEquals("<ABC>,", targets.get(3));
|
||||
Assert.assertEquals("<ABC>,", targets.get(3));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPunctAfterVarNameForLiterals(){
|
||||
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,");
|
||||
|
||||
Map keyToValues = new HashMap();
|
||||
public void testPunctAfterVarNameForLiterals(){
|
||||
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,");
|
||||
|
||||
Map keyToValues = new HashMap();
|
||||
keyToValues.put("var", Arrays.asList(new EditLiteral("ABC", null, null)));
|
||||
|
||||
|
||||
gen.subInMultiLiterals(keyToValues, targets);
|
||||
Assert.assertNotNull(targets);
|
||||
Assert.assertEquals(4,targets.size());
|
||||
|
||||
|
||||
Assert.assertEquals("\"ABC\".", targets.get(0));
|
||||
Assert.assertEquals("\"ABC\";", targets.get(1));
|
||||
Assert.assertEquals("\"ABC\"]", targets.get(2));
|
||||
Assert.assertEquals("\"ABC\",", targets.get(3));
|
||||
Assert.assertEquals("\"ABC\",", targets.get(3));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLiterlasWithDatatypes(){
|
||||
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,","?var", " ?var ");
|
||||
|
||||
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,","?var", " ?var ");
|
||||
|
||||
String value = "ABC";
|
||||
String datatype = "http://someDataType.com/bleck";
|
||||
String expected = '"' + value + '"' + "^^<" + datatype + ">";
|
||||
|
||||
Map keyToValues = new HashMap();
|
||||
|
||||
Map keyToValues = new HashMap();
|
||||
keyToValues.put("var", Arrays.asList(new EditLiteral(value,datatype,null)));
|
||||
|
||||
|
||||
gen.subInMultiLiterals(keyToValues, targets);
|
||||
Assert.assertNotNull(targets);
|
||||
Assert.assertEquals(6,targets.size());
|
||||
|
||||
|
||||
Assert.assertEquals( expected + ".", targets.get(0));
|
||||
Assert.assertEquals(expected + ";", targets.get(1));
|
||||
Assert.assertEquals(expected + "]", targets.get(2));
|
||||
Assert.assertEquals(expected + ",", targets.get(3));
|
||||
Assert.assertEquals(expected , targets.get(4));
|
||||
Assert.assertEquals(" " + expected + " ", targets.get(5));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLiterlasWithLang(){
|
||||
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,","?var", " ?var ");
|
||||
|
||||
List<String> targets = Arrays.asList("?var.","?var;","?var]","?var,","?var", " ?var ");
|
||||
|
||||
String value = "ABC";
|
||||
String datatype = null;
|
||||
String lang = "XYZ";
|
||||
String expected = '"' + value + '"' + "@" + lang + "";
|
||||
|
||||
Map keyToValues = new HashMap();
|
||||
|
||||
Map keyToValues = new HashMap();
|
||||
keyToValues.put("var", Arrays.asList(new EditLiteral(value,datatype,lang)));
|
||||
|
||||
|
||||
gen.subInMultiLiterals(keyToValues, targets);
|
||||
Assert.assertNotNull(targets);
|
||||
Assert.assertEquals(6,targets.size());
|
||||
|
||||
|
||||
Assert.assertEquals( expected + ".", targets.get(0));
|
||||
Assert.assertEquals(expected + ";", targets.get(1));
|
||||
Assert.assertEquals(expected + "]", targets.get(2));
|
||||
|
@ -131,139 +131,139 @@ public class EditN3GeneratorVTwoTest {
|
|||
Assert.assertEquals(expected , targets.get(4));
|
||||
Assert.assertEquals(" " + expected + " ", targets.get(5));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSubInMultiUrisNull(){
|
||||
|
||||
|
||||
@Test
|
||||
public void testSubInMultiUrisNull(){
|
||||
String n3 = "?varXYZ" ;
|
||||
List<String> targets = new ArrayList<String>();
|
||||
targets.add(n3);
|
||||
|
||||
|
||||
Map<String,List<String>> keyToValues = new HashMap<String,List<String>>();
|
||||
List<String> targetValue = new ArrayList<String>();
|
||||
targetValue.add(null);
|
||||
List<String> targetValue = new ArrayList<String>();
|
||||
targetValue.add(null);
|
||||
keyToValues.put("varXYZ", targetValue);
|
||||
|
||||
|
||||
gen.subInMultiUris(keyToValues, targets);
|
||||
Assert.assertNotNull(targets);
|
||||
Assert.assertEquals(1,targets.size());
|
||||
|
||||
|
||||
String resultN3 = targets.get(0);
|
||||
Assert.assertNotNull(resultN3);
|
||||
Assert.assertTrue("String was empty", !resultN3.isEmpty());
|
||||
|
||||
|
||||
String not_expected = "<null>";
|
||||
Assert.assertTrue("must not sub in <null>", !not_expected.equals(resultN3));
|
||||
|
||||
not_expected = "<>";
|
||||
|
||||
not_expected = "<>";
|
||||
Assert.assertTrue("must not sub in <>", !not_expected.equals(resultN3));
|
||||
|
||||
|
||||
Assert.assertEquals("?varXYZ", resultN3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubInMultiUrisEmptyString(){
|
||||
|
||||
@Test
|
||||
public void testSubInMultiUrisEmptyString(){
|
||||
String n3 = "?varXYZ" ;
|
||||
List<String> targets = new ArrayList<String>();
|
||||
targets.add(n3);
|
||||
|
||||
|
||||
Map<String,List<String>> keyToValues = new HashMap<String,List<String>>();
|
||||
List<String> targetValue = new ArrayList<String>();
|
||||
targetValue.add("");
|
||||
List<String> targetValue = new ArrayList<String>();
|
||||
targetValue.add("");
|
||||
keyToValues.put("varXYZ", targetValue);
|
||||
|
||||
|
||||
gen.subInMultiUris(keyToValues, targets);
|
||||
Assert.assertNotNull(targets);
|
||||
Assert.assertEquals(1,targets.size());
|
||||
|
||||
|
||||
String resultN3 = targets.get(0);
|
||||
Assert.assertNotNull(resultN3);
|
||||
Assert.assertTrue("String was empty", !resultN3.isEmpty());
|
||||
|
||||
Assert.assertTrue("String was empty", !resultN3.isEmpty());
|
||||
|
||||
Assert.assertEquals("?varXYZ", resultN3);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testSubInUrisNull(){
|
||||
String n3 = " ?varXYZ " ;
|
||||
List<String> targets = new ArrayList<String>();
|
||||
targets.add(n3);
|
||||
|
||||
Map<String,String> keyToValues = new HashMap<String,String>();
|
||||
|
||||
Map<String,String> keyToValues = new HashMap<String,String>();
|
||||
keyToValues.put("varXYZ", "xyzURI");
|
||||
|
||||
|
||||
gen.subInUris(keyToValues, targets);
|
||||
List<String> result = targets;
|
||||
Assert.assertNotNull(result);
|
||||
Assert.assertEquals(1,result.size());
|
||||
|
||||
|
||||
String resultN3 = result.get(0);
|
||||
Assert.assertNotNull(resultN3);
|
||||
Assert.assertTrue("String was empty", !resultN3.isEmpty());
|
||||
Assert.assertTrue("String was empty", !resultN3.isEmpty());
|
||||
Assert.assertEquals(" <xyzURI> ", resultN3);
|
||||
|
||||
keyToValues = new HashMap<String,String>();
|
||||
|
||||
keyToValues = new HashMap<String,String>();
|
||||
keyToValues.put("varXYZ", null);
|
||||
|
||||
|
||||
List<String> targets2 = new ArrayList<String>();
|
||||
targets2.add(n3);
|
||||
|
||||
|
||||
gen.subInUris(keyToValues, targets2);
|
||||
Assert.assertNotNull(targets2);
|
||||
Assert.assertEquals(1,targets2.size());
|
||||
|
||||
resultN3 = targets2.get(0);
|
||||
|
||||
resultN3 = targets2.get(0);
|
||||
Assert.assertNotNull(resultN3);
|
||||
Assert.assertTrue("String was empty", !resultN3.isEmpty());
|
||||
Assert.assertTrue("String was empty", !resultN3.isEmpty());
|
||||
Assert.assertEquals(" ?varXYZ ", resultN3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
[@prefix core: <http://vivoweb.org/ontology/core#> .
|
||||
?person core:educationalTraining ?edTraining .
|
||||
?edTraining a core:EducationalTraining ;
|
||||
core:educationalTrainingOf ?person ;
|
||||
<http://vivoweb.org/ontology/core#trainingAtOrganization> ?org .
|
||||
, ?org <http://www.w3.org/2000/01/rdf-schema#label> ?orgLabel ., ?org a ?orgType .]
|
||||
, ?org <http://www.w3.org/2000/01/rdf-schema#label> ?orgLabel ., ?org a ?orgType .]
|
||||
|
||||
*/
|
||||
|
||||
//{person=http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2576, predicate=http://vivoweb.org/ontology/core#educationalTraining, edTraining=null}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testSubInMultiUris() {
|
||||
String n3 = "?subject ?predicate ?multivalue ." ;
|
||||
List<String> strs = new ArrayList<String>();
|
||||
strs.add(n3);
|
||||
|
||||
|
||||
Map<String,List<String>> keyToValues = new HashMap<String,List<String>>();
|
||||
List<String> values = new ArrayList<String>();
|
||||
List<String> values = new ArrayList<String>();
|
||||
values.add("http://a.com/2");
|
||||
values.add("http://b.com/ont#2");
|
||||
values.add("http://c.com/individual/n23431");
|
||||
values.add("http://c.com/individual/n23431");
|
||||
keyToValues.put("multivalue", values);
|
||||
|
||||
|
||||
List<String> subject = new ArrayList<String>();
|
||||
List<String> predicate = new ArrayList<String>();
|
||||
subject.add("http://testsubject.com/1");
|
||||
predicate.add("http://testpredicate.com/2");
|
||||
keyToValues.put("subject", subject);
|
||||
keyToValues.put("predicate", predicate);
|
||||
|
||||
gen.subInMultiUris(keyToValues, strs);
|
||||
|
||||
|
||||
gen.subInMultiUris(keyToValues, strs);
|
||||
|
||||
Assert.assertNotNull(strs);
|
||||
Assert.assertTrue( strs.size() == 1 );
|
||||
String expected ="<http://testsubject.com/1> <http://testpredicate.com/2> <http://a.com/2>, <http://b.com/ont#2>, <http://c.com/individual/n23431> .";
|
||||
Assert.assertEquals(expected, strs.get(0));
|
||||
|
||||
|
||||
//Replace subject and predicate with other variables
|
||||
|
||||
|
||||
//make a model,
|
||||
Model expectedModel = ModelFactory.createDefaultModel();
|
||||
StringReader expectedReader = new StringReader(expected);
|
||||
|
|
|
@ -24,26 +24,26 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
|||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfigurationConstants;
|
||||
|
||||
public class ProcessRdfFormTest extends AbstractTestClass{
|
||||
|
||||
|
||||
@Test
|
||||
public void basicNewStatementTest() throws Exception{
|
||||
|
||||
/* A very basic new statement edit. */
|
||||
|
||||
/* A very basic new statement edit. */
|
||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||
config.setEditKey("mockEditKey");
|
||||
config.setN3Required(Arrays.asList("?test1 ?test2 ?test3 ." ));
|
||||
config.setUrisOnform(Arrays.asList("test1", "test2", "test3"));
|
||||
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
values.put("test1", (new String[] {"http://test.com/uri1"}));
|
||||
values.put("test2", (new String[] {"http://test.com/uri2"}));
|
||||
values.put("test3", (new String[] {"http://test.com/uri3"}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
|
||||
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(values, config);
|
||||
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
|
||||
|
||||
/* test just the N3 substitution part */
|
||||
List<String>req = config.getN3Required();
|
||||
List<String>opt = config.getN3Optional();
|
||||
|
@ -54,15 +54,15 @@ public class ProcessRdfFormTest extends AbstractTestClass{
|
|||
assertEquals("<http://test.com/uri1> <http://test.com/uri2> <http://test.com/uri3> .", req.get(0));
|
||||
/* test the N3 and parse RDF parts */
|
||||
AdditionsAndRetractions changes = processor.process( config, submission, null );
|
||||
|
||||
|
||||
assertNotNull( changes );
|
||||
assertNotNull( changes.getAdditions() );
|
||||
assertNotNull( changes.getRetractions());
|
||||
assertTrue( changes.getAdditions().size() == 1 );
|
||||
assertTrue( changes.getRetractions().size() == 0 );
|
||||
|
||||
|
||||
assertTrue( changes.getAdditions().contains(
|
||||
ResourceFactory.createResource("http://test.com/uri1"),
|
||||
ResourceFactory.createResource("http://test.com/uri1"),
|
||||
ResourceFactory.createProperty("http://test.com/uri2"),
|
||||
ResourceFactory.createResource("http://test.com/uri3")));
|
||||
}
|
||||
|
@ -74,112 +74,112 @@ public class ProcessRdfFormTest extends AbstractTestClass{
|
|||
String testYURI = "http://test.com/uriY";
|
||||
String testZURIOrginal = "http://test.com/uriZ";
|
||||
String testZURIChanged = "http://test.com/uriZChanged";
|
||||
|
||||
|
||||
/* set up model */
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
model.add(model.createResource(testXURI),
|
||||
model.createProperty(testYURI),
|
||||
model.add(model.createResource(testXURI),
|
||||
model.createProperty(testYURI),
|
||||
model.createResource(testZURIOrginal));
|
||||
|
||||
|
||||
/* set up EditConfiguration */
|
||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||
config.setEditKey("mockEditKey");
|
||||
config.setEditKey("mockEditKey");
|
||||
config.setUrisOnform(Arrays.asList("testX", "testY", "testZ"));
|
||||
config.setN3Required( Arrays.asList("?testX ?testY ?testZ ." ));
|
||||
|
||||
|
||||
config.setVarNameForSubject("testX");
|
||||
config.setSubjectUri(testXURI);
|
||||
|
||||
|
||||
config.setPredicateUri(testYURI);
|
||||
config.setVarNameForPredicate("testY");
|
||||
|
||||
|
||||
config.setObject(testZURIOrginal);
|
||||
config.setVarNameForObject("testZ");
|
||||
|
||||
config.prepareForObjPropUpdate(model);
|
||||
|
||||
/* set up Submission */
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
config.setVarNameForObject("testZ");
|
||||
|
||||
config.prepareForObjPropUpdate(model);
|
||||
|
||||
/* set up Submission */
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
values.put("testZ", (new String[] {testZURIChanged}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(values, config);
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
AdditionsAndRetractions changes = processor.process( config, submission, null );
|
||||
|
||||
|
||||
assertNotNull( changes );
|
||||
assertNotNull( changes.getAdditions() );
|
||||
assertNotNull( changes.getRetractions());
|
||||
|
||||
|
||||
assertTrue( changes.getAdditions().size() == 1 );
|
||||
assertTrue( changes.getRetractions().size() == 1 );
|
||||
|
||||
|
||||
assertTrue( changes.getAdditions().contains(
|
||||
ResourceFactory.createResource(testXURI),
|
||||
ResourceFactory.createResource(testXURI),
|
||||
ResourceFactory.createProperty(testYURI),
|
||||
ResourceFactory.createResource(testZURIChanged)));
|
||||
|
||||
|
||||
assertTrue( changes.getRetractions().contains(
|
||||
ResourceFactory.createResource(testXURI),
|
||||
ResourceFactory.createResource(testXURI),
|
||||
ResourceFactory.createProperty(testYURI),
|
||||
ResourceFactory.createResource(testZURIOrginal)));
|
||||
ResourceFactory.createResource(testZURIOrginal)));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void substituteInSubPredObjURIsTest(){
|
||||
public void substituteInSubPredObjURIsTest(){
|
||||
String testXURI = "http://test.com/uriX";
|
||||
String testYURI = "http://test.com/uriY";
|
||||
String testZURI = "http://test.com/uriZ";
|
||||
|
||||
String testZURI = "http://test.com/uriZ";
|
||||
|
||||
/* set up EditConfiguration */
|
||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||
|
||||
|
||||
config.setVarNameForSubject("testX");
|
||||
config.setSubjectUri(testXURI);
|
||||
|
||||
|
||||
config.setPredicateUri(testYURI);
|
||||
config.setVarNameForPredicate("testY");
|
||||
|
||||
|
||||
config.setObject(testZURI);
|
||||
config.setVarNameForObject("testZ");
|
||||
|
||||
|
||||
List<String> a = Arrays.asList("a.0 ?testX ?testY ?testZ.", "a.1 ?testX ?testY ?testZ.");
|
||||
List<String> b = Arrays.asList("b.0 ?testX ?testY ?testZ.", "b.1 ?testX ?testY ?testZ.");
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
|
||||
processor.substituteInSubPredObjURIs(config, a, b);
|
||||
assertEquals("a.0 <" + testXURI + "> <" + testYURI + "> <" + testZURI + ">.", a.get(0));
|
||||
assertEquals("a.1 <" + testXURI + "> <" + testYURI + "> <" + testZURI + ">.", a.get(1));
|
||||
assertEquals("a.1 <" + testXURI + "> <" + testYURI + "> <" + testZURI + ">.", a.get(1));
|
||||
assertEquals("b.0 <" + testXURI + "> <" + testYURI + "> <" + testZURI + ">.", b.get(0));
|
||||
assertEquals("b.1 <" + testXURI + "> <" + testYURI + "> <" + testZURI + ">.", b.get(1));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unicodeTest() throws Exception{
|
||||
/* A test unicode characters with new statement edit. */
|
||||
|
||||
/* A test unicode characters with new statement edit. */
|
||||
|
||||
/* make configuration */
|
||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||
config.setEditKey("mockEditKey");
|
||||
config.setN3Required(Arrays.asList("?test1 ?test2 ?test3 ." ));
|
||||
config.setUrisOnform(Arrays.asList("test1", "test2", "test3"));
|
||||
|
||||
|
||||
String test1 = "http://test.com/uriWithUnicodeƺ",
|
||||
test2 = "http://test.com/latin-1-ÙåàÞñöÿ",
|
||||
test3 = "http://test.com/moreUnicode-ἎἘὤ" ;
|
||||
|
||||
|
||||
/* make submission */
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
values.put("test1", (new String[] {test1}));
|
||||
values.put("test2", (new String[] {test2}));
|
||||
values.put("test3", (new String[] {test3}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(values, config);
|
||||
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
|
||||
|
||||
/* test just the N3 substitution part */
|
||||
List<String>req = config.getN3Required();
|
||||
List<String>opt = config.getN3Optional();
|
||||
|
@ -188,42 +188,42 @@ public class ProcessRdfFormTest extends AbstractTestClass{
|
|||
assertTrue( req.size() > 0);
|
||||
assertNotNull(req.get(0));
|
||||
assertEquals("<" +test1+ "> <" +test2+ "> <" +test3+ "> .", req.get(0));
|
||||
|
||||
|
||||
/* test the N3 and parse RDF parts */
|
||||
AdditionsAndRetractions changes = processor.process( config, submission, null );
|
||||
|
||||
|
||||
assertNotNull( changes );
|
||||
assertNotNull( changes.getAdditions() );
|
||||
assertNotNull( changes.getRetractions());
|
||||
assertTrue( changes.getAdditions().size() == 1 );
|
||||
assertTrue( changes.getRetractions().size() == 0 );
|
||||
|
||||
|
||||
assertTrue( changes.getAdditions().contains(
|
||||
ResourceFactory.createResource(test1),
|
||||
ResourceFactory.createResource(test1),
|
||||
ResourceFactory.createProperty(test2),
|
||||
ResourceFactory.createResource(test3)));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void basicNewResourceTest() throws Exception{
|
||||
/* A very basic new statement edit. */
|
||||
public void basicNewResourceTest() throws Exception{
|
||||
/* A very basic new statement edit. */
|
||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||
config.setEditKey("mockEditKey");
|
||||
config.setN3Required(Arrays.asList("?newRes ?test2 ?test3 ." ));
|
||||
config.setUrisOnform(Arrays.asList( "test2", "test3"));
|
||||
config.addNewResource("newRes", null);
|
||||
config.setEntityToReturnTo("?newRes");
|
||||
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
config.setEntityToReturnTo("?newRes");
|
||||
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
|
||||
values.put("test2", (new String[] {"http://test.com/uri2"}));
|
||||
values.put("test3", (new String[] {"http://test.com/uri3"}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
|
||||
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(values, config);
|
||||
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
|
||||
|
||||
/* test just the N3 substitution part */
|
||||
List<String>req = config.getN3Required();
|
||||
List<String>opt = config.getN3Optional();
|
||||
|
@ -232,28 +232,28 @@ public class ProcessRdfFormTest extends AbstractTestClass{
|
|||
assertTrue( req.size() > 0);
|
||||
assertNotNull(req.get(0));
|
||||
assertEquals("<"+NEWURI_STRING + "0> <http://test.com/uri2> <http://test.com/uri3> .", req.get(0));
|
||||
|
||||
|
||||
assertEquals("<" + NEWURI_STRING + "0>", submission.getEntityToReturnTo());
|
||||
|
||||
|
||||
/* test the N3 and parse RDF parts */
|
||||
AdditionsAndRetractions changes = processor.process( config, submission, null );
|
||||
|
||||
|
||||
assertNotNull( changes );
|
||||
assertNotNull( changes.getAdditions() );
|
||||
assertNotNull( changes.getRetractions());
|
||||
assertTrue( changes.getAdditions().size() == 1 );
|
||||
assertTrue( changes.getRetractions().size() == 0 );
|
||||
|
||||
|
||||
assertTrue( changes.getAdditions().contains(
|
||||
ResourceFactory.createResource(NEWURI_STRING + "0"),
|
||||
ResourceFactory.createResource(NEWURI_STRING + "0"),
|
||||
ResourceFactory.createProperty("http://test.com/uri2"),
|
||||
ResourceFactory.createResource("http://test.com/uri3")));
|
||||
}
|
||||
|
||||
@Test
|
||||
//Edit existing statement
|
||||
public void forcedNewResourceTest() throws Exception{
|
||||
/* A very basic new statement edit. */
|
||||
public void forcedNewResourceTest() throws Exception{
|
||||
/* A very basic new statement edit. */
|
||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||
config.setEditKey("mockEditKey");
|
||||
config.setN3Required(Arrays.asList("?newRes ?test2 ?test3 ." ));
|
||||
|
@ -261,19 +261,19 @@ public class ProcessRdfFormTest extends AbstractTestClass{
|
|||
//set uris in scope to include an existing value for new resource
|
||||
config.addUrisInScope("newRes", Arrays.asList("<http://test.com/uri1>"));
|
||||
config.addNewResource("newRes", null);
|
||||
config.setEntityToReturnTo("?newRes");
|
||||
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
config.setEntityToReturnTo("?newRes");
|
||||
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
//value from form should indicate that newRes should have new uri created
|
||||
values.put("newRes", (new String[] {EditConfigurationConstants.NEW_URI_SENTINEL}));
|
||||
values.put("test2", (new String[] {"http://test.com/uri2"}));
|
||||
values.put("test3", (new String[] {"http://test.com/uri3"}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
|
||||
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(values, config);
|
||||
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
|
||||
|
||||
/* test just the N3 substitution part */
|
||||
List<String>req = config.getN3Required();
|
||||
List<String>opt = config.getN3Optional();
|
||||
|
@ -282,27 +282,27 @@ public class ProcessRdfFormTest extends AbstractTestClass{
|
|||
assertTrue( req.size() > 0);
|
||||
assertNotNull(req.get(0));
|
||||
assertEquals("<"+NEWURI_STRING + "0> <http://test.com/uri2> <http://test.com/uri3> .", req.get(0));
|
||||
|
||||
|
||||
assertEquals("<" + NEWURI_STRING + "0>", submission.getEntityToReturnTo());
|
||||
|
||||
|
||||
/* test the N3 and parse RDF parts */
|
||||
AdditionsAndRetractions changes = processor.process( config, submission, null );
|
||||
|
||||
|
||||
assertNotNull( changes );
|
||||
assertNotNull( changes.getAdditions() );
|
||||
assertNotNull( changes.getRetractions());
|
||||
assertTrue( changes.getAdditions().size() == 1 );
|
||||
//the old uri should be removed
|
||||
assertTrue( changes.getRetractions().size() == 0 );
|
||||
|
||||
|
||||
assertTrue( changes.getAdditions().contains(
|
||||
ResourceFactory.createResource(NEWURI_STRING + "0"),
|
||||
ResourceFactory.createResource(NEWURI_STRING + "0"),
|
||||
ResourceFactory.createProperty("http://test.com/uri2"),
|
||||
ResourceFactory.createResource("http://test.com/uri3")));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* An edit of an existing statement set where some statements need to be replaced while
|
||||
* others must be retained. */
|
||||
@Test
|
||||
|
@ -316,77 +316,77 @@ public class ProcessRdfFormTest extends AbstractTestClass{
|
|||
/* set up model */
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
//?x ?y ?zOriginal.
|
||||
model.add(model.createResource(testXURI),
|
||||
model.createProperty(testYURI),
|
||||
model.add(model.createResource(testXURI),
|
||||
model.createProperty(testYURI),
|
||||
model.createResource(testZURIOrginal));
|
||||
//?zOriginal a TestType.
|
||||
|
||||
model.add(model.createResource(testZURIOrginal),
|
||||
RDF.type,
|
||||
model.add(model.createResource(testZURIOrginal),
|
||||
RDF.type,
|
||||
model.createResource(zType));
|
||||
//?zOriginal label "zLabel";
|
||||
|
||||
model.add(model.createResource(testZURIOrginal),
|
||||
RDFS.label,
|
||||
model.add(model.createResource(testZURIOrginal),
|
||||
RDFS.label,
|
||||
model.createLiteral("Z Original Label"));
|
||||
|
||||
|
||||
/* set up EditConfiguration */
|
||||
EditConfigurationVTwo config = new EditConfigurationVTwo();
|
||||
config.setEditKey("mockEditKey");
|
||||
config.setEditKey("mockEditKey");
|
||||
config.setLiteralsOnForm(Arrays.asList("zLabel"));
|
||||
config.setUrisOnform(Arrays.asList("testX", "testY", "testZ"));
|
||||
config.setN3Required( Arrays.asList("?testX ?testY ?testZ ." ));
|
||||
config.setN3Optional( Arrays.asList("?testZ a <" + zType + "> . \n" +
|
||||
config.setN3Optional( Arrays.asList("?testZ a <" + zType + "> . \n" +
|
||||
"?testZ <" + rdfsLabel + "> ?zLabel ." ));
|
||||
//mimicking an existing value for the label
|
||||
config.addLiteralInScope("zLabel", model.createLiteral("Z Original Label"));
|
||||
|
||||
config.addLiteralInScope("zLabel", model.createLiteral("Z Original Label"));
|
||||
|
||||
config.setVarNameForSubject("testX");
|
||||
config.setSubjectUri(testXURI);
|
||||
|
||||
|
||||
config.setPredicateUri(testYURI);
|
||||
config.setVarNameForPredicate("testY");
|
||||
|
||||
|
||||
config.setObject(testZURIOrginal);
|
||||
config.setVarNameForObject("testZ");
|
||||
|
||||
config.setVarNameForObject("testZ");
|
||||
|
||||
config.addField(new FieldVTwo().setName("zLabel"));
|
||||
config.prepareForObjPropUpdate(model);
|
||||
/* set up Submission */
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
config.prepareForObjPropUpdate(model);
|
||||
/* set up Submission */
|
||||
Map<String,String[]> values = new HashMap<String, String[]>();
|
||||
values.put("testZ", (new String[] {testZURIChanged}));
|
||||
values.put("zLabel", (new String[] {"New Z Label"}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
values.put("editKey", (new String[] {"mockEditKey"}));
|
||||
MultiValueEditSubmission submission = new MultiValueEditSubmission(values, config);
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
|
||||
ProcessRdfForm processor = new ProcessRdfForm(config,getMockNewURIMaker());
|
||||
AdditionsAndRetractions changes = processor.process( config, submission, null );
|
||||
|
||||
|
||||
assertNotNull( changes );
|
||||
assertNotNull( changes.getAdditions() );
|
||||
assertNotNull( changes.getRetractions());
|
||||
|
||||
|
||||
// assertTrue( changes.getAdditions().size() == 3 );
|
||||
//only one statement should be retracted
|
||||
// assertTrue( changes.getRetractions().size() == 1 );
|
||||
|
||||
|
||||
assertTrue( changes.getAdditions().contains(
|
||||
ResourceFactory.createResource(testXURI),
|
||||
ResourceFactory.createResource(testXURI),
|
||||
ResourceFactory.createProperty(testYURI),
|
||||
ResourceFactory.createResource(testZURIChanged)));
|
||||
|
||||
|
||||
assertTrue( changes.getRetractions().contains(
|
||||
ResourceFactory.createResource(testXURI),
|
||||
ResourceFactory.createResource(testXURI),
|
||||
ResourceFactory.createProperty(testYURI),
|
||||
ResourceFactory.createResource(testZURIOrginal)));
|
||||
ResourceFactory.createResource(testZURIOrginal)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
String NEWURI_STRING= "http://newURI/n";
|
||||
|
||||
|
||||
public NewURIMaker getMockNewURIMaker(){
|
||||
return new NewURIMaker() {
|
||||
int count = 0;
|
||||
int count = 0;
|
||||
@Override
|
||||
public String getUnusedNewURI(String prefixURI) throws InsertException {
|
||||
if( prefixURI != null )
|
||||
|
@ -394,6 +394,6 @@ public class ProcessRdfFormTest extends AbstractTestClass{
|
|||
else
|
||||
return NEWURI_STRING + count;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmis
|
|||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||
|
||||
public class AntiXssValidationTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testLiteral( ){
|
||||
//test all fields constructor
|
||||
|
@ -24,18 +24,18 @@ public class AntiXssValidationTest {
|
|||
eConf.setEditKey("fakeEditKey");
|
||||
eConf.addField( new FieldVTwo().setName("X") );
|
||||
eConf.setLiteralsOnForm( Arrays.asList("X") );
|
||||
|
||||
|
||||
Map<String, String[]> params = new HashMap<String,String[]>();
|
||||
String[] vals= { "some sort of string" };
|
||||
params.put("X", vals);
|
||||
|
||||
MultiValueEditSubmission mvEditSub =
|
||||
new MultiValueEditSubmission(params,eConf);
|
||||
|
||||
params.put("X", vals);
|
||||
|
||||
MultiValueEditSubmission mvEditSub =
|
||||
new MultiValueEditSubmission(params,eConf);
|
||||
|
||||
Map<String, String> res = validator.validate(eConf, mvEditSub);
|
||||
Assert.assertEquals(null, res);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAllURI( ){
|
||||
//test all fields constructor
|
||||
|
@ -44,86 +44,86 @@ public class AntiXssValidationTest {
|
|||
EditConfigurationVTwo eConf = new EditConfigurationVTwo();
|
||||
eConf.setEditKey("fakeEditKey");
|
||||
eConf.setUrisOnform( Arrays.asList("X","Y","Z"));
|
||||
|
||||
|
||||
Map<String, String[]> params = new HashMap<String,String[]>();
|
||||
String[] strings0 = {"no problem 0"};
|
||||
params.put("X", strings0 );
|
||||
params.put("X", strings0 );
|
||||
String[] strings1 = {"no problem 1"};
|
||||
params.put("Y", strings1 );
|
||||
String[] strings2 = {"no problem 2"};
|
||||
params.put("Z", strings2 );
|
||||
|
||||
MultiValueEditSubmission mvEditSub =
|
||||
new MultiValueEditSubmission(params,eConf);
|
||||
|
||||
|
||||
MultiValueEditSubmission mvEditSub =
|
||||
new MultiValueEditSubmission(params,eConf);
|
||||
|
||||
Map<String, String> res = validator.validate(eConf, mvEditSub);
|
||||
Assert.assertNull( res );
|
||||
}
|
||||
|
||||
|
||||
protected Map<String, String> testURI( String ... strings){
|
||||
|
||||
AntiXssValidation validator =
|
||||
AntiXssValidation validator =
|
||||
new AntiXssValidation(Arrays.asList("X"));
|
||||
|
||||
EditConfigurationVTwo eConf = new EditConfigurationVTwo();
|
||||
eConf.setEditKey("fakeEditKey");
|
||||
eConf.setUrisOnform( Arrays.asList("X"));
|
||||
|
||||
Map<String, String[]> params = new HashMap<String,String[]>();
|
||||
params.put("X", strings );
|
||||
|
||||
MultiValueEditSubmission mvEditSub =
|
||||
new MultiValueEditSubmission(params,eConf);
|
||||
|
||||
return validator.validate(eConf, mvEditSub);
|
||||
|
||||
Map<String, String[]> params = new HashMap<String,String[]>();
|
||||
params.put("X", strings );
|
||||
|
||||
MultiValueEditSubmission mvEditSub =
|
||||
new MultiValueEditSubmission(params,eConf);
|
||||
|
||||
return validator.validate(eConf, mvEditSub);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testURIValidation(){
|
||||
Map<String, String> result = testURI("http://this.should.be.fine.com/xyz#lskd?junk=a&bkeck=%23");
|
||||
public void testURIValidation(){
|
||||
Map<String, String> result = testURI("http://this.should.be.fine.com/xyz#lskd?junk=a&bkeck=%23");
|
||||
Assert.assertNull(result);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testURIValidationWithScriptTagLevel1(){
|
||||
public void testURIValidationWithScriptTagLevel1(){
|
||||
Map<String, String> result = null;
|
||||
result = testURI("http:<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>//bad.news.com");
|
||||
result = testURI("http:<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=JaVaScRiPt:alert('XSS')>//bad.news.com");
|
||||
|
||||
result = testURI("http:<IMG SRC=JaVaScRiPt:alert('XSS')>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert("XSS")>//bad.news.com");
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert("XSS")>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=\"jav\tascript:alert('XSS');\">//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=\"jav\tascript:alert('XSS');\">//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testURIValidationWithScriptTagLevel2(){
|
||||
public void testURIValidationWithScriptTagLevel2(){
|
||||
Map<String, String> result = null;
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<<SCRIPT>alert(\"XSS\");//<</SCRIPT>//bad.news.com");
|
||||
|
||||
result = testURI("http:<<SCRIPT>alert(\"XSS\");//<</SCRIPT>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
|
||||
result = testURI("http:<IMG SRC=javascript:alert('XSS')>//bad.news.com");
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ public class RdfLiteralHashTest {
|
|||
// Assert.assertNull(stmt);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// @Test
|
||||
// public void testGetRdfsLabelStatementByHash(){
|
||||
//
|
||||
|
@ -187,7 +187,7 @@ public class RdfLiteralHashTest {
|
|||
// "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . \n"+
|
||||
// "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"+
|
||||
// " ex:bob rdfs:label \"Smith, Bob\"^^<"+XSD.xstring.getURI()+"> ." ;
|
||||
//
|
||||
//
|
||||
// Model model = (ModelFactory.createDefaultModel()).read(new StringReader(n3), "", "N3");
|
||||
//
|
||||
// Individual bob = new IndividualImpl();
|
||||
|
@ -195,16 +195,16 @@ public class RdfLiteralHashTest {
|
|||
//
|
||||
// int hash = RdfLiteralHash.makeRdfsLabelLiteralHash(bob, "Smith, Bob", model);
|
||||
// DataPropertyStatement stmt = RdfLiteralHash.getRdfsLabelStatementByHash(bob.getURI(), model, hash);
|
||||
//
|
||||
//
|
||||
// String data = stmt.getData();
|
||||
// String datatypeUri = stmt.getDatatypeURI();
|
||||
// String predicateUri = stmt.getDatapropURI();
|
||||
// String subjectUri = stmt.getIndividualURI();
|
||||
//
|
||||
//
|
||||
// Assert.assertEquals("Smith, Bob", data);
|
||||
// Assert.assertEquals(XSD.xstring.getURI(), datatypeUri);
|
||||
// Assert.assertEquals(VitroVocabulary.LABEL, predicateUri);
|
||||
// Assert.assertEquals("http://example.com/bob", subjectUri);
|
||||
//
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class FileServingHelperTest extends AbstractTestClass {
|
|||
@Before
|
||||
public void createConfigurationProperties() throws Exception {
|
||||
setLoggerLevel(ConfigurationProperties.class, Level.WARN);
|
||||
|
||||
|
||||
ctx = new ServletContextStub();
|
||||
|
||||
ConfigurationPropertiesStub props = new ConfigurationPropertiesStub();
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class FileStorageHelperTest {
|
||||
private static String RAW_NAME_1 = "simpleName";
|
||||
|
|
|
@ -24,37 +24,37 @@ public class URLRewritingHttpServletResponseTest {
|
|||
*/
|
||||
protected void urlEncodingStyleA(String urlToEncode, String expectedUrlResult ){
|
||||
URLRewritingHttpServletResponse urhsr = new URLRewritingHttpServletResponse(new stubs.javax.servlet.http.HttpServletResponseStub());
|
||||
|
||||
|
||||
List<String>externalNamespaces = new ArrayList();
|
||||
externalNamespaces.add("http://vivo.med.cornell.edu/individual/");
|
||||
|
||||
String actual = urhsr.encodeForVitro(urlToEncode, "UTF-8",
|
||||
true, 1,
|
||||
getMockNamespaceMapper(),
|
||||
"http://vivo.cornell.edu/individual/",
|
||||
externalNamespaces.add("http://vivo.med.cornell.edu/individual/");
|
||||
|
||||
String actual = urhsr.encodeForVitro(urlToEncode, "UTF-8",
|
||||
true, 1,
|
||||
getMockNamespaceMapper(),
|
||||
"http://vivo.cornell.edu/individual/",
|
||||
externalNamespaces);
|
||||
Assert.assertEquals(expectedUrlResult, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Style A is for sites that are running behind apache httpd at a
|
||||
* Style A is for sites that are running behind apache httpd at a
|
||||
* URL like http://caruso.mannlib.cornell.edu/ with no portals.
|
||||
*/
|
||||
protected void urlEncodingStyleB(String urlToEncode, String expectedUrlResult){
|
||||
URLRewritingHttpServletResponse urhsr = new URLRewritingHttpServletResponse(new stubs.javax.servlet.http.HttpServletResponseStub());
|
||||
|
||||
|
||||
List<String>externalNamespaces = new ArrayList();
|
||||
externalNamespaces.add("http://vivo.med.cornell.edu/individual/");
|
||||
|
||||
String actual = urhsr.encodeForVitro(urlToEncode, "UTF-8",
|
||||
true, 0,
|
||||
getMockNamespaceMapper(),
|
||||
"http://vivo.cornell.edu/individual/",
|
||||
externalNamespaces.add("http://vivo.med.cornell.edu/individual/");
|
||||
|
||||
String actual = urhsr.encodeForVitro(urlToEncode, "UTF-8",
|
||||
true, 0,
|
||||
getMockNamespaceMapper(),
|
||||
"http://vivo.cornell.edu/individual/",
|
||||
externalNamespaces);
|
||||
Assert.assertEquals(expectedUrlResult, actual);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test40984(){ urlEncodingStyleA( "/vivo/js/jquery-1.12.4.min.js",
|
||||
"/vivo/js/jquery-1.12.4.min.js"); }
|
||||
|
@ -593,8 +593,8 @@ public class URLRewritingHttpServletResponseTest {
|
|||
"/vivo/js/jquery_plugins/ui.datepicker.js",
|
||||
"/vivo/js/jquery_plugins/ui.datepicker.js"); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test35560(){ urlEncodingStyleB( "/js/jquery-1.12.4.min.js",
|
||||
|
@ -783,85 +783,85 @@ public class URLRewritingHttpServletResponseTest {
|
|||
|
||||
public NamespaceMapper getMockNamespaceMapper(){
|
||||
return new NamespaceMapper() {
|
||||
|
||||
|
||||
@Override
|
||||
public void removedStatements(Model arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removedStatements(StmtIterator arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removedStatements(List<Statement> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removedStatements(Statement[] arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removedStatement(Statement arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void notifyEvent(Model arg0, Object arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addedStatements(Model arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addedStatements(StmtIterator arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addedStatements(List<Statement> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addedStatements(Statement[] arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addedStatement(Statement arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getPrefixesForNamespace(String namespace) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPrefixForNamespace(String namespace) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getNamespaceForPrefix(String prefix) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -10,14 +10,14 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
|
||||
public class VitroURLTest {
|
||||
public class VitroURLTest {
|
||||
|
||||
/**
|
||||
* Test of beginsWithSlash method, of class VitroURL.
|
||||
*/
|
||||
@Test
|
||||
public void testBeginsWithSlash()
|
||||
{
|
||||
{
|
||||
String pathStr = "entity?home=1&uri=http://aims.fao.org/aos/geopolitical.owl#Afghanistan";
|
||||
VitroURL instance = new VitroURL("", "UTF-8");
|
||||
boolean expResult = false;
|
||||
|
@ -30,7 +30,7 @@ public class VitroURLTest {
|
|||
*/
|
||||
@Test
|
||||
public void testEndsInSlash()
|
||||
{
|
||||
{
|
||||
String pathStr = "/entity?home=1&uri=http://aims.fao.org/aos/geopolitical.owl#Afghanistan";
|
||||
VitroURL instance = new VitroURL("", "UTF-8");
|
||||
boolean expResult = false;
|
||||
|
@ -58,8 +58,8 @@ public class VitroURLTest {
|
|||
result = instance.toString();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is a test similar to testToString()
|
||||
* in that it has a = and a ? but it doesn't
|
||||
|
@ -69,77 +69,77 @@ public class VitroURLTest {
|
|||
public void testWithEqualsSign(){
|
||||
String MelbUniStr = "/entity?home=1&uri=HTTPS://bida.themis.unimelb.edu.au/pls/apex/f?p=mrw2rdf:org:::::org_id:145";
|
||||
VitroURL instance = new VitroURL(MelbUniStr, "UTF-8");
|
||||
String expResult ="/entity?home=1&uri=HTTPS%3A%2F%2Fbida.themis.unimelb.edu.au%2Fpls%2Fapex%2Ff%3Fp%3Dmrw2rdf%3Aorg%3A%3A%3A%3A%3Aorg_id%3A145";
|
||||
String expResult ="/entity?home=1&uri=HTTPS%3A%2F%2Fbida.themis.unimelb.edu.au%2Fpls%2Fapex%2Ff%3Fp%3Dmrw2rdf%3Aorg%3A%3A%3A%3A%3Aorg_id%3A145";
|
||||
assertEquals(expResult, instance.toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseQueryParams(){
|
||||
//parseQueryParams
|
||||
VitroURL instance = new VitroURL("stringNotImportant", "UTF-8");
|
||||
VitroURL instance = new VitroURL("stringNotImportant", "UTF-8");
|
||||
List<String[]> result = instance.parseQueryParams("uri=HTTPS://bida.themis.unimelb.edu.au/pls/apex/f?p=mrw2rdf:org:::::org_id:145");
|
||||
Assert.assertNotNull(result);
|
||||
Assert.assertEquals(1, result.size());
|
||||
Assert.assertNotNull(result.get(0));
|
||||
Assert.assertEquals(2, result.get(0).length);
|
||||
Assert.assertEquals("uri",result.get(0)[0]);
|
||||
Assert.assertEquals("HTTPS://bida.themis.unimelb.edu.au/pls/apex/f?p=mrw2rdf:org:::::org_id:145",result.get(0)[1]);
|
||||
Assert.assertEquals("HTTPS://bida.themis.unimelb.edu.au/pls/apex/f?p=mrw2rdf:org:::::org_id:145",result.get(0)[1]);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseQueryParams2(){
|
||||
//parseQueryParams
|
||||
VitroURL instance = new VitroURL("stringNotImportant", "UTF-8");
|
||||
VitroURL instance = new VitroURL("stringNotImportant", "UTF-8");
|
||||
List<String[]> result = instance.parseQueryParams("home=1&uri=HTTPS://bida.themis.unimelb.edu.au/pls/apex/f?p=mrw2rdf:org:::::org_id:145");
|
||||
Assert.assertNotNull(result);
|
||||
Assert.assertEquals(2, result.size());
|
||||
|
||||
|
||||
Assert.assertNotNull(result.get(0));
|
||||
Assert.assertEquals(2, result.get(0).length);
|
||||
Assert.assertEquals("home",result.get(0)[0]);
|
||||
Assert.assertEquals("1",result.get(0)[1]);
|
||||
|
||||
|
||||
Assert.assertNotNull(result.get(1));
|
||||
Assert.assertEquals(2, result.get(1).length);
|
||||
Assert.assertEquals("uri",result.get(1)[0]);
|
||||
Assert.assertEquals("HTTPS://bida.themis.unimelb.edu.au/pls/apex/f?p=mrw2rdf:org:::::org_id:145",result.get(1)[1]);
|
||||
Assert.assertEquals("HTTPS://bida.themis.unimelb.edu.au/pls/apex/f?p=mrw2rdf:org:::::org_id:145",result.get(1)[1]);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseQueryParams3(){
|
||||
//parseQueryParams
|
||||
VitroURL instance = new VitroURL("stringNotImportant", "UTF-8");
|
||||
VitroURL instance = new VitroURL("stringNotImportant", "UTF-8");
|
||||
List<String[]> result = instance.parseQueryParams("home=1&uri=HTTPS://bida.edu.au/pls/apex/f?p=mrw2&additiona=234");
|
||||
Assert.assertNotNull(result);
|
||||
Assert.assertEquals(2, result.size());
|
||||
|
||||
|
||||
Assert.assertNotNull(result.get(0));
|
||||
Assert.assertEquals(2, result.get(0).length);
|
||||
Assert.assertEquals("home",result.get(0)[0]);
|
||||
Assert.assertEquals("1",result.get(0)[1]);
|
||||
|
||||
|
||||
Assert.assertNotNull(result.get(1));
|
||||
Assert.assertEquals(2, result.get(1).length);
|
||||
Assert.assertEquals("uri",result.get(1)[0]);
|
||||
Assert.assertEquals("HTTPS://bida.edu.au/pls/apex/f?p=mrw2&additiona=234",result.get(1)[1]);
|
||||
Assert.assertEquals("HTTPS://bida.edu.au/pls/apex/f?p=mrw2&additiona=234",result.get(1)[1]);
|
||||
}
|
||||
|
||||
|
||||
@Test (expected=Error.class)
|
||||
public void testParseQueryParams4(){
|
||||
//parseQueryParams
|
||||
VitroURL instance = new VitroURL("stringNotImportant", "UTF-8");
|
||||
VitroURL instance = new VitroURL("stringNotImportant", "UTF-8");
|
||||
List<String[]> result = instance.parseQueryParams("home=1&shouldBeURI=HTTPS://bida.edu.au/pls/apex/f?p=mrw2&additiona=234");
|
||||
Assert.assertNotNull(result);
|
||||
Assert.assertEquals(2, result.size());
|
||||
|
||||
|
||||
Assert.assertNotNull(result.get(0));
|
||||
Assert.assertEquals(2, result.get(0).length);
|
||||
Assert.assertEquals("home",result.get(0)[0]);
|
||||
Assert.assertEquals("1",result.get(0)[1]);
|
||||
|
||||
|
||||
Assert.assertNotNull(result.get(1));
|
||||
Assert.assertEquals(2, result.get(1).length);
|
||||
Assert.assertEquals("uri",result.get(1)[0]);
|
||||
Assert.assertEquals("HTTPS://bida.edu.au/pls/apex/f?p=mrw2&additiona=234",result.get(1)[1]);
|
||||
Assert.assertEquals("HTTPS://bida.edu.au/pls/apex/f?p=mrw2&additiona=234",result.get(1)[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
|
|||
|
||||
/**
|
||||
* Test the I18N functionality.
|
||||
*
|
||||
*
|
||||
* Start by checking the logic that finds approximate matches for
|
||||
* language-specific property files.
|
||||
*/
|
||||
|
|
|
@ -146,7 +146,7 @@ public class LocaleSelectionSetupTest extends AbstractTestClass {
|
|||
expectForced("es");
|
||||
expectMessages(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void forceSuccessL_C() {
|
||||
props.setProperty(PROPERTY_FORCE_LOCALE, "es_ES");
|
||||
|
@ -154,7 +154,7 @@ public class LocaleSelectionSetupTest extends AbstractTestClass {
|
|||
expectForced("es_ES");
|
||||
expectMessages(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void forceSuccessL_C_V() {
|
||||
props.setProperty(PROPERTY_FORCE_LOCALE, "no_NO_NY");
|
||||
|
|
|
@ -36,31 +36,31 @@ import edu.cornell.mannlib.vitro.testing.RecordingProxy.MethodCallRecorder;
|
|||
/**
|
||||
* Test that the VitroModelFactory is doing what we want, with regard to bulk
|
||||
* updates.
|
||||
*
|
||||
*
|
||||
* With the switch to Jena 2.10, bulk update operations are deprecated, but
|
||||
* still supported, to a large extent. A Graph still has a bulk updater which
|
||||
* can be called for bulk operations (like adding multiple statements). However,
|
||||
* the default Model won't call the bulk updater of its Graph, and neither will
|
||||
* the default OntModel.
|
||||
*
|
||||
*
|
||||
* VitroModelFactory creates Models and OntModels that do call the bulk updaters
|
||||
* of their respective graphs.
|
||||
*
|
||||
*
|
||||
* ---------------
|
||||
*
|
||||
*
|
||||
* These tests show which methods are called on which objects (graph, model,
|
||||
* listener) for both simple operations (add a statement) and bulk operations
|
||||
* (add multiple statements).
|
||||
*
|
||||
*
|
||||
* The tests of the default ModelFactory aren't necessary. They do add
|
||||
* confidence to the testing mechanism, and provide a contrast with the
|
||||
* VitroModelFactory.
|
||||
*
|
||||
*
|
||||
* The tests of simple operations may or may not add value. Probably good to
|
||||
* keep them.
|
||||
*
|
||||
*
|
||||
* ----------------
|
||||
*
|
||||
*
|
||||
* Who knows how we will deal with this in the next Jena upgrade, when
|
||||
* presumably the bulk updaters will be removed completely.
|
||||
*/
|
||||
|
@ -84,7 +84,7 @@ public class VitroModelFactoryTest extends AbstractTestClass {
|
|||
/**
|
||||
* A ModelGroup has a talkative graph, with a talkative bulkUpdater, wrapped
|
||||
* by a model that has a talkative listener attached.
|
||||
*
|
||||
*
|
||||
* But what kind of model?
|
||||
*/
|
||||
private static abstract class ModelGroup extends TestObjectGrouping {
|
||||
|
@ -164,7 +164,7 @@ public class VitroModelFactoryTest extends AbstractTestClass {
|
|||
/**
|
||||
* An OntModelGroup is like a ModelGroup, but the model is wrapped in an
|
||||
* OntModel that has its own talkative listener.
|
||||
*
|
||||
*
|
||||
* But what kind of Model, and what kind of OntModel?
|
||||
*/
|
||||
private static abstract class OntModelGroup extends ModelGroup {
|
||||
|
@ -256,7 +256,7 @@ public class VitroModelFactoryTest extends AbstractTestClass {
|
|||
/**
|
||||
* A UnionModelGroup is two ModelGroups, joined into a union that has its
|
||||
* own talkative listener.
|
||||
*
|
||||
*
|
||||
* But what kind of ModelGroup, and what kind of union?
|
||||
*/
|
||||
private abstract static class UnionModelGroup extends TestObjectGrouping {
|
||||
|
@ -359,7 +359,7 @@ public class VitroModelFactoryTest extends AbstractTestClass {
|
|||
/**
|
||||
* A UnionOntModelGroup is two OntModelGroups, joined into a union that has
|
||||
* its own talkative listener.
|
||||
*
|
||||
*
|
||||
* But what kind of OntModelGroup, and what kind of union?
|
||||
*/
|
||||
private abstract static class UnionOntModelGroup extends TestObjectGrouping {
|
||||
|
@ -467,7 +467,7 @@ public class VitroModelFactoryTest extends AbstractTestClass {
|
|||
/**
|
||||
* A OntModelUnionModelGroup is a UnionModelGroup wrapped by an OntModel
|
||||
* with a listener.
|
||||
*
|
||||
*
|
||||
* But what kind of UnionModelGroup, and what kind of OntModel?
|
||||
*/
|
||||
private abstract static class OntModelUnionModelGroup extends
|
||||
|
|
|
@ -27,7 +27,7 @@ import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
|||
|
||||
/**
|
||||
* This is the matching order we expect to see:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* exact match to preferred, by order.
|
||||
* partial match to preferred, by order.
|
||||
|
|
|
@ -22,9 +22,9 @@ import org.apache.jena.vocabulary.OWL;
|
|||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||
|
||||
public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper {
|
||||
|
||||
|
||||
long delay = 50;
|
||||
|
||||
|
||||
@Before
|
||||
public void suppressErrorOutput() {
|
||||
suppressSyserr();
|
||||
|
@ -37,10 +37,10 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
@Before public void setup() {
|
||||
ApplicationStub.setup(new ServletContextStub(), new SearchEngineStub());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addABoxAssertion1Test(){
|
||||
addABoxAssertion1(true);
|
||||
addABoxAssertion1(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -50,47 +50,47 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
|
||||
/*
|
||||
* basic scenarios around adding abox data
|
||||
*
|
||||
*
|
||||
* Create a Tbox with property P inverseOf property Q.
|
||||
* Add a statement a P b, and verify that b Q a is inferred.
|
||||
* Add a statement c Q d and verify that d Q c is inferred.
|
||||
* Add a statement c Q d and verify that d Q c is inferred.
|
||||
*/
|
||||
public void addABoxAssertion1(boolean sameAs ) {
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
setInverse(P, Q);
|
||||
|
||||
|
||||
// this is the model to receive abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an abox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox,aBox,inf);
|
||||
sr.setSameAsEnabled( sameAs );
|
||||
|
||||
aBox.register( sr );
|
||||
|
||||
|
||||
// add assertions to the abox and verify inferences
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
Resource c = aBox.createResource("http://test.vivo/c");
|
||||
Resource d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
aBox.add(a,P,b);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
aBox.add(c,Q,d);
|
||||
Assert.assertTrue(inf.contains(d,P,c));
|
||||
|
||||
|
||||
aBox.add(a,P,b);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
aBox.add(c,Q,d);
|
||||
Assert.assertTrue(inf.contains(d,P,c));
|
||||
|
||||
// delete assertions and verify that inferences go away
|
||||
aBox.remove(c,Q,d);
|
||||
Assert.assertFalse(inf.contains(d,P,c));
|
||||
aBox.remove(a,P,b);
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -110,29 +110,29 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
public void addABoxAssertion2(boolean sameAs ) {
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
setInverse(P, Q);
|
||||
|
||||
|
||||
// this is the model to receive abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and add data (no inferencing happening yet)
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
// Individuals a, b, c and d
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
aBox.add(b,Q,a);
|
||||
|
||||
|
||||
// register SimpleReasoner
|
||||
aBox.register(new SimpleReasoner(tBox, aBox, inf));
|
||||
|
||||
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
|
||||
|
||||
// add data and verify inferences
|
||||
aBox.add(a,P,b);
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -149,16 +149,16 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
* (remove the inference when it is asserted)
|
||||
*/
|
||||
public void addABoxAssertion3(boolean sameAs) {
|
||||
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
setInverse(P, Q);
|
||||
|
||||
|
||||
// this is the model to receive abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create abox and register SimpleReasoner
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
|
@ -166,15 +166,15 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
sr.setSameAsEnabled( sameAs );
|
||||
|
||||
aBox.register( sr );
|
||||
|
||||
|
||||
// add statements to the abox and verify inferences
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
|
||||
|
||||
aBox.add(a,P,b);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
aBox.add(b,Q,a); // this should cause the inference to be removed
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -193,38 +193,38 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
public void addABoxAssertion4( boolean sameAs ) {
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty R = createObjectProperty(tBox, "http://test.vivo/R", "property R");
|
||||
setInverse(P, Q);
|
||||
setInverse(R, Q);
|
||||
setEquivalent(R, P);
|
||||
|
||||
|
||||
// this is the model to receive abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( sameAs );
|
||||
aBox.register( sr );
|
||||
|
||||
|
||||
// add abox statements and verify inferences
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
Resource c = aBox.createResource("http://test.vivo/c");
|
||||
Resource d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
aBox.add(a,R,b);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
|
||||
aBox.add(c,Q,d);
|
||||
Assert.assertTrue(inf.contains(d,P,c));
|
||||
Assert.assertTrue(inf.contains(d,R,c));
|
||||
aBox.add(a,R,b);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
|
||||
aBox.add(c,Q,d);
|
||||
Assert.assertTrue(inf.contains(d,P,c));
|
||||
Assert.assertTrue(inf.contains(d,R,c));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void removedABoxAssertion1Test(){
|
||||
removedABoxAssertion1(true);
|
||||
|
@ -237,49 +237,49 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
|
||||
/*
|
||||
* basic scenarios around removing abox data
|
||||
* don't remove an inference if it's still
|
||||
* don't remove an inference if it's still
|
||||
* entailed by something else in the abox.
|
||||
*/
|
||||
*/
|
||||
public void removedABoxAssertion1(boolean sameAs) {
|
||||
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||
setInverse(P, Q);
|
||||
setInverse(P, T);
|
||||
|
||||
|
||||
// this is the model to receive abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( sameAs );
|
||||
aBox.register( sr );
|
||||
|
||||
|
||||
// add statements to the abox and verify inferences
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
Resource c = aBox.createResource("http://test.vivo/c");
|
||||
Resource d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
|
||||
aBox.add(a,P,b);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
|
||||
// d P c is inferred from c Q d and also from c T d
|
||||
aBox.add(c,Q,d);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
|
||||
// d P c is inferred from c Q d and also from c T d
|
||||
aBox.add(c,Q,d);
|
||||
aBox.add(c,T,d);
|
||||
Assert.assertTrue(inf.contains(d,P,c));
|
||||
|
||||
Assert.assertTrue(inf.contains(d,P,c));
|
||||
|
||||
aBox.remove(a,P,b);
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
|
||||
aBox.remove(c,Q,d);
|
||||
|
||||
aBox.remove(c,Q,d);
|
||||
Assert.assertTrue(inf.contains(d,P,c)); // still inferred from c T d
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void removedABoxAssertion2Test(){
|
||||
removedABoxAssertion2(true);
|
||||
|
@ -293,11 +293,11 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
/*
|
||||
* removing abox data with equivalent and inverse properties
|
||||
* don't remove inference if it's still inferred.
|
||||
*/
|
||||
*/
|
||||
public void removedABoxAssertion2(boolean sameAs) {
|
||||
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||
|
@ -307,28 +307,28 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
|
||||
// this is the model to receive abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an abox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( sameAs );
|
||||
aBox.register( sr );
|
||||
|
||||
|
||||
// add abox data and verify inferences
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
|
||||
// b Q a is inferred from a P b and also from a T b.
|
||||
|
||||
// b Q a is inferred from a P b and also from a T b.
|
||||
aBox.add(a,P,b);
|
||||
aBox.add(a,T,b);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
Assert.assertFalse(inf.contains(a,P,b));
|
||||
Assert.assertFalse(inf.contains(a,T,b));
|
||||
|
||||
|
||||
aBox.remove(a,P,b);
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void removedABoxAssertion3Test(){
|
||||
removedABoxAssertion3(true);
|
||||
|
@ -341,18 +341,18 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
|
||||
/*
|
||||
* removing abox data with equivalent and inverse properties
|
||||
*/
|
||||
*/
|
||||
public void removedABoxAssertion3(boolean sameAs) {
|
||||
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
setInverse(P, Q);
|
||||
|
||||
// this is the model to receive abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create the abox and add some data - no reasoning is happening yet
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
|
@ -364,7 +364,7 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( sameAs );
|
||||
aBox.register( sr );
|
||||
|
||||
|
||||
// add abox statements and verify inferences
|
||||
aBox.add(b,Q,a);
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
|
@ -374,7 +374,7 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
Assert.assertTrue(inf.contains(a,P,b)); // now it gets added to inference model
|
||||
// when it's removed from the abox
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addTBoxInverseAssertion1Test() throws InterruptedException {
|
||||
addTBoxInverseAssertion1(true);
|
||||
|
@ -389,9 +389,9 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
* adding an inverseOf assertion to the tbox
|
||||
*/
|
||||
public void addTBoxInverseAssertion1(boolean sameAs) throws InterruptedException {
|
||||
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
|
||||
|
@ -400,11 +400,11 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
|
||||
// abox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
// set up SimpleReasoner and register it with abox. register
|
||||
|
||||
// set up SimpleReasoner and register it with abox. register
|
||||
// SimpleReasonerTBoxListener with the tbox.
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf );
|
||||
simpleReasoner.setSameAsEnabled( sameAs );
|
||||
simpleReasoner.setSameAsEnabled( sameAs );
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
@ -414,32 +414,32 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
Resource b = aBox.createIndividual("http://test.vivo/b", OWL.Thing);
|
||||
Resource c = aBox.createIndividual("http://test.vivo/c", OWL.Thing);
|
||||
Resource d = aBox.createIndividual("http://test.vivo/d", OWL.Thing);
|
||||
|
||||
aBox.add(a,P,b);
|
||||
|
||||
aBox.add(a,P,b);
|
||||
aBox.add(c,P,d);
|
||||
aBox.add(b,Q,a);
|
||||
|
||||
|
||||
// Assert P and Q as inverses and wait for
|
||||
// SimpleReasonerTBoxListener thread to end
|
||||
|
||||
|
||||
setInverse(P, Q);
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
// Verify inferences
|
||||
|
||||
// Verify inferences
|
||||
Assert.assertTrue(inf.contains(d,Q,c));
|
||||
Assert.assertFalse(inf.contains(b,Q,a));
|
||||
Assert.assertFalse(inf.contains(a,P,b));
|
||||
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void removeTBoxInverseAssertion1Test() throws InterruptedException {
|
||||
removeTBoxInverseAssertion1(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeTBoxInverseAssertion1NoSameAsTest() throws InterruptedException {
|
||||
|
@ -450,48 +450,48 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
* removing an inverseOf assertion from the tbox
|
||||
*/
|
||||
public void removeTBoxInverseAssertion1(boolean sameAs) throws InterruptedException {
|
||||
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
setInverse(P, Q);
|
||||
|
||||
|
||||
// this is the model to receive abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
// abox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
// set up SimpleReasoner and SimpleReasonerTBox listener,
|
||||
// register them with abox and tbox
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
simpleReasoner.setSameAsEnabled( sameAs );
|
||||
simpleReasoner.setSameAsEnabled( sameAs );
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
||||
// add statements to the abox and verify inference
|
||||
Resource c = aBox.createIndividual("http://test.vivo/c", OWL.Thing);
|
||||
Resource d = aBox.createIndividual("http://test.vivo/d", OWL.Thing);
|
||||
aBox.add(c,P,d);
|
||||
Assert.assertTrue(inf.contains(d,Q,c));
|
||||
|
||||
|
||||
// Remove P and Q inverse relationship and wait for
|
||||
// SimpleReasoner TBox thread to end.
|
||||
|
||||
|
||||
removeInverse(P, Q);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
// Verify inference has been removed
|
||||
|
||||
// Verify inference has been removed
|
||||
Assert.assertFalse(inf.contains(d,Q,c));
|
||||
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void recomputeABox1Test() throws InterruptedException {
|
||||
recomputeABox1(true);
|
||||
|
@ -506,9 +506,9 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
* Basic scenario around recomputing the ABox inferences
|
||||
*/
|
||||
public void recomputeABox1(boolean sameAs) throws InterruptedException {
|
||||
|
||||
|
||||
// set up the tbox
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
setInverse(P, Q);
|
||||
|
@ -518,12 +518,12 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
|
||||
// create abox and abox inf model and register simplereasoner
|
||||
// with abox.
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
simpleReasoner.setSameAsEnabled( sameAs );
|
||||
aBox.register(simpleReasoner);
|
||||
|
||||
|
||||
// abox statements
|
||||
Resource a = aBox.createIndividual("http://test.vivo/a", OWL.Thing);
|
||||
Resource b = aBox.createIndividual("http://test.vivo/b", OWL.Thing);
|
||||
|
@ -532,44 +532,44 @@ public class SimpleReasonerInversePropertyTest extends SimpleReasonerTBoxHelper
|
|||
|
||||
aBox.add(a,P,b);
|
||||
aBox.add(c,X,d);
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
Assert.assertTrue(inf.contains(d,Y,c));
|
||||
|
||||
Assert.assertTrue(inf.contains(d,Y,c));
|
||||
|
||||
inf.remove(b,Q,a);
|
||||
inf.remove(d,Y,c);
|
||||
|
||||
|
||||
//recompute whole abox
|
||||
simpleReasoner.recompute();
|
||||
|
||||
|
||||
while (simpleReasoner.isRecomputing()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
// Verify inferences
|
||||
|
||||
// Verify inferences
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
Assert.assertTrue(inf.contains(d,Y,c));
|
||||
Assert.assertTrue(inf.contains(d,Y,c));
|
||||
}
|
||||
|
||||
//==================================== Utility methods ====================
|
||||
SimpleReasonerTBoxListener getTBoxListener(SimpleReasoner simpleReasoner) {
|
||||
return new SimpleReasonerTBoxListener(simpleReasoner, new Exception().getStackTrace()[1].getMethodName());
|
||||
}
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModel(Model model, String modelName) {
|
||||
|
||||
|
||||
System.out.println("\nThe " + modelName + " model has " + model.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------------------------");
|
||||
model.write(System.out);
|
||||
model.write(System.out);
|
||||
}
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModel(OntModel ontModel, String modelName) {
|
||||
|
||||
|
||||
System.out.println("\nThe " + modelName + " model has " + ontModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------------------------");
|
||||
ontModel.writeAll(System.out,"N3",null);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,18 +24,18 @@ import org.apache.jena.vocabulary.RDFS;
|
|||
|
||||
public class SimpleReasonerPluginTest extends SimpleReasonerTBoxHelper {
|
||||
long delay = 50;
|
||||
|
||||
|
||||
private final static String DEFAULT_NS = "http://vivoweb.org/individual/";
|
||||
|
||||
|
||||
private final static String DCTERMS_NS = "http://purl.org/dc/terms/";
|
||||
private final static String VIVOCORE_NS = "http://vivoweb.org/ontology/core#";
|
||||
|
||||
|
||||
private final static String creator_URI = DCTERMS_NS + "creator";
|
||||
private final static String authorInAuthorship_URI = VIVOCORE_NS + "authorInAuthorship";
|
||||
private final static String linkedAuthor_URI = VIVOCORE_NS + "linkedAuthor";
|
||||
private final static String informationResourceInAuthorship_URI = VIVOCORE_NS + "informationResourceInAuthorship";
|
||||
private final static String linkedInformationResource_URI = VIVOCORE_NS + "linkedInformationResource";
|
||||
|
||||
|
||||
@Before
|
||||
public void suppressErrorOutput() {
|
||||
//suppressSyserr();
|
||||
|
@ -43,43 +43,43 @@ public class SimpleReasonerPluginTest extends SimpleReasonerTBoxHelper {
|
|||
setLoggerLevel(SimpleReasoner.class, Level.DEBUG);
|
||||
setLoggerLevel(SimpleReasonerTBoxListener.class, Level.DEBUG);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* testing samplePlugin - based on dcterms:creator plugin
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void test1() {
|
||||
OntModel tBox = createTBoxModel();
|
||||
|
||||
OntModel tBox = createTBoxModel();
|
||||
|
||||
OntProperty authorInAuthorship = tBox.createObjectProperty(authorInAuthorship_URI);
|
||||
OntProperty linkedAuthor = tBox.createObjectProperty(linkedAuthor_URI);
|
||||
OntProperty informationResourceInAuthorship = tBox.createObjectProperty(informationResourceInAuthorship_URI);
|
||||
OntProperty linkedInformationResource = tBox.createObjectProperty(linkedInformationResource_URI);
|
||||
|
||||
|
||||
authorInAuthorship.addInverseOf(linkedAuthor);
|
||||
informationResourceInAuthorship.addInverseOf(linkedInformationResource);
|
||||
|
||||
|
||||
Literal title1 = tBox.createLiteral("My Findings");
|
||||
Literal name1 = tBox.createLiteral("Priscilla Powers");
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
aBox.register(simpleReasoner);
|
||||
|
||||
|
||||
// register plugin with SimpleReasoner
|
||||
List<ReasonerPlugin> pluginList = new ArrayList<ReasonerPlugin>();
|
||||
List<ReasonerPlugin> pluginList = new ArrayList<ReasonerPlugin>();
|
||||
String pluginClassName = "edu.cornell.mannlib.vitro.webapp.reasoner.plugin.SamplePlugin";
|
||||
|
||||
|
||||
try {
|
||||
ReasonerPlugin plugin = (ReasonerPlugin) Class.forName(pluginClassName).getConstructors()[0].newInstance();
|
||||
plugin.setSimpleReasoner(simpleReasoner);
|
||||
pluginList.add(plugin);
|
||||
simpleReasoner.setPluginList(pluginList);
|
||||
simpleReasoner.setPluginList(pluginList);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception trying to instantiate plugin: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
@ -87,56 +87,56 @@ public class SimpleReasonerPluginTest extends SimpleReasonerTBoxHelper {
|
|||
}
|
||||
|
||||
Property dctermsCreator = ResourceFactory.createProperty(creator_URI);
|
||||
|
||||
// add abox data for person, authorship and article.
|
||||
|
||||
// add abox data for person, authorship and article.
|
||||
// note, they aren't actually typed in this test tbox
|
||||
Resource prissy = aBox.createResource(DEFAULT_NS + "prissy");
|
||||
|
||||
|
||||
// assert same as
|
||||
|
||||
|
||||
Resource authorship1 = aBox.createResource(DEFAULT_NS + "authorship1");
|
||||
Resource article1 = aBox.createResource(DEFAULT_NS + "article1");
|
||||
Resource article100 = aBox.createResource(DEFAULT_NS + "article100");
|
||||
|
||||
Resource article100 = aBox.createResource(DEFAULT_NS + "article100");
|
||||
|
||||
aBox.add(prissy,RDFS.label,name1);
|
||||
aBox.add(prissy,authorInAuthorship,authorship1);
|
||||
|
||||
|
||||
aBox.add(authorship1,linkedAuthor,prissy);
|
||||
aBox.add(authorship1,linkedInformationResource,article1);
|
||||
|
||||
|
||||
aBox.add(article1,RDFS.label,title1);
|
||||
aBox.add(article1,informationResourceInAuthorship,authorship1);
|
||||
aBox.add(article1, OWL.sameAs, article100);
|
||||
|
||||
Assert.assertTrue(inf.contains(article1,dctermsCreator,prissy));
|
||||
Assert.assertTrue(inf.contains(article100,dctermsCreator,prissy));
|
||||
|
||||
Assert.assertTrue(inf.contains(article100,dctermsCreator,prissy));
|
||||
|
||||
aBox.remove(authorship1,linkedAuthor,prissy);
|
||||
|
||||
|
||||
Assert.assertFalse(inf.contains(article1,dctermsCreator,prissy));
|
||||
Assert.assertFalse(inf.contains(article100,dctermsCreator,prissy));
|
||||
Assert.assertFalse(inf.contains(article100,dctermsCreator,prissy));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================== Utility methods ====================
|
||||
SimpleReasonerTBoxListener getTBoxListener(SimpleReasoner simpleReasoner) {
|
||||
return new SimpleReasonerTBoxListener(simpleReasoner, new Exception().getStackTrace()[1].getMethodName());
|
||||
}
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModel(Model model, String modelName) {
|
||||
|
||||
|
||||
System.out.println("\nThe " + modelName + " model has " + model.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------------------------");
|
||||
model.write(System.out);
|
||||
model.write(System.out);
|
||||
}
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModel(OntModel ontModel, String modelName) {
|
||||
|
||||
|
||||
System.out.println("\nThe " + modelName + " model has " + ontModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------------------------");
|
||||
ontModel.writeAll(System.out,"N3",null);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ import org.apache.jena.vocabulary.RDF;
|
|||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||
|
||||
public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
||||
|
||||
|
||||
long delay = 50;
|
||||
private static final String mostSpecificTypePropertyURI = "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType";
|
||||
|
||||
|
||||
@Before
|
||||
public void suppressErrorOutput() {
|
||||
suppressSyserr();
|
||||
|
@ -36,33 +36,33 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
setLoggerLevel(SimpleReasonerTBoxListener.class, Level.OFF);
|
||||
setLoggerLevel(ABoxRecomputer.class, Level.OFF);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* basic scenario of adding an abox sameAs assertion
|
||||
* basic scenario of adding an abox sameAs assertion
|
||||
//*/
|
||||
@Test
|
||||
public void addSameAsABoxAssertion1() {
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox.register(new SimpleReasoner(tBox, aBox, inf));
|
||||
|
||||
|
||||
// Individuals a, b, c and d
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
Resource c = aBox.createResource("http://test.vivo/c");
|
||||
Resource d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
|
||||
aBox.add(a,P,c);
|
||||
aBox.add(a,S,literal1);
|
||||
aBox.add(b,Q,d);
|
||||
|
@ -80,19 +80,19 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertFalse(aBox.contains(b,S,literal1));
|
||||
Assert.assertFalse(aBox.contains(a,Q,d));
|
||||
Assert.assertFalse(aBox.contains(a,T,literal2));
|
||||
|
||||
|
||||
//run same test with sameAs = false
|
||||
inf = ModelFactory.createDefaultModel();
|
||||
aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner sres = new SimpleReasoner(tBox,aBox,inf);
|
||||
sres.setSameAsEnabled( false );
|
||||
aBox.register(sres);
|
||||
|
||||
|
||||
a = aBox.createResource("http://test.vivo/a");
|
||||
b = aBox.createResource("http://test.vivo/b");
|
||||
c = aBox.createResource("http://test.vivo/c");
|
||||
d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
|
||||
aBox.add(a,P,c);
|
||||
aBox.add(a,S,literal1);
|
||||
aBox.add(b,Q,d);
|
||||
|
@ -112,39 +112,39 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertFalse(aBox.contains(a,Q,d));
|
||||
Assert.assertFalse(aBox.contains(a,T,literal2));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* basic scenario of removing an abox sameAs assertion
|
||||
* basic scenario of removing an abox sameAs assertion
|
||||
*/
|
||||
@Test
|
||||
public void removeSameAsABoxAssertion1() {
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox.register(new SimpleReasoner(tBox, aBox, inf));
|
||||
|
||||
|
||||
// Individuals a, b, c and d
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
Resource c = aBox.createResource("http://test.vivo/c");
|
||||
Resource d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
|
||||
aBox.add(a,P,c);
|
||||
aBox.add(a,S,literal1);
|
||||
aBox.add(b,Q,d);
|
||||
aBox.add(b,T,literal2);
|
||||
aBox.add(a,OWL.sameAs,b);
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(b,OWL.sameAs,a));
|
||||
Assert.assertTrue(inf.contains(b,P,c));
|
||||
Assert.assertTrue(inf.contains(b,S,literal1));
|
||||
|
@ -152,34 +152,34 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertTrue(inf.contains(a,T,literal2));
|
||||
|
||||
aBox.remove(a,OWL.sameAs,b);
|
||||
|
||||
|
||||
Assert.assertFalse(inf.contains(b,OWL.sameAs,a));
|
||||
Assert.assertFalse(inf.contains(b,P,c));
|
||||
Assert.assertFalse(inf.contains(b,S,literal1));
|
||||
Assert.assertFalse(inf.contains(a,Q,d));
|
||||
Assert.assertFalse(inf.contains(a,T,literal2));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* adding abox assertion for individual in sameAs chain.
|
||||
*/
|
||||
@Test
|
||||
public void addABoxAssertion1() {
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox.register(new SimpleReasoner(tBox, aBox, inf));
|
||||
|
||||
|
||||
// Individuals a, b, c and d
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
|
@ -187,7 +187,7 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Resource d = aBox.createResource("http://test.vivo/d");
|
||||
Resource e = aBox.createResource("http://test.vivo/e");
|
||||
Resource f = aBox.createResource("http://test.vivo/f");
|
||||
|
||||
|
||||
aBox.add(a,OWL.sameAs,b);
|
||||
aBox.add(b,OWL.sameAs,e);
|
||||
aBox.add(e,OWL.sameAs,f);
|
||||
|
@ -202,12 +202,12 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertTrue(inf.contains(b,OWL.sameAs,f));
|
||||
Assert.assertTrue(inf.contains(a,OWL.sameAs,f));
|
||||
|
||||
|
||||
|
||||
aBox.add(a,P,c);
|
||||
aBox.add(a,S,literal1);
|
||||
aBox.add(b,Q,d);
|
||||
aBox.add(b,T,literal2);
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(b,P,c));
|
||||
Assert.assertTrue(inf.contains(b,S,literal1));
|
||||
Assert.assertTrue(inf.contains(a,Q,d));
|
||||
|
@ -220,7 +220,7 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertTrue(inf.contains(f,S,literal1));
|
||||
Assert.assertTrue(inf.contains(f,Q,d));
|
||||
Assert.assertTrue(inf.contains(f,T,literal2));
|
||||
|
||||
|
||||
aBox.remove(b,OWL.sameAs,e);
|
||||
|
||||
Assert.assertTrue(inf.contains(b,OWL.sameAs,a));
|
||||
|
@ -244,7 +244,7 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertFalse(inf.contains(f,P,c));
|
||||
Assert.assertFalse(inf.contains(f,S,literal1));
|
||||
Assert.assertFalse(inf.contains(f,Q,d));
|
||||
Assert.assertFalse(inf.contains(f,T,literal2));
|
||||
Assert.assertFalse(inf.contains(f,T,literal2));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,27 +252,27 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
*/
|
||||
@Test
|
||||
public void disabledSameAs() {
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox.register(new SimpleReasoner(tBox, aBox, inf));
|
||||
|
||||
|
||||
// Individuals a, b, c and d
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
Resource c = aBox.createResource("http://test.vivo/c");
|
||||
Resource d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
|
||||
aBox.add(a,P,c);
|
||||
aBox.add(a,S,literal1);
|
||||
aBox.add(b,Q,d);
|
||||
|
@ -290,19 +290,19 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertFalse(aBox.contains(b,S,literal1));
|
||||
Assert.assertFalse(aBox.contains(a,Q,d));
|
||||
Assert.assertFalse(aBox.contains(a,T,literal2));
|
||||
|
||||
|
||||
//run same test with sameAs = false
|
||||
inf = ModelFactory.createDefaultModel();
|
||||
aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner sres = new SimpleReasoner(tBox,aBox,inf);
|
||||
sres.setSameAsEnabled( false );
|
||||
aBox.register(sres);
|
||||
|
||||
|
||||
a = aBox.createResource("http://test.vivo/a");
|
||||
b = aBox.createResource("http://test.vivo/b");
|
||||
c = aBox.createResource("http://test.vivo/c");
|
||||
d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
|
||||
aBox.add(a,P,c);
|
||||
aBox.add(a,S,literal1);
|
||||
aBox.add(b,Q,d);
|
||||
|
@ -328,90 +328,90 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
*/
|
||||
@Test
|
||||
public void addABoxAssertion2() {
|
||||
OntModel tBox = createTBoxModel();
|
||||
|
||||
OntModel tBox = createTBoxModel();
|
||||
|
||||
OntProperty desc = tBox.createDatatypeProperty("http://test.vivo/desc");
|
||||
desc.setLabel("property desc", "en-US");
|
||||
|
||||
|
||||
Literal desc1 = tBox.createLiteral("individual 1");
|
||||
Literal desc2 = tBox.createLiteral("individual 2");
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox.register(new SimpleReasoner(tBox, aBox, inf));
|
||||
|
||||
|
||||
// Individuals a and b
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
|
||||
|
||||
aBox.add(a,desc,desc1);
|
||||
aBox.add(b,desc,desc2);
|
||||
aBox.add(a,OWL.sameAs,b);
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(a,desc,desc2));
|
||||
Assert.assertTrue(inf.contains(b,desc,desc1));
|
||||
Assert.assertTrue(inf.contains(b,OWL.sameAs,a));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* basic scenario of removing an abox assertion for
|
||||
* an individual is sameAs another.
|
||||
* an individual is sameAs another.
|
||||
*/
|
||||
@Test
|
||||
public void removeABoxAssertion1() {
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox.register(new SimpleReasoner(tBox, aBox, inf));
|
||||
|
||||
|
||||
// Individuals a, b, c and d
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
Resource c = aBox.createResource("http://test.vivo/c");
|
||||
Resource d = aBox.createResource("http://test.vivo/d");
|
||||
|
||||
|
||||
aBox.add(a,P,c);
|
||||
aBox.add(a,S,literal1);
|
||||
aBox.add(b,Q,d);
|
||||
aBox.add(b,T,literal2);
|
||||
aBox.add(a,OWL.sameAs,b);
|
||||
|
||||
|
||||
aBox.remove(a,P,c);
|
||||
aBox.remove(a,S,literal1);
|
||||
|
||||
Assert.assertFalse(inf.contains(b,P,c));
|
||||
Assert.assertFalse(inf.contains(b,S,literal1));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* adding and removing an inverseOf assertion for individuals who
|
||||
* are sameAs each other.
|
||||
*/
|
||||
@Test
|
||||
public void tBoxInverseAssertion1() throws InterruptedException {
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
|
||||
// Create ABox and Inference models and register
|
||||
// the ABox reasoner listeners with the ABox and TBox
|
||||
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
|
@ -420,17 +420,17 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
// Individuals a and b
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
|
||||
// abox statements
|
||||
aBox.add(a,P,b);
|
||||
|
||||
// abox statements
|
||||
aBox.add(a,P,b);
|
||||
aBox.add(a, OWL.sameAs,b);
|
||||
|
||||
|
||||
setInverse(Q, P);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(b,Q,a));
|
||||
Assert.assertTrue(inf.contains(b,OWL.sameAs,a));
|
||||
Assert.assertTrue(inf.contains(b,P,b));
|
||||
|
@ -446,11 +446,11 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertTrue(inf.contains(b,OWL.sameAs,a));
|
||||
Assert.assertTrue(inf.contains(b,P,b));
|
||||
Assert.assertFalse(inf.contains(a,Q,a));
|
||||
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* adding and removing a type assertion for an individual who has
|
||||
* a sameAs individual.
|
||||
|
@ -458,31 +458,31 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
@Test
|
||||
public void tBoxTypeAssertion1() {
|
||||
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
addSubclass(classA, classB);
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
aBox.register(new SimpleReasoner(tBox, aBox, inf));
|
||||
|
||||
|
||||
Resource x = aBox.createResource("http://test.vivo/x");
|
||||
Resource y = aBox.createResource("http://test.vivo/y");
|
||||
Resource z = aBox.createResource("http://test.vivo/z");
|
||||
|
||||
|
||||
aBox.add(x,OWL.sameAs,y);
|
||||
aBox.add(y,OWL.sameAs,z);
|
||||
aBox.add(x,RDF.type,classB);
|
||||
|
||||
aBox.add(x,RDF.type,classB);
|
||||
|
||||
Assert.assertTrue(inf.contains(y,RDF.type,classB));
|
||||
Assert.assertTrue(inf.contains(y,RDF.type,classA));
|
||||
Assert.assertTrue(inf.contains(z,RDF.type,classB));
|
||||
Assert.assertTrue(inf.contains(z,RDF.type,classA));
|
||||
|
||||
|
||||
aBox.remove(x,RDF.type,classB);
|
||||
Assert.assertFalse(inf.contains(y,RDF.type,classB));
|
||||
Assert.assertFalse(inf.contains(y,RDF.type,classA));
|
||||
|
@ -491,21 +491,21 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
}
|
||||
|
||||
/*
|
||||
* adding and removing subclass assertion when there is an
|
||||
* adding and removing subclass assertion when there is an
|
||||
* individual member who has a sameAs individual.
|
||||
*/
|
||||
@Test
|
||||
public void tBoxSubclassAssertion1() throws InterruptedException {
|
||||
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
|
||||
//create aBox and SimpleReasoner to listen to them
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
|
@ -515,31 +515,31 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
Resource c = aBox.createResource("http://test.vivo/c");
|
||||
|
||||
aBox.add(a, RDF.type, classC);
|
||||
|
||||
aBox.add(a, RDF.type, classC);
|
||||
aBox.add(a, OWL.sameAs, b);
|
||||
aBox.add(c, OWL.sameAs, a);
|
||||
|
||||
|
||||
// update TBox
|
||||
addSubclass(classA, classB);
|
||||
|
||||
|
||||
// wait for SimpleReasonerTBoxListener thread to end
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
addSubclass(classB, classC);
|
||||
|
||||
|
||||
// wait for SimpleReasonerTBoxListener thread to end
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Verify inferences
|
||||
Assert.assertFalse(inf.contains(a, RDF.type, classC));
|
||||
Assert.assertTrue(inf.contains(a, RDF.type, classB));
|
||||
Assert.assertTrue(inf.contains(a, RDF.type, classA));
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(b, RDF.type, classC));
|
||||
Assert.assertTrue(inf.contains(b, RDF.type, classB));
|
||||
Assert.assertTrue(inf.contains(b, RDF.type, classA));
|
||||
|
@ -555,12 +555,12 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
// Verify inferences
|
||||
|
||||
// Verify inferences
|
||||
Assert.assertFalse(inf.contains(a, RDF.type, classC));
|
||||
Assert.assertTrue(inf.contains(a, RDF.type, classB));
|
||||
Assert.assertFalse(inf.contains(a, RDF.type, classA));
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(b, RDF.type, classC));
|
||||
Assert.assertTrue(inf.contains(b, RDF.type, classB));
|
||||
Assert.assertFalse(inf.contains(b, RDF.type, classA));
|
||||
|
@ -568,20 +568,20 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertTrue(inf.contains(c, RDF.type, classC));
|
||||
Assert.assertTrue(inf.contains(c, RDF.type, classB));
|
||||
Assert.assertFalse(inf.contains(c, RDF.type, classA));
|
||||
|
||||
|
||||
// update TBox
|
||||
removeSubclass(classB, classC);
|
||||
|
||||
|
||||
// wait for SimpleReasonerTBoxListener thread to end
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
// Verify inferences
|
||||
|
||||
// Verify inferences
|
||||
Assert.assertFalse(inf.contains(a, RDF.type, classC));
|
||||
Assert.assertFalse(inf.contains(a, RDF.type, classB));
|
||||
Assert.assertFalse(inf.contains(a, RDF.type, classA));
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(b, RDF.type, classC));
|
||||
Assert.assertFalse(inf.contains(b, RDF.type, classB));
|
||||
Assert.assertFalse(inf.contains(b, RDF.type, classA));
|
||||
|
@ -591,17 +591,17 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertFalse(inf.contains(c, RDF.type, classA));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* test that mostSpecificType inferences propagate to sameAs
|
||||
* test that mostSpecificType inferences propagate to sameAs
|
||||
* individuals
|
||||
*/
|
||||
@Test
|
||||
public void mostSpecificTypeTest1() {
|
||||
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||
|
@ -616,14 +616,14 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
|
||||
// this will receive the abox inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
// abox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
// set up SimpleReasoner and register it with abox
|
||||
// abox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
// set up SimpleReasoner and register it with abox
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
aBox.register(simpleReasoner);
|
||||
|
||||
|
||||
// add & remove ABox type statements and verify inferences
|
||||
Resource a = aBox.createResource("http://test.vivo/a");
|
||||
Resource b = aBox.createResource("http://test.vivo/b");
|
||||
|
@ -633,11 +633,11 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
// Assert a, b, c and d are the same
|
||||
aBox.add(a, OWL.sameAs, b);
|
||||
aBox.add(c, OWL.sameAs, b);
|
||||
aBox.add(d, OWL.sameAs, a);
|
||||
aBox.add(d, OWL.sameAs, a);
|
||||
|
||||
// Assert a is D, and d ic C
|
||||
// All resources will therefore be C and D
|
||||
aBox.add(a, RDF.type, classD);
|
||||
aBox.add(a, RDF.type, classD);
|
||||
aBox.add(d, RDF.type, classC);
|
||||
|
||||
// All resources should be inferred as C and D, except a and d which have direct assertions
|
||||
|
@ -677,86 +677,86 @@ public class SimpleReasonerSameAsTest extends SimpleReasonerTBoxHelper {
|
|||
Assert.assertFalse(inf.contains(b, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
Assert.assertFalse(inf.contains(c, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
Assert.assertFalse(inf.contains(d, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Basic scenario around recomputing the ABox inferences
|
||||
*/
|
||||
@Test
|
||||
public void recomputeABox1() throws InterruptedException {
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntProperty P = createObjectProperty(tBox, "http://test.vivo/P", "property P");
|
||||
OntProperty Q = createObjectProperty(tBox, "http://test.vivo/Q", "property Q");
|
||||
OntProperty S = createObjectProperty(tBox, "http://test.vivo/S", "property S");
|
||||
OntProperty T = createObjectProperty(tBox, "http://test.vivo/T", "property T");
|
||||
Literal literal1 = tBox.createLiteral("Literal value 1");
|
||||
Literal literal2 = tBox.createLiteral("Literal value 2");
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
aBox.register(simpleReasoner);
|
||||
|
||||
|
||||
// Individuals a, b, c and d
|
||||
Resource a = aBox.createIndividual("http://test.vivo/a", OWL.Thing);
|
||||
Resource b = aBox.createIndividual("http://test.vivo/b", OWL.Thing);
|
||||
Resource c = aBox.createIndividual("http://test.vivo/c", OWL.Thing);
|
||||
Resource d = aBox.createIndividual("http://test.vivo/d", OWL.Thing);
|
||||
|
||||
|
||||
aBox.add(a,P,c);
|
||||
aBox.add(a,S,literal1);
|
||||
aBox.add(b,Q,d);
|
||||
aBox.add(b,T,literal2);
|
||||
aBox.add(a,OWL.sameAs,b);
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(b,OWL.sameAs,a));
|
||||
Assert.assertTrue(inf.contains(b,P,c));
|
||||
Assert.assertTrue(inf.contains(b,S,literal1));
|
||||
Assert.assertTrue(inf.contains(a,Q,d));
|
||||
Assert.assertTrue(inf.contains(a,T,literal2));
|
||||
|
||||
|
||||
inf.remove(b,OWL.sameAs,a);
|
||||
inf.remove(b,P,c);
|
||||
inf.remove(b,S,literal1);
|
||||
inf.remove(a,Q,d);
|
||||
inf.remove(a,T,literal2);
|
||||
|
||||
|
||||
simpleReasoner.recompute();
|
||||
|
||||
|
||||
while (simpleReasoner.isRecomputing()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
// Verify inferences
|
||||
|
||||
// Verify inferences
|
||||
Assert.assertTrue(inf.contains(b,OWL.sameAs,a));
|
||||
Assert.assertTrue(inf.contains(b,P,c));
|
||||
Assert.assertTrue(inf.contains(b,S,literal1));
|
||||
Assert.assertTrue(inf.contains(a,Q,d));
|
||||
Assert.assertTrue(inf.contains(a,T,literal2));
|
||||
}
|
||||
|
||||
|
||||
//==================================== Utility methods ====================
|
||||
SimpleReasonerTBoxListener getTBoxListener(SimpleReasoner simpleReasoner) {
|
||||
return new SimpleReasonerTBoxListener(simpleReasoner, new Exception().getStackTrace()[1].getMethodName());
|
||||
}
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModel(Model model, String modelName) {
|
||||
|
||||
|
||||
System.out.println("\nThe " + modelName + " model has " + model.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------------------------");
|
||||
model.write(System.out);
|
||||
model.write(System.out);
|
||||
}
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModel(OntModel ontModel, String modelName) {
|
||||
|
||||
|
||||
System.out.println("\nThe " + modelName + " model has " + ontModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------------------------");
|
||||
ontModel.writeAll(System.out,"N3",null);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,23 +17,23 @@ import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
|||
/**
|
||||
* We're using a simple OntModel as the TBox in the SimpleReasoner tests, so we
|
||||
* don't get tied to a particular TBox reasoner (like Pellet).
|
||||
*
|
||||
*
|
||||
* But the SimpleReasoner expects certain elementary reasoning, so these methods
|
||||
* impose that reasoning on the model.
|
||||
*
|
||||
*
|
||||
* On the model: Thing is a class.
|
||||
*
|
||||
*
|
||||
* On classes: Every class is equivalent to itself, a subclass of itself, and a
|
||||
* subclass of Thing. Every class is a subclass of all its ancestors and a
|
||||
* superclass of all its descendants. Every class has the same superclasses and
|
||||
* subclasses as do all of its equivalent classes.
|
||||
*
|
||||
*
|
||||
* On object properties: Every object property is equivalent to itself and a
|
||||
* subproperty of itself. Every object property has the same inverses as do all
|
||||
* of its equivalent properties.
|
||||
*
|
||||
*
|
||||
* ----------------------
|
||||
*
|
||||
*
|
||||
* It's a little silly to implement this as a parent class of the unit tests. It
|
||||
* would have been nicer to find a way that is more object-oriented but still
|
||||
* explicit in what "reasoning" is performed. This will do for now.
|
||||
|
@ -135,15 +135,15 @@ public class SimpleReasonerTBoxHelper extends AbstractTestClass {
|
|||
|
||||
/**
|
||||
* This has the potential for problems if we set this up:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* A -> B -> C
|
||||
*
|
||||
*
|
||||
* explicit add A -> C
|
||||
*
|
||||
*
|
||||
* remove A -> B
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* But why would we do that?
|
||||
*/
|
||||
private void removeSubclass(Set<OntClass> equivalentParents,
|
||||
|
|
|
@ -24,10 +24,10 @@ import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
|||
|
||||
|
||||
public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
||||
|
||||
|
||||
private static final String mostSpecificTypePropertyURI = "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#mostSpecificType";
|
||||
long delay = 50;
|
||||
|
||||
|
||||
@Before
|
||||
public void suppressErrorOutput() {
|
||||
suppressSyserr();
|
||||
|
@ -35,7 +35,7 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
setLoggerLevel(SimpleReasoner.class, Level.OFF);
|
||||
setLoggerLevel(SimpleReasonerTBoxListener.class, Level.OFF);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addABoxTypeAssertion1Test(){
|
||||
addABoxTypeAssertion1(true);
|
||||
|
@ -50,31 +50,31 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
* its asserted type is not added to the inference graph
|
||||
*/
|
||||
public void addABoxTypeAssertion1( boolean sameAsEnabled ){
|
||||
|
||||
|
||||
// Create a Tbox with a simple class hierarchy. B is a subclass of A.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
classA.addSubClass(classB);
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an ABox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
simpleReasoner.setSameAsEnabled( sameAsEnabled );
|
||||
aBox.register(simpleReasoner);
|
||||
|
||||
// Individual x
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
|
||||
// add a statement to the ABox that individual x is of type (i.e. is an instance of) B.
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
aBox.add(xisb);
|
||||
|
||||
// Verify that "x is of type B" was not inferred
|
||||
Assert.assertFalse(inf.contains(xisb));
|
||||
// Individual x
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
|
||||
// add a statement to the ABox that individual x is of type (i.e. is an instance of) B.
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
aBox.add(xisb);
|
||||
|
||||
// Verify that "x is of type B" was not inferred
|
||||
Assert.assertFalse(inf.contains(xisb));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -91,40 +91,40 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
* of its superclasses
|
||||
*/
|
||||
public void addABoxTypeAssertion2(boolean enableSameAs){
|
||||
|
||||
|
||||
// Create a Tbox with a simple class hierarchy. D and E are subclasses
|
||||
// of C. B and C are subclasses of A.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||
// of C. B and C are subclasses of A.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||
addSubclass(classA, classB);
|
||||
addSubclass(classA, classC);
|
||||
addSubclass(classC, classD);
|
||||
addSubclass(classC, classE);
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an Abox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
aBox.register( sr );
|
||||
|
||||
|
||||
// add a statement to the ABox that individual x is of type E.
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classE);
|
||||
aBox.add(ind_x, RDF.type, classE);
|
||||
|
||||
// Verify that "x is of type C" was inferred
|
||||
Statement xisc = ResourceFactory.createStatement(ind_x, RDF.type, classC);
|
||||
Assert.assertTrue(inf.contains(xisc));
|
||||
|
||||
Statement xisc = ResourceFactory.createStatement(ind_x, RDF.type, classC);
|
||||
Assert.assertTrue(inf.contains(xisc));
|
||||
|
||||
// Verify that "x is of type A" was inferred
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -137,22 +137,22 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
}
|
||||
/*
|
||||
* Test inference based on class equivalence
|
||||
*/
|
||||
*/
|
||||
public void addABoxTypeAssertion3(boolean enableSameAs) throws InterruptedException {
|
||||
|
||||
// Add classes A, B and C to the TBox
|
||||
// A is equivalent to B
|
||||
// C is a subclass of A
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
addSubclass(classA, classC);
|
||||
setEquivalent(classA, classB);
|
||||
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
|
@ -163,22 +163,22 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Add a statement that individual x is of type C to the ABox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classC);
|
||||
|
||||
aBox.add(ind_x, RDF.type, classC);
|
||||
|
||||
// Verify that "x is of type A" was inferred
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
// Verify that "x is of type B" was inferred
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
Assert.assertTrue(inf.contains(xisb));
|
||||
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
Assert.assertTrue(inf.contains(xisb));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addABoxTypeAssertion4Test()throws InterruptedException{
|
||||
addABoxTypeAssertion4(true);
|
||||
|
@ -189,41 +189,41 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
}
|
||||
/*
|
||||
* Test inference based on class equivalence
|
||||
*/
|
||||
*/
|
||||
public void addABoxTypeAssertion4(boolean enableSameAs) throws InterruptedException {
|
||||
|
||||
|
||||
// Add classes A and B to the TBox
|
||||
// A is equivalent to B
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
setEquivalent(classA, classB);
|
||||
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Add a statement that individual x is of type B to the ABox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classB);
|
||||
|
||||
aBox.add(ind_x, RDF.type, classB);
|
||||
|
||||
// Verify that "x is of type A" was inferred
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void addABoxTypeAssertion5Test()throws InterruptedException{
|
||||
|
@ -240,14 +240,14 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
|
||||
// Add classes classes A and B to the TBox
|
||||
// A is equivalent to B
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
setEquivalent(classA, classB);
|
||||
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
|
@ -258,20 +258,20 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Add a statement that individual x is of type B to the ABox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classB);
|
||||
|
||||
aBox.add(ind_x, RDF.type, classB);
|
||||
|
||||
// Verify that "x is of type A" was inferred
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
// Remove the statement that x is of type B from the ABox
|
||||
aBox.remove(ind_x, RDF.type, classB);
|
||||
|
||||
|
||||
// Verify that "x is of type A" was removed from the inference graph
|
||||
Assert.assertFalse(inf.contains(xisa));
|
||||
Assert.assertFalse(inf.contains(xisa));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
@ -293,47 +293,47 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
* should not be retracted.
|
||||
*/
|
||||
public void removeABoxTypeAssertion1(boolean enableSameAs){
|
||||
|
||||
|
||||
// Create a Tbox with a simple class hierarchy. C is a subclass of B
|
||||
// and B is a subclass of A.
|
||||
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
addSubclass(classB, classC);
|
||||
addSubclass(classA, classB);
|
||||
|
||||
|
||||
// this is the model to receive inferences
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
// create an Abox and register the SimpleReasoner listener with it
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
aBox.register( sr );
|
||||
|
||||
|
||||
// add a statement to the ABox that individual x is of type C.
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classC);
|
||||
aBox.add(ind_x, RDF.type, classC);
|
||||
|
||||
// add a statement to the ABox that individual x is of type B.
|
||||
aBox.add(ind_x, RDF.type, classB);
|
||||
aBox.add(ind_x, RDF.type, classB);
|
||||
|
||||
// remove the statement that individual x is of type C
|
||||
aBox.remove(ind_x, RDF.type, classC);
|
||||
|
||||
|
||||
// Verify that the inference graph contains the statement that x is of type A.
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
// Hopefully the assertion that x is b got removed from
|
||||
// the inference graph
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
Assert.assertFalse(inf.contains(xisb));
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
Assert.assertFalse(inf.contains(xisb));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addTBoxSubClassAssertion1Test()throws InterruptedException{
|
||||
addTBoxSubClassAssertion1(true);
|
||||
|
@ -343,15 +343,15 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
addTBoxSubClassAssertion1(false);
|
||||
}
|
||||
/*
|
||||
* Test the addition of a subClassOf statement to
|
||||
* Test the addition of a subClassOf statement to
|
||||
* the TBox. The instance data that is the basis
|
||||
* for the inference is in the ABox. The existing
|
||||
* instance of the newly declared subclass should
|
||||
* be inferred to have the type of the superclass.
|
||||
* be inferred to have the type of the superclass.
|
||||
* There are also a few checks that the instance
|
||||
* is not inferred to have the types of some other
|
||||
* random classes.
|
||||
*
|
||||
*
|
||||
* Since the addition of an owl:equivalentClass
|
||||
* statement is implemented as two calls to the
|
||||
* method that handles the addition of an
|
||||
|
@ -360,17 +360,17 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
*/
|
||||
public void addTBoxSubClassAssertion1(boolean enableSameAs) throws InterruptedException {
|
||||
// Create the TBox and add classes A, B, C and D
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
|
||||
// Create ABox and Inference models and register
|
||||
// the ABox reasoner listeners with the ABox and TBox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
|
@ -380,27 +380,27 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
|
||||
// Add a statement that individual x is of type C to the ABox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classC);
|
||||
|
||||
// Add a statement that C is a subclass of A to the TBox
|
||||
aBox.add(ind_x, RDF.type, classC);
|
||||
|
||||
// Add a statement that C is a subclass of A to the TBox
|
||||
addSubclass(classA, classC);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Verify that "x is of type A" was inferred
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
// Verify that "x is of type B" was not inferred
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
Assert.assertFalse(inf.contains(xisb));
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
Assert.assertFalse(inf.contains(xisb));
|
||||
|
||||
// Verify that "x is of type D" was not inferred
|
||||
Statement xisd = ResourceFactory.createStatement(ind_x, RDF.type, classD);
|
||||
Assert.assertFalse(inf.contains(xisd));
|
||||
|
||||
Statement xisd = ResourceFactory.createStatement(ind_x, RDF.type, classD);
|
||||
Assert.assertFalse(inf.contains(xisd));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
@ -413,67 +413,67 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
addTBoxSubClassAssertion2(false);
|
||||
}
|
||||
/*
|
||||
* Test the addition of a subClassOf statement to
|
||||
* Test the addition of a subClassOf statement to
|
||||
* the TBox. The instance data that is the basis
|
||||
* for the inference is in the ABox graph and the
|
||||
* inference graph. The existing instance of the
|
||||
* subclass of the newly added subclass should
|
||||
* be inferred to have the type of the superclass
|
||||
* of the newly added subclass.
|
||||
*
|
||||
* of the newly added subclass.
|
||||
*
|
||||
* Since the addition of an owl:equivalentClass
|
||||
* statement is implemented as two calls to the
|
||||
* method that handles the addition of an
|
||||
* rdfs:subClassOf statement, this test serves
|
||||
* as some test of equivalentClass statements also.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void addTBoxSubClassAssertion2(boolean enableSameAs) throws InterruptedException {
|
||||
|
||||
|
||||
// Create the TBox and add classes A, B, C and D.
|
||||
// D is a subclass of C.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
addSubclass(classC, classD);
|
||||
|
||||
|
||||
// Create ABox and Inference models and register
|
||||
// the ABox reasoner listeners with the ABox and TBox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Add a statement that individual x is of type D to the ABox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classD);
|
||||
|
||||
// Add a statement that C is a subclass of A to the TBox
|
||||
aBox.add(ind_x, RDF.type, classD);
|
||||
|
||||
// Add a statement that C is a subclass of A to the TBox
|
||||
addSubclass(classA, classC);
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Verify that "x is of type A" was inferred
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(xisa));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void removeTBoxSubClassAssertion1Test()throws InterruptedException{
|
||||
removeTBoxSubClassAssertion1(true);
|
||||
|
@ -483,11 +483,11 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
removeTBoxSubClassAssertion1(false);
|
||||
}
|
||||
/*
|
||||
* Test the removal of a subClassOf statement from
|
||||
* Test the removal of a subClassOf statement from
|
||||
* the TBox. The instance data that is the basis
|
||||
* for the inference is in the ABox graph and the
|
||||
* inference graph.
|
||||
*
|
||||
* inference graph.
|
||||
*
|
||||
*/
|
||||
public void removeTBoxSubClassAssertion1(boolean enableSameAs) throws InterruptedException {
|
||||
// Create the TBox and add classes A, B, C, D, E, F, G and H.
|
||||
|
@ -495,10 +495,10 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
// E is a subclass of B.
|
||||
// F and G are subclasses of C.
|
||||
// H is a subclass of D.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||
OntClass classF = createClass(tBox, "http://test.vivo/F", "class F");
|
||||
|
@ -511,12 +511,12 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
addSubclass(classC, classF);
|
||||
addSubclass(classC, classG);
|
||||
addSubclass(classD, classH);
|
||||
|
||||
|
||||
// Create ABox and Inference models and register
|
||||
// the ABox reasoner listeners with the ABox and TBox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
|
@ -527,45 +527,45 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Add a statement that individual x is of type E to the ABox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classE);
|
||||
|
||||
aBox.add(ind_x, RDF.type, classE);
|
||||
|
||||
// Remove the statement that B is a subclass of A from the TBox
|
||||
removeSubclass(classA, classB);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Verify that "x is of type A" is not in the inference graph
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Statement xisa = ResourceFactory.createStatement(ind_x, RDF.type, classA);
|
||||
Assert.assertFalse(inf.contains(xisa));
|
||||
|
||||
|
||||
// Verify that "x is of type B" is in the inference graph
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
Assert.assertTrue(inf.contains(xisb));
|
||||
Statement xisb = ResourceFactory.createStatement(ind_x, RDF.type, classB);
|
||||
Assert.assertTrue(inf.contains(xisb));
|
||||
|
||||
// Add statements that individual y is of types F and H to the ABox
|
||||
Resource ind_y = aBox.createResource("http://test.vivo/y");
|
||||
aBox.add(ind_y, RDF.type, classF);
|
||||
aBox.add(ind_y, RDF.type, classF);
|
||||
aBox.add(ind_y, RDF.type, classH);
|
||||
|
||||
|
||||
// Remove the statement that C is a subclass of A from the TBox
|
||||
classA.removeSubClass(classC);
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Verify that "y is of type A" is in the inference graph
|
||||
Statement yisa = ResourceFactory.createStatement(ind_y, RDF.type, classA);
|
||||
Statement yisa = ResourceFactory.createStatement(ind_y, RDF.type, classA);
|
||||
Assert.assertTrue(inf.contains(yisa));
|
||||
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
@Ignore(" needs TBoxReasoner infrastructure which is not in this suite.")
|
||||
@Test
|
||||
public void bcdTest()throws InterruptedException{
|
||||
|
@ -578,11 +578,11 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
bcd(false);
|
||||
}
|
||||
/*
|
||||
* Test the removal of a subClassOf statement from
|
||||
* Test the removal of a subClassOf statement from
|
||||
* the TBox. The instance data that is the basis
|
||||
* for the inference is in the ABox graph and the
|
||||
* inference graph.
|
||||
*
|
||||
* inference graph.
|
||||
*
|
||||
*/
|
||||
// this test would need TBoxReasoner infrastructure, which we're not
|
||||
// testing in this suite. The reason it doesn't work as it is because
|
||||
|
@ -594,15 +594,15 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
|
||||
// Create ABox and Inference models and register
|
||||
// the ABox reasoner listeners with the ABox and TBox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(tBox, aBox, inf);
|
||||
simpleReasoner.setSameAsEnabled( enableSameAs );
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
||||
|
||||
// Add classes LivingThing, Flora, Brassica to the TBox
|
||||
// Brassica is a subClass of Flora and Flora is a subclass of Brassica
|
||||
OntClass LivingThing = createClass(tBox, "http://test.vivo/LivingThing", "Living Thing");
|
||||
|
@ -610,18 +610,18 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
OntClass Brassica = createClass(tBox, "http://test.vivo/Brassica", "Brassica");
|
||||
addSubclass(LivingThing, Flora);
|
||||
addSubclass(Flora, Brassica);
|
||||
|
||||
|
||||
tBox.rebind();
|
||||
tBox.prepare();
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Add a statement that individual kale is of type Brassica to the ABox
|
||||
Resource kale = aBox.createResource("http://test.vivo/kale");
|
||||
aBox.add(kale, RDF.type, Brassica);
|
||||
|
||||
aBox.add(kale, RDF.type, Brassica);
|
||||
|
||||
// Remove the statement that Brassica is a subclass of Flora from the TBox
|
||||
Flora.removeSubClass(Brassica);
|
||||
|
||||
|
@ -630,18 +630,18 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Verify that "kale is of type Flora" is not in the inference graph
|
||||
Statement kaleIsFlora = ResourceFactory.createStatement(kale, RDF.type, Flora);
|
||||
Statement kaleIsFlora = ResourceFactory.createStatement(kale, RDF.type, Flora);
|
||||
Assert.assertFalse(inf.contains(kaleIsFlora));
|
||||
|
||||
|
||||
// Verify that "kale is of type LivingThing" is not in the inference graph
|
||||
Statement kaleIsLivingThing = ResourceFactory.createStatement(kale, RDF.type, LivingThing);
|
||||
Statement kaleIsLivingThing = ResourceFactory.createStatement(kale, RDF.type, LivingThing);
|
||||
Assert.assertFalse(inf.contains(kaleIsLivingThing));
|
||||
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void mstTest1Test()throws InterruptedException{
|
||||
mstTest1(true);
|
||||
|
@ -657,10 +657,10 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
public void mstTest1(boolean enableSameAs) throws InterruptedException {
|
||||
// Set up the Tbox with a class hierarchy. C is a subclass of A
|
||||
// and Y. D and E are subclasses of C. B is a subclass of D.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||
OntClass classY = createClass(tBox, "http://test.vivo/Y", "class Y");
|
||||
|
@ -672,44 +672,44 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
|
||||
// Create ABox and Inference models and register
|
||||
// the ABox reasoner listeners with the ABox and TBox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
||||
|
||||
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Add the statement individual x is of type Y to the ABox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classD);
|
||||
|
||||
aBox.add(ind_x, RDF.type, classD);
|
||||
|
||||
// Verify ind_x mostSpecificType annotation for D
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
|
||||
// Verify ind_x doesn't have a mostSpecificType annotation for
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
|
||||
// Verify ind_x doesn't have a mostSpecificType annotation for
|
||||
// A, Y, C, E or B.
|
||||
Assert.assertFalse(aBox.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classA.getURI())));
|
||||
Assert.assertFalse(aBox.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classA.getURI())));
|
||||
Assert.assertFalse(aBox.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classY.getURI())));
|
||||
Assert.assertFalse(aBox.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classC.getURI())));
|
||||
Assert.assertFalse(aBox.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classC.getURI())));
|
||||
Assert.assertFalse(aBox.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classE.getURI())));
|
||||
Assert.assertFalse(aBox.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classB.getURI())));
|
||||
|
||||
Assert.assertFalse(aBox.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classB.getURI())));
|
||||
|
||||
aBox.remove(ind_x, RDF.type, classD); // retract assertion that x is of type D.
|
||||
// Verify that D is not longer the most specific type
|
||||
Assert.assertFalse(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
|
||||
Assert.assertFalse(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void mstTest2Test()throws InterruptedException{
|
||||
|
@ -726,43 +726,43 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
public void mstTest2(boolean enableSameAs) throws InterruptedException {
|
||||
// Set up the Tbox with a class hierarchy. A, B, and C are all equivalent.
|
||||
// This implies that they are all subclasses of each other.
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
setEquivalent(classA, classB);
|
||||
setEquivalent(classB, classC);
|
||||
|
||||
// Create ABox and Inference models and register
|
||||
// the ABox reasoner listeners with the ABox and TBox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
||||
|
||||
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// Add the statement individual x is of type B to the ABox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
aBox.add(ind_x, RDF.type, classB);
|
||||
|
||||
aBox.add(ind_x, RDF.type, classB);
|
||||
|
||||
// Verify ind_x mostSpecificType annotation for A, B and C
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classA.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classB.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classC.getURI())));
|
||||
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classA.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classB.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classC.getURI())));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void mstTest3Test()throws InterruptedException{
|
||||
mstTest3(true);
|
||||
|
@ -777,52 +777,52 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
*/
|
||||
public void mstTest3(boolean enableSameAs) throws InterruptedException {
|
||||
// Set up the Tbox with classes A, B, C, D, E, F and G
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||
OntClass classF = createClass(tBox, "http://test.vivo/F", "class F");
|
||||
OntClass classG = createClass(tBox, "http://test.vivo/G", "class G");
|
||||
OntModel tBox = createTBoxModel();
|
||||
OntClass classA = createClass(tBox, "http://test.vivo/A", "class A");
|
||||
OntClass classB = createClass(tBox, "http://test.vivo/B", "class B");
|
||||
OntClass classC = createClass(tBox, "http://test.vivo/C", "class C");
|
||||
OntClass classD = createClass(tBox, "http://test.vivo/D", "class D");
|
||||
OntClass classE = createClass(tBox, "http://test.vivo/E", "class E");
|
||||
OntClass classF = createClass(tBox, "http://test.vivo/F", "class F");
|
||||
OntClass classG = createClass(tBox, "http://test.vivo/G", "class G");
|
||||
|
||||
// Create ABox and Inference models and register
|
||||
// the ABox reasoner listeners with the ABox and TBox
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
OntModel aBox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||
Model inf = ModelFactory.createDefaultModel();
|
||||
|
||||
|
||||
SimpleReasoner sr = new SimpleReasoner(tBox, aBox, inf);
|
||||
sr.setSameAsEnabled( enableSameAs );
|
||||
SimpleReasoner simpleReasoner = sr ;
|
||||
aBox.register(simpleReasoner);
|
||||
SimpleReasonerTBoxListener simpleReasonerTBoxListener = getTBoxListener(simpleReasoner);
|
||||
tBox.register(simpleReasonerTBoxListener);
|
||||
|
||||
|
||||
OntClass OWL_THING = tBox.createClass(OWL.Thing.getURI());
|
||||
AnnotationProperty mostSpecificType = tBox.createAnnotationProperty(mostSpecificTypePropertyURI);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
// add individuals x, y and z to the aBox
|
||||
Resource ind_x = aBox.createResource("http://test.vivo/x");
|
||||
Resource ind_y = aBox.createResource("http://test.vivo/y");
|
||||
|
||||
aBox.add(ind_x, RDF.type, OWL_THING);
|
||||
aBox.add(ind_y, RDF.type, classD);
|
||||
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(OWL.Thing.getURI())));
|
||||
|
||||
aBox.add(ind_x, RDF.type, OWL_THING);
|
||||
aBox.add(ind_y, RDF.type, classD);
|
||||
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(OWL.Thing.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
|
||||
|
||||
aBox.add(ind_x, RDF.type, classC);
|
||||
aBox.add(ind_y, RDF.type, classF);
|
||||
|
||||
Assert.assertFalse(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(OWL.Thing.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classC.getURI())));
|
||||
|
||||
Assert.assertFalse(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(OWL.Thing.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_x, mostSpecificType, ResourceFactory.createResource(classC.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classF.getURI())));
|
||||
|
||||
|
||||
// Set up a class hierarchy.
|
||||
addSubclass(classA, classB);
|
||||
addSubclass(classA, classC);
|
||||
|
@ -830,45 +830,45 @@ public class SimpleReasonerTest extends SimpleReasonerTBoxHelper {
|
|||
addSubclass(classC, classE);
|
||||
addSubclass(classD, classF);
|
||||
addSubclass(classD, classG);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
|
||||
Assert.assertFalse(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
Assert.assertTrue(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classF.getURI())));
|
||||
|
||||
|
||||
// If F is removed as a subclass of D, then D should once again be a most specific type
|
||||
// for y.
|
||||
removeSubclass(classD, classF);
|
||||
|
||||
|
||||
while (!VitroBackgroundThread.getLivingThreads().isEmpty()) {
|
||||
Thread.sleep(delay);
|
||||
}
|
||||
|
||||
Assert.assertTrue(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
|
||||
|
||||
Assert.assertTrue(inf.contains(ind_y, mostSpecificType, ResourceFactory.createResource(classD.getURI())));
|
||||
|
||||
simpleReasonerTBoxListener.setStopRequested();
|
||||
}
|
||||
|
||||
|
||||
SimpleReasonerTBoxListener getTBoxListener(SimpleReasoner simpleReasoner) {
|
||||
return new SimpleReasonerTBoxListener(simpleReasoner, new Exception().getStackTrace()[1].getMethodName());
|
||||
}
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModel(Model model, String modelName) {
|
||||
|
||||
|
||||
System.out.println("\nThe " + modelName + " model has " + model.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------------------------");
|
||||
model.write(System.out);
|
||||
model.write(System.out);
|
||||
}
|
||||
|
||||
|
||||
// To help in debugging the unit test
|
||||
void printModel(OntModel ontModel, String modelName) {
|
||||
|
||||
|
||||
System.out.println("\nThe " + modelName + " model has " + ontModel.size() + " statements:");
|
||||
System.out.println("---------------------------------------------------------------------");
|
||||
ontModel.writeAll(System.out,"N3",null);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ package edu.cornell.mannlib.vitro.webapp.reasoner.plugin;
|
|||
import edu.cornell.mannlib.vitro.webapp.reasoner.ReasonerPlugin;
|
||||
|
||||
public class SamplePlugin extends SimpleBridgingRule implements ReasonerPlugin {
|
||||
|
||||
|
||||
private final static String DCTERMS = "http://purl.org/dc/terms/";
|
||||
private final static String VIVOCORE = "http://vivoweb.org/ontology/core#";
|
||||
|
||||
|
||||
public SamplePlugin() {
|
||||
super(VIVOCORE + "informationResourceInAuthorship",
|
||||
super(VIVOCORE + "informationResourceInAuthorship",
|
||||
VIVOCORE + "linkedAuthor",
|
||||
DCTERMS + "creator");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package edu.cornell.mannlib.vitro.webapp.search.controller;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMa
|
|||
import edu.cornell.mannlib.vitro.webapp.search.controller.PagedSearchController.PagingLink;
|
||||
|
||||
public class PagedSearchControllerTest {
|
||||
|
||||
|
||||
@Before
|
||||
public void useI18nStubBundles() {
|
||||
I18nStub.setup();
|
||||
|
@ -25,14 +25,14 @@ public class PagedSearchControllerTest {
|
|||
|
||||
@Test
|
||||
public void testGetPagingLinks() {
|
||||
ParamMap pm = new ParamMap();
|
||||
ParamMap pm = new ParamMap();
|
||||
int hitsPerPage = 25;
|
||||
int totalHits = 500;
|
||||
int currentStartIndex = 0;
|
||||
List<PagingLink> pageLinks = PagedSearchController.getPagingLinks(currentStartIndex, hitsPerPage, totalHits, "baseURL", pm, null);
|
||||
Assert.assertNotNull(pageLinks);
|
||||
Assert.assertEquals(500 / 25, pageLinks.size());
|
||||
|
||||
|
||||
//test for no page links on a very short result
|
||||
hitsPerPage = 25;
|
||||
totalHits = 10;
|
||||
|
@ -41,25 +41,25 @@ public class PagedSearchControllerTest {
|
|||
Assert.assertNotNull(pageLinks);
|
||||
Assert.assertEquals(0, pageLinks.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetPagingLinksForLargeResults() {
|
||||
ParamMap pm = new ParamMap();
|
||||
ParamMap pm = new ParamMap();
|
||||
int hitsPerPage = 25;
|
||||
int totalHits = 349909;
|
||||
int currentStartIndex = 0;
|
||||
List<PagingLink> pageLinks = PagedSearchController.getPagingLinks(currentStartIndex, hitsPerPage, totalHits, "baseURL", pm, null);
|
||||
Assert.assertNotNull(pageLinks);
|
||||
Assert.assertEquals( PagedSearchController.DEFAULT_MAX_HIT_COUNT / hitsPerPage, pageLinks.size());
|
||||
|
||||
|
||||
//test for large sets of results with high start index
|
||||
hitsPerPage = 25;
|
||||
totalHits = PagedSearchController.DEFAULT_MAX_HIT_COUNT + 20329;
|
||||
currentStartIndex = PagedSearchController.DEFAULT_MAX_HIT_COUNT + 5432;
|
||||
pageLinks = PagedSearchController.getPagingLinks(currentStartIndex, hitsPerPage, totalHits, "baseURL", pm, null);
|
||||
Assert.assertNotNull(pageLinks);
|
||||
Assert.assertEquals(
|
||||
(currentStartIndex / hitsPerPage) + //all the pages that are before the current page
|
||||
Assert.assertEquals(
|
||||
(currentStartIndex / hitsPerPage) + //all the pages that are before the current page
|
||||
(PagedSearchController.DEFAULT_MAX_HIT_COUNT / hitsPerPage) + //some pages after the current apge
|
||||
1, //for the more... page
|
||||
pageLinks.size());
|
||||
|
|
|
@ -32,7 +32,7 @@ public class BaseSearchInputDocumentTest {
|
|||
SearchInputField field2 = new BaseSearchInputField("anotherField");
|
||||
field2.setBoost(-16F);
|
||||
doc.addField(field2);
|
||||
|
||||
|
||||
BaseSearchInputDocument other = new BaseSearchInputDocument(doc);
|
||||
assertEquals(doc, other);
|
||||
assertEquals(doc.getDocumentBoost(), other.getDocumentBoost(), 0.01F);
|
||||
|
|
|
@ -32,7 +32,7 @@ import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
|||
public class ThumbnailImageURLTest extends AbstractTestClass{
|
||||
ContextModelAccessStub contextModels;
|
||||
String personsURI = "http://vivo.cornell.edu/individual/individual8803";
|
||||
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
|
@ -41,9 +41,9 @@ public class ThumbnailImageURLTest extends AbstractTestClass{
|
|||
setLoggerLevel(RDFDefaultErrorHandler.class, Level.OFF);
|
||||
ApplicationStub.setup(new ServletContextStub(), new SearchEngineStub());
|
||||
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
InputStream in = ThumbnailImageURLTest.class.getResourceAsStream("testPerson.n3");
|
||||
model.read(in,"","N3");
|
||||
model.read(in,"","N3");
|
||||
contextModels = new ContextModelAccessStub();
|
||||
contextModels.setRDFService(CONTENT, new RDFServiceModel( model ));
|
||||
}
|
||||
|
@ -59,18 +59,18 @@ public class ThumbnailImageURLTest extends AbstractTestClass{
|
|||
testMe.setContextModels(contextModels);
|
||||
Individual ind = new IndividualImpl();
|
||||
ind.setURI(personsURI);
|
||||
|
||||
|
||||
//make sure that the person is in the RDF
|
||||
testMe.modifyDocument(ind, doc);
|
||||
|
||||
//make sure that a search document field got created for the thumbnail image
|
||||
|
||||
|
||||
SearchInputField thumbnailField = doc.getField( VitroSearchTermNames.THUMBNAIL_URL );
|
||||
Assert.assertNotNull(thumbnailField);
|
||||
|
||||
Assert.assertNotNull( thumbnailField.getValues() );
|
||||
Assert.assertEquals(1, thumbnailField.getValues().size());
|
||||
|
||||
|
||||
Assert.assertEquals("http://vivo.cornell.edu/individual/n54945", thumbnailField.getFirstValue());
|
||||
}
|
||||
|
||||
|
|
|
@ -17,70 +17,70 @@ public class ExcludeBasedOnTypeTest {
|
|||
|
||||
@Test
|
||||
public void testCheckForExclusion() {
|
||||
|
||||
|
||||
ExcludeBasedOnType ebot = new ExcludeBasedOnType();
|
||||
ebot.addTypeToExclude("http://xmlns.com/foaf/0.1/Person");
|
||||
|
||||
|
||||
IndividualImpl ind = new IndividualImpl();
|
||||
ind.setURI("http://example.com/n2343");
|
||||
|
||||
VClass personClass = new VClass("http://xmlns.com/foaf/0.1/Person");
|
||||
ind.setVClasses(Collections.singletonList(personClass), false);
|
||||
|
||||
VClass personClass = new VClass("http://xmlns.com/foaf/0.1/Person");
|
||||
ind.setVClasses(Collections.singletonList(personClass), false);
|
||||
|
||||
String excludeResult = ebot.checkForExclusion(ind);
|
||||
assertNotNull( excludeResult );
|
||||
assertNotNull( excludeResult );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckForExclusion2() {
|
||||
|
||||
|
||||
ExcludeBasedOnType ebot = new ExcludeBasedOnType();
|
||||
ebot.addTypeToExclude("http://example.com/KillerRobot");
|
||||
|
||||
|
||||
IndividualImpl ind = new IndividualImpl();
|
||||
ind.setURI("http://example.com/n2343");
|
||||
|
||||
|
||||
List<VClass> vClassList = new ArrayList<VClass>();
|
||||
vClassList.add( new VClass("http://xmlns.com/foaf/0.1/Agent"));
|
||||
vClassList.add( new VClass("http://example.com/Robot"));
|
||||
vClassList.add( new VClass("http://example.com/KillerRobot"));
|
||||
vClassList.add( new VClass("http://example.com/Droid"));
|
||||
ind.setVClasses(vClassList, false);
|
||||
|
||||
|
||||
String excludeResult = ebot.checkForExclusion(ind);
|
||||
assertNotNull( excludeResult );
|
||||
assertNotNull( excludeResult );
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCheckForNonExclusion() {
|
||||
ExcludeBasedOnType ebot = new ExcludeBasedOnType();
|
||||
ebot.addTypeToExclude("http://xmlns.com/foaf/0.1/Person");
|
||||
|
||||
|
||||
IndividualImpl ind = new IndividualImpl();
|
||||
ind.setURI("http://example.com/n2343");
|
||||
VClass personClass = new VClass("http://xmlns.com/foaf/0.1/Robot");
|
||||
ind.setVClasses(Collections.singletonList(personClass), false);
|
||||
|
||||
VClass personClass = new VClass("http://xmlns.com/foaf/0.1/Robot");
|
||||
ind.setVClasses(Collections.singletonList(personClass), false);
|
||||
|
||||
String excludeResult = ebot.checkForExclusion(ind);
|
||||
assertNull( excludeResult );
|
||||
assertNull( excludeResult );
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCheckForNonExclusion2() {
|
||||
public void testCheckForNonExclusion2() {
|
||||
ExcludeBasedOnType ebot = new ExcludeBasedOnType();
|
||||
ebot.addTypeToExclude("http://xmlns.com/foaf/0.1/Person");
|
||||
|
||||
|
||||
IndividualImpl ind = new IndividualImpl();
|
||||
ind.setURI("http://example.com/n2343");
|
||||
|
||||
|
||||
List<VClass> vClassList = new ArrayList<VClass>();
|
||||
vClassList.add( new VClass("http://xmlns.com/foaf/0.1/Agent"));
|
||||
vClassList.add( new VClass("http://example.com/Robot"));
|
||||
vClassList.add( new VClass("http://example.com/KillerRobot"));
|
||||
vClassList.add( new VClass("http://example.com/Droid"));
|
||||
ind.setVClasses(vClassList, false);
|
||||
|
||||
|
||||
String excludeResult = ebot.checkForExclusion(ind);
|
||||
assertNull( excludeResult );
|
||||
assertNull( excludeResult );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,40 +37,40 @@ public class AdditionalURIsForClassGroupChangesTest {
|
|||
public void testFindAdditionalURIsToIndex() {
|
||||
OntModel model = ModelFactory.createOntologyModel();
|
||||
model.read( new StringReader(n3ForPresentationClass), null, "N3");
|
||||
|
||||
|
||||
ContextModelAccessStub models = new ContextModelAccessStub();
|
||||
models.setOntModel(ModelNames.TBOX_ASSERTIONS, model);
|
||||
|
||||
|
||||
AdditionalURIsForClassGroupChanges uriFinder = new AdditionalURIsForClassGroupChanges( );
|
||||
uriFinder.setContextModels(models);
|
||||
|
||||
List<String> uris = uriFinder.findAdditionalURIsToIndex(
|
||||
|
||||
List<String> uris = uriFinder.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource("http://vivoweb.org/ontology/core#Presentation"),
|
||||
ResourceFactory.createProperty(VitroVocabulary.IN_CLASSGROUP),
|
||||
ResourceFactory.createResource("http://example.com/someClassGroup")));
|
||||
|
||||
|
||||
Assert.assertNotNull(uris);
|
||||
Assert.assertTrue("uris list is empty", uris.size() > 0 );
|
||||
|
||||
|
||||
Assert.assertTrue(uris.contains("http://vivo.scripps.edu/individual/n400"));
|
||||
Assert.assertTrue(uris.contains("http://vivo.scripps.edu/individual/n12400"));
|
||||
Assert.assertTrue(uris.contains("http://vivo.scripps.edu/individual/n210"));
|
||||
Assert.assertTrue(uris.contains("http://vivo.scripps.edu/individual/n264"));
|
||||
Assert.assertTrue(uris.contains("http://vivo.scripps.edu/individual/n25031"));
|
||||
Assert.assertTrue(uris.contains("http://vivo.scripps.edu/individual/n2486"));
|
||||
|
||||
|
||||
Assert.assertTrue("uris list should not contain n9999",!uris.contains("http://vivo.scripps.edu/individual/n9999"));
|
||||
Assert.assertTrue("uris list should not contain n9998",!uris.contains("http://vivo.scripps.edu/individual/n9998"));
|
||||
|
||||
|
||||
// Assert.assertTrue("uris didn't not contain test:onions", uris.contains(testNS+"onions"));
|
||||
// Assert.assertTrue("uris didn't not contain test:cheese", uris.contains(testNS+"cheese"));
|
||||
// Assert.assertTrue("uris didn't not contain test:icecream", uris.contains(testNS+"icecream"));
|
||||
//
|
||||
//
|
||||
// Assert.assertTrue("uris contained test:Person", !uris.contains(testNS+"Person"));
|
||||
// Assert.assertTrue("uris contained owl:Thing", !uris.contains( OWL.Thing.getURI() ));
|
||||
// Assert.assertTrue("uris contained owl:Thing", !uris.contains( OWL.Thing.getURI() ));
|
||||
}
|
||||
String n3ForPresentationClass =
|
||||
String n3ForPresentationClass =
|
||||
"@prefix dc: <http://purl.org/dc/elements/1.1/> . \n" +
|
||||
"@prefix pvs: <http://vivoweb.org/ontology/provenance-support#> . \n" +
|
||||
"@prefix geo: <http://aims.fao.org/aos/geopolitical.owl#> . \n" +
|
||||
|
@ -136,16 +136,16 @@ String n3ForPresentationClass =
|
|||
" a core:Presentation ; \n" +
|
||||
" vitro:mostSpecificType \n" +
|
||||
" core:Presentation . \n" +
|
||||
" \n " +
|
||||
" \n " +
|
||||
"<http://vivo.scripps.edu/individual/n9998> \n" +
|
||||
" a core:BogusClass . \n" +
|
||||
" a core:BogusClass . \n" +
|
||||
"<http://vivo.scripps.edu/individual/n9999> \n" +
|
||||
" a core:BogusClass . \n" +
|
||||
" \n" +
|
||||
" \n" +
|
||||
"core:InvitedTalk \n" +
|
||||
" rdfs:subClassOf core:Presentation . \n" +
|
||||
" \n" ;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class AdditionalURIsForObjectPropertiesTest {
|
|||
Model model;
|
||||
RDFService rdfService;
|
||||
AdditionalURIsForObjectProperties aufop;
|
||||
|
||||
|
||||
String testNS = "http://example.com/test#";
|
||||
String n3 = "" +
|
||||
"@prefix owl: <http://www.w3.org/2002/07/owl#> .\n" +
|
||||
|
@ -43,102 +43,102 @@ public class AdditionalURIsForObjectPropertiesTest {
|
|||
"test:bob a test:Person . \n" +
|
||||
"test:bob a owl:Thing . \n" +
|
||||
"test:bob test:likes [ rdfs:label \"this is a blank node\" ] . ";
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
model = ModelFactory.createDefaultModel();
|
||||
model.read(new StringReader(n3 ), null , "N3");
|
||||
rdfService = new RDFServiceModel(model);
|
||||
|
||||
|
||||
ContextModelAccessStub models = new ContextModelAccessStub();
|
||||
models.setRDFService(CONTENT, rdfService);
|
||||
|
||||
|
||||
aufop = new AdditionalURIsForObjectProperties();
|
||||
aufop.setContextModels(models);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeOfRdfsLabel() {
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource(testNS + "bob"),
|
||||
RDFS.label,
|
||||
ResourceFactory.createPlainLiteral("Some new label for bob")));
|
||||
|
||||
|
||||
Assert.assertNotNull(uris);
|
||||
Assert.assertTrue("uris was empty", uris.size() > 0 );
|
||||
|
||||
Assert.assertTrue("uris was empty", uris.size() > 0 );
|
||||
|
||||
Assert.assertTrue("uris didn't not contain test:onions", uris.contains(testNS+"onions"));
|
||||
Assert.assertTrue("uris didn't not contain test:cheese", uris.contains(testNS+"cheese"));
|
||||
Assert.assertTrue("uris didn't not contain test:icecream", uris.contains(testNS+"icecream"));
|
||||
|
||||
|
||||
Assert.assertTrue("uris contained test:Person", !uris.contains(testNS+"Person"));
|
||||
Assert.assertTrue("uris contained owl:Thing", !uris.contains( OWL.Thing.getURI() ));
|
||||
|
||||
|
||||
Assert.assertEquals(3, uris.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testChangeOfObjPropStmt() {
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource(testNS + "bob"),
|
||||
ResourceFactory.createProperty(testNS+"likes"),
|
||||
ResourceFactory.createResource(testNS+"cheese")));
|
||||
|
||||
|
||||
Assert.assertNotNull(uris);
|
||||
Assert.assertTrue("uris was empty", uris.size() > 0 );
|
||||
|
||||
Assert.assertTrue("uris was empty", uris.size() > 0 );
|
||||
|
||||
Assert.assertTrue("uris didn't not contain test:cheese", uris.contains(testNS+"cheese"));
|
||||
|
||||
|
||||
Assert.assertTrue("uris contained test:Person", !uris.contains(testNS+"Person"));
|
||||
Assert.assertTrue("uris contained owl:Thing", !uris.contains( OWL.Thing.getURI() ));
|
||||
Assert.assertTrue("uris contained test:onions", !uris.contains(testNS+"onions"));
|
||||
Assert.assertTrue("uris contained test:onions", !uris.contains(testNS+"onions"));
|
||||
Assert.assertTrue("uris contained test:icecream", !uris.contains(testNS+"icecream"));
|
||||
|
||||
|
||||
Assert.assertEquals(1, uris.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOfDataPropChange() {
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource(testNS + "bob"),
|
||||
ResourceFactory.createProperty(testNS+"hatsize"),
|
||||
ResourceFactory.createPlainLiteral("Some new hat size for bob")));
|
||||
|
||||
|
||||
Assert.assertNotNull(uris);
|
||||
Assert.assertTrue("uris was not empty", uris.size() == 0 );
|
||||
Assert.assertTrue("uris was not empty", uris.size() == 0 );
|
||||
}
|
||||
|
||||
|
||||
// For NIHVIVO-2902
|
||||
@Test
|
||||
public void testNIHVIVO_2902 (){
|
||||
//Update search index for research area when a statement is
|
||||
//removed between a person and the research area.
|
||||
|
||||
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
model.read(new StringReader( n3ForNIHVIVO_2902 ), null , "N3");
|
||||
|
||||
|
||||
ContextModelAccessStub models = new ContextModelAccessStub();
|
||||
models.setRDFService(CONTENT, new RDFServiceModel(model));
|
||||
|
||||
aufop.setContextModels(models);
|
||||
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
|
||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||
ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2241"),
|
||||
ResourceFactory.createProperty("http://vivoweb.org/ontology/core#hasResearchArea"),
|
||||
ResourceFactory.createResource("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n7416")));
|
||||
|
||||
|
||||
Assert.assertNotNull(uris);
|
||||
Assert.assertTrue("uris was empty", uris.size() > 0 );
|
||||
|
||||
Assert.assertTrue("NIHVIVO-2902 regression, research area is not getting reindexed", uris.contains("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n7416"));
|
||||
|
||||
Assert.assertTrue("NIHVIVO-2902 regression, research area is not getting reindexed", uris.contains("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n7416"));
|
||||
}
|
||||
|
||||
|
||||
// For NIHVIVO-2902
|
||||
String n3ForNIHVIVO_2902 =
|
||||
String n3ForNIHVIVO_2902 =
|
||||
"@prefix dc: <http://purl.org/dc/elements/1.1/> . \n" +
|
||||
"@prefix pvs: <http://vivoweb.org/ontology/provenance-support#> . \n" +
|
||||
"@prefix geo: <http://aims.fao.org/aos/geopolitical.owl#> . \n" +
|
||||
|
|
|
@ -31,14 +31,14 @@ public class AdditionalURIsForTypeStatementsTest {
|
|||
AdditionalURIsForTypeStatements aufts = new AdditionalURIsForTypeStatements();
|
||||
|
||||
String subject = "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n3270";
|
||||
Statement typeChangeStatement = ResourceFactory.createStatement(
|
||||
Statement typeChangeStatement = ResourceFactory.createStatement(
|
||||
ResourceFactory.createResource(subject),
|
||||
ResourceFactory.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
|
||||
ResourceFactory.createResource( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/ontology/localOnt#LocalInternalClass"));
|
||||
|
||||
|
||||
|
||||
|
||||
List<String> uris = aufts.findAdditionalURIsToIndex( typeChangeStatement );
|
||||
|
||||
|
||||
Assert.assertNotNull(uris);
|
||||
Assert.assertTrue("Did not contain subject of type change statement", uris.contains(subject));
|
||||
}
|
||||
|
|
|
@ -33,20 +33,20 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceMod
|
|||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
*
|
||||
* If the statement qualifies, execute the queries and return the accumulated
|
||||
* results.
|
||||
*
|
||||
*
|
||||
* A statement qualifies if the predicate matches any of the restrictions, or if
|
||||
* there are no restrictions.
|
||||
*
|
||||
*
|
||||
* If a query contains a ?subject or ?object variable, it will be bound to the
|
||||
* URI of the subject or object of the statement, respectively. If the subject
|
||||
* or object has no URI for the query, then the query will be ignored.
|
||||
*
|
||||
*
|
||||
* All of the result fields of all result rows of all of the queries will be
|
||||
* returned.
|
||||
*
|
||||
*
|
||||
* A label may be supplied to the instance, for use in logging. If no label is
|
||||
* supplied, one will be generated.
|
||||
*/
|
||||
|
|
|
@ -5,10 +5,10 @@ package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
|||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
|
||||
public class UpdateKnowledgeBaseTest extends AbstractTestClass {
|
||||
|
||||
|
||||
@org.junit.Test
|
||||
public void testMigrateDisplayModel14() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,30 +17,30 @@ import org.apache.jena.rdf.model.ModelFactory;
|
|||
*/
|
||||
public class JenaOntologyLoader {
|
||||
public OntModel ontModel = null;
|
||||
|
||||
|
||||
/**
|
||||
* This should load the system with classes, data properties and
|
||||
* object properties that the vitro systems needs.
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
OntModel loadSystemAndUsers() throws Exception{
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
for( String ont : systemOnts){
|
||||
OntModel loadSystemAndUsers() throws Exception{
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
for( String ont : systemOnts){
|
||||
InputStream in = this.getClass().getResourceAsStream(ont);
|
||||
model.read(in,null);
|
||||
in.close();
|
||||
}
|
||||
ontModel = ModelFactory.createOntologyModel(ONT_MODEL_SPEC,model);
|
||||
ontModel.prepare();
|
||||
}
|
||||
ontModel = ModelFactory.createOntologyModel(ONT_MODEL_SPEC,model);
|
||||
ontModel.prepare();
|
||||
return ontModel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Loads a owl file into the ontModel. Looks for files on classpath.
|
||||
* example: loadSpecialVivoModel("/testontologies/smallVivo-20070809.owl")
|
||||
*
|
||||
* example: loadSpecialVivoModel("/testontologies/smallVivo-20070809.owl")
|
||||
*
|
||||
* @param junk Junk value
|
||||
* @throws IOException
|
||||
*/
|
||||
|
@ -49,19 +49,19 @@ public class JenaOntologyLoader {
|
|||
Model model = ModelFactory.createDefaultModel();
|
||||
model.read(in,null);
|
||||
in.close();
|
||||
|
||||
ontModel.add(model);
|
||||
ontModel.prepare();
|
||||
return ontModel;
|
||||
|
||||
ontModel.add(model);
|
||||
ontModel.prepare();
|
||||
return ontModel;
|
||||
}
|
||||
|
||||
static String systemOnts[] ={
|
||||
|
||||
static String systemOnts[] ={
|
||||
"/testontologies/vitro1.owl",
|
||||
"/testontologies/vivo-users.owl" };
|
||||
|
||||
|
||||
static String testOnt[] ={
|
||||
"/testontologies/smallVivo-20070809.owl" };
|
||||
|
||||
|
||||
static OntModelSpec ONT_MODEL_SPEC = OntModelSpec.OWL_DL_MEM; // no additional entailment reasoning
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.configuration.WrappedInstance.Reso
|
|||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
*
|
||||
* Circularity prevention. Before setting properties, create a WeakMap of
|
||||
* instances by URIs, so if a property refers to a created instance, we just
|
||||
* pass it in.
|
||||
|
@ -387,14 +387,14 @@ public class ConfigurationBeanLoaderTest extends
|
|||
|
||||
SimpleSuccess instance = loader.loadInstance(
|
||||
SIMPLE_SUCCESS_INSTANCE_URI, SimpleSuccess.class);
|
||||
|
||||
|
||||
assertNotNull(instance);
|
||||
}
|
||||
|
||||
|
||||
public static class SimpleSuccess {
|
||||
// Nothing of interest.
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -599,7 +599,7 @@ public class ConfigurationBeanLoaderTest extends
|
|||
|
||||
/**
|
||||
* FullSuccess already tests for multiple validation methods.
|
||||
*
|
||||
*
|
||||
* SimpleSuccess already test for no validation methods, and for no property
|
||||
* methods.
|
||||
*/
|
||||
|
|
|
@ -269,7 +269,7 @@ public class ConfigurationBeanLoader_PropertyTest extends
|
|||
"Value"),
|
||||
dataProperty(GENERIC_INSTANCE_URI, OTHER_PROPERTY_URI,
|
||||
100.0F) });
|
||||
|
||||
|
||||
expectSimpleFailure(
|
||||
DistinctPropertyMethodSubclass.class,
|
||||
throwable(ConfigurationBeanLoaderException.class,
|
||||
|
|
|
@ -23,24 +23,24 @@ import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
|
||||
public class DataGetterUtilsTest extends AbstractTestClass{
|
||||
|
||||
|
||||
OntModel displayModel;
|
||||
VitroRequest vreq;
|
||||
String testDataGetterURI_1 = "http://vitro.mannlib.cornell.edu/ontologies/display/1.1#query1data";
|
||||
String pageURI_1 = "http://vitro.mannlib.cornell.edu/ontologies/display/1.1#SPARQLPage";
|
||||
String pageX = "http://vitro.mannlib.cornell.edu/ontologies/display/1.1#pageX";
|
||||
String dataGetterX = "http://vitro.mannlib.cornell.edu/ontologies/display/1.1#pageDataGetterX";
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() throws Exception {
|
||||
// Suppress error logging.
|
||||
setLoggerLevel(RDFDefaultErrorHandler.class, Level.OFF);
|
||||
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
|
||||
Model model = ModelFactory.createDefaultModel();
|
||||
InputStream in = DataGetterUtilsTest.class.getResourceAsStream("resources/dataGetterTest.n3");
|
||||
model.read(in,"","N3");
|
||||
model.read(in,"","N3");
|
||||
displayModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,model);
|
||||
|
||||
|
||||
vreq = new VitroRequest(new HttpServletRequestStub());
|
||||
}
|
||||
|
||||
|
@ -57,16 +57,16 @@ public class DataGetterUtilsTest extends AbstractTestClass{
|
|||
DataGetter dg = DataGetterUtils.dataGetterForURI(vreq, displayModel, testDataGetterURI_1);
|
||||
Assert.assertNotNull(dg);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetDataGettersForPage() throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException {
|
||||
List<DataGetter> dgList =
|
||||
List<DataGetter> dgList =
|
||||
DataGetterUtils.getDataGettersForPage(vreq, displayModel, pageURI_1);
|
||||
Assert.assertNotNull(dgList);
|
||||
Assert.assertTrue("List of DataGetters was empty, it should not be.", dgList.size() > 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -29,26 +29,26 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.SimpleOntModelSelector;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||
|
||||
public class SparqlQueryDataGetterTest extends AbstractTestClass{
|
||||
|
||||
|
||||
OntModel displayModel;
|
||||
String testDataGetterURI_1 = "http://vitro.mannlib.cornell.edu/ontologies/display/1.1#query1data";
|
||||
WebappDaoFactory wdf;
|
||||
VitroRequest vreq;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Suppress error logging.
|
||||
setLoggerLevel(RDFDefaultErrorHandler.class, Level.OFF);
|
||||
|
||||
OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM);
|
||||
OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM);
|
||||
InputStream in = SparqlQueryDataGetterTest.class.getResourceAsStream("resources/dataGetterTest.n3");
|
||||
model.read(in,"","N3");
|
||||
model.read(in,"","N3");
|
||||
displayModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM,model);
|
||||
|
||||
|
||||
SimpleOntModelSelector sos = new SimpleOntModelSelector( ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM));
|
||||
sos.setDisplayModel(displayModel);
|
||||
wdf = new WebappDaoFactoryJena(sos);
|
||||
|
||||
sos.setDisplayModel(displayModel);
|
||||
wdf = new WebappDaoFactoryJena(sos);
|
||||
|
||||
vreq = new VitroRequest(new HttpServletRequestStub());
|
||||
}
|
||||
|
||||
|
@ -59,27 +59,27 @@ public class SparqlQueryDataGetterTest extends AbstractTestClass{
|
|||
Assert.assertTrue(
|
||||
"DataGetter should be of type " + SparqlQueryDataGetter.class.getName(),
|
||||
dg instanceof SparqlQueryDataGetter);
|
||||
|
||||
|
||||
SparqlQueryDataGetter sdg = (SparqlQueryDataGetter)dg;
|
||||
|
||||
|
||||
|
||||
|
||||
Model dataModel = ModelFactory.createDefaultModel();
|
||||
String bobURI = "http://example.com/p/bob";
|
||||
dataModel.add(ResourceFactory.createResource(bobURI), RDF.type, ResourceFactory.createResource("http://xmlns.com/foaf/0.1/Person"));
|
||||
|
||||
|
||||
Map<String, String> params = Collections.emptyMap();
|
||||
|
||||
|
||||
Map<String,Object> mapOut = sdg.doQueryOnModel(sdg.queryText, dataModel);
|
||||
|
||||
|
||||
Assert.assertNotNull(mapOut);
|
||||
Assert.assertTrue("should contain key people" , mapOut.containsKey("people"));
|
||||
|
||||
Object obj = mapOut.get("people");
|
||||
Assert.assertTrue("people should be a List, it is " + obj.getClass().getName(), obj instanceof List);
|
||||
|
||||
Object obj = mapOut.get("people");
|
||||
Assert.assertTrue("people should be a List, it is " + obj.getClass().getName(), obj instanceof List);
|
||||
List people = (List)obj;
|
||||
|
||||
|
||||
Assert.assertEquals(1, people.size());
|
||||
|
||||
|
||||
Map<String,String> first = (Map<String, String>) people.get(0);
|
||||
Assert.assertEquals(bobURI, first.get("uri"));
|
||||
}
|
||||
|
|
|
@ -23,18 +23,18 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceMod
|
|||
import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaIngestUtils;
|
||||
|
||||
public class JenaIngestUtilsTest {
|
||||
|
||||
|
||||
private final Log log = LogFactory.getLog(JenaIngestUtilsTest.class);
|
||||
|
||||
|
||||
protected JenaIngestUtils utils = new JenaIngestUtils();
|
||||
|
||||
|
||||
protected Model makeModel() {
|
||||
Model base = ModelFactory.createDefaultModel();
|
||||
RDFService rdfService = new RDFServiceModel(base);
|
||||
return RDFServiceGraph.createRDFServiceModel(
|
||||
new RDFServiceGraph(rdfService));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSmush() {
|
||||
Model model = makeModel();
|
||||
|
@ -60,7 +60,7 @@ public class JenaIngestUtilsTest {
|
|||
s.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRenameBNodes() {
|
||||
Model initialState = ModelFactory.createDefaultModel();
|
||||
|
@ -68,7 +68,7 @@ public class JenaIngestUtilsTest {
|
|||
"renameBlank.n3"), null, "N3");
|
||||
Model renamedState = utils.renameBNodes(
|
||||
initialState, "http://example.org/node/n");
|
||||
Assert.assertEquals("Post-rename model is not the same size as the " +
|
||||
Assert.assertEquals("Post-rename model is not the same size as the " +
|
||||
"initial model", initialState.size(), renamedState.size());
|
||||
StmtIterator sit = renamedState.listStatements();
|
||||
boolean lingeringBNodes = false;
|
||||
|
@ -80,12 +80,12 @@ public class JenaIngestUtilsTest {
|
|||
}
|
||||
if(lingeringBNodes) {
|
||||
StringWriter s = new StringWriter();
|
||||
renamedState.write(s, "N3");
|
||||
Assert.fail("Renamed model still contains blank nodes \n" +
|
||||
renamedState.write(s, "N3");
|
||||
Assert.fail("Renamed model still contains blank nodes \n" +
|
||||
s.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGenerateTBox() {
|
||||
Model abox = ModelFactory.createDefaultModel();
|
||||
|
@ -96,11 +96,11 @@ public class JenaIngestUtilsTest {
|
|||
"tbox.n3"), null, "N3");
|
||||
Model generatedTBox = utils.generateTBox(abox);
|
||||
//log.warn(tbox.toString());
|
||||
Assert.assertTrue("Generated TBox does not match expected result",
|
||||
Assert.assertTrue("Generated TBox does not match expected result",
|
||||
tbox.isIsomorphicWith(generatedTBox));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testDoMerge() {
|
||||
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, makeModel());
|
||||
OntModel tbox = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, makeModel());
|
||||
|
@ -113,7 +113,7 @@ public class JenaIngestUtilsTest {
|
|||
utils.doMerge("http://example.com/ns/n1", "http://example.com/ns/n1", model, tbox, false);
|
||||
Assert.assertTrue("Merged model with multiple labels does not match " +
|
||||
"expected result", expectedMergeMultipleLabels.isIsomorphicWith(model));
|
||||
|
||||
|
||||
model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, makeModel());
|
||||
model.read(JenaIngestUtilsTest.class.getResourceAsStream(
|
||||
"merge.n3"), null, "N3");
|
||||
|
|
|
@ -17,25 +17,25 @@ public class JenaIngestUtilsTest extends AbstractTestClass {
|
|||
|
||||
@Test
|
||||
public void testRenameBNodes() {
|
||||
|
||||
|
||||
JenaIngestUtils jiu = new JenaIngestUtils();
|
||||
|
||||
|
||||
Model blankModel = ModelFactory.createDefaultModel();
|
||||
for (int i = 0; i < 20; i++) {
|
||||
blankModel.add(blankModel.createResource(), RDF.type, OWL.Thing);
|
||||
}
|
||||
Assert.assertTrue(blankModel.size() == 20);
|
||||
|
||||
|
||||
Model named = jiu.renameBNodes(blankModel, "http://example.org/resource");
|
||||
Assert.assertTrue(named.size() == blankModel.size());
|
||||
Assert.assertTrue(named.size() == 20);
|
||||
|
||||
|
||||
StmtIterator stmtIt = named.listStatements();
|
||||
while (stmtIt.hasNext()) {
|
||||
Statement stmt = stmtIt.nextStatement();
|
||||
Assert.assertEquals("http://example.org/", stmt.getSubject().getNameSpace());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
|||
|
||||
/**
|
||||
* quotes,\, \r, \n, \b, \f, \t and other control characters.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JacksonUtilsTest extends AbstractTestClass {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ContentTypeTest {
|
|||
Assert.assertEquals(0.5f, map.get("text/rdf+n3"), 0.01f);
|
||||
Assert.assertEquals(0.8f,map.get("*/*"), 0.01f);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void typeAndQTest2(){
|
||||
Map<String,Float> map = ContentType.getTypesAndQ(
|
||||
|
@ -32,32 +32,32 @@ public class ContentTypeTest {
|
|||
Assert.assertEquals(1.0f, map.get("text/html"), 0.01f);
|
||||
Assert.assertEquals(1.0f, map.get("application/xhtml+xml"), 0.01f);
|
||||
Assert.assertEquals(0.9f, map.get("application/xml"), 0.01f);
|
||||
Assert.assertEquals(0.8f,map.get("*/*"), 0.01f);
|
||||
Assert.assertEquals(0.8f,map.get("*/*"), 0.01f);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWeightedBestContentTypeForTabulator(){
|
||||
//accept header from tabulator
|
||||
Map<String,Float> clientAccepts = ContentType.getTypesAndQ(
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,application/rdf+xml;q=0.93,text/rdf+n3;q=0.5");
|
||||
|
||||
|
||||
Map<String,Float> serverTypes = IndividualController.ACCEPTED_CONTENT_TYPES;
|
||||
|
||||
Assert.assertEquals("application/rdf+xml", ContentType.getBestContentType(clientAccepts, serverTypes));
|
||||
|
||||
Assert.assertEquals("application/rdf+xml", ContentType.getBestContentType(clientAccepts, serverTypes));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modified this, added q-factor to text/html, because otherwise the result is indeterminate, and the
|
||||
* test fails in Java 8.
|
||||
*/
|
||||
*/
|
||||
@Test
|
||||
public void testWeightedBestContentTypeForFirefox(){
|
||||
//accept header from normal firefox
|
||||
Map<String,Float> clientAccepts = ContentType.getTypesAndQ(
|
||||
"text/html;q=0.95,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
|
||||
|
||||
|
||||
Map<String,Float> serverTypes = IndividualController.ACCEPTED_CONTENT_TYPES;
|
||||
|
||||
Assert.assertEquals("application/xhtml+xml", ContentType.getBestContentType(clientAccepts, serverTypes));
|
||||
|
||||
Assert.assertEquals("application/xhtml+xml", ContentType.getBestContentType(clientAccepts, serverTypes));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,16 @@ import org.junit.Test;
|
|||
public class BaseTemplateModelTest {
|
||||
|
||||
private static String value;
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testCleanURIofNull(){
|
||||
|
||||
|
||||
BaseTemplateModel btm = new BaseTemplateModel(){};
|
||||
//should not throw NPE
|
||||
value = btm.cleanURIForDisplay( null );
|
||||
|
||||
|
||||
//should not throw NPE
|
||||
value = btm.cleanTextForDisplay( null );
|
||||
value = btm.cleanTextForDisplay( null );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -245,4 +245,4 @@ public class TagsTest extends AbstractTestClass {
|
|||
return t.list();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
|||
public class CustomListViewConfigFileTest extends AbstractTestClass {
|
||||
/**
|
||||
* Use this XML to test the methods that strip tags from the select clause.
|
||||
*
|
||||
*
|
||||
* If not collated, omit the "collated" tag. If editing, omit the
|
||||
* "critical-data-required" tag.
|
||||
*/
|
||||
|
@ -41,7 +41,7 @@ public class CustomListViewConfigFileTest extends AbstractTestClass {
|
|||
/**
|
||||
* In general, we expect no exception, but individual tests may override,
|
||||
* like this:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* thrown.expect(InvalidConfigurationException.class);
|
||||
* thrown.expectMessage("Bozo");
|
||||
|
@ -204,7 +204,7 @@ public class CustomListViewConfigFileTest extends AbstractTestClass {
|
|||
* TODO Successes:
|
||||
* select query with all tags
|
||||
* collated, editing, both, neither
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
|
|
|
@ -74,13 +74,13 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
|
|||
private TemplateLoaderStub tl;
|
||||
|
||||
private StringWriter logMessages;
|
||||
|
||||
|
||||
private ModelAccessFactoryStub mafs;
|
||||
|
||||
/**
|
||||
* In general, we expect no exception, but individual tests may override,
|
||||
* like this:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* thrown.expect(InvalidConfigurationException.class);
|
||||
* thrown.expectMessage("Bozo");
|
||||
|
@ -138,7 +138,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
|
|||
hreq.setSession(session);
|
||||
|
||||
vreq = new VitroRequest(hreq);
|
||||
|
||||
|
||||
mafs = new ModelAccessFactoryStub();
|
||||
mafs.get(vreq).setWebappDaoFactory(wadf, ASSERTIONS_AND_INFERENCES);
|
||||
mafs.get(vreq).setWebappDaoFactory(wadf, POLICY_NEUTRAL);
|
||||
|
@ -394,7 +394,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
|
|||
/**
|
||||
* Sets up an operation with name "foobar" and adds it to the
|
||||
* ObjectPropertyDaoStub.
|
||||
*
|
||||
*
|
||||
* The URI will be "http://foobar", and the ListViewConfig file will be
|
||||
* "testConfig-foobar.xml". That file is assumed to exist already, and to be
|
||||
* mapped in the ServletContextStub.
|
||||
|
|
|
@ -44,57 +44,57 @@ public class DumpAllDirectiveTest {
|
|||
Logger.getLogger(BaseDumpDirective.class).setLevel(Level.OFF);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void dumpDataModel() {
|
||||
|
||||
|
||||
Map<String, Object> dataModel = new HashMap<String, Object>();
|
||||
|
||||
|
||||
String stringName = "dog";
|
||||
String stringVal = "Rover";
|
||||
dataModel.put(stringName, stringVal);
|
||||
|
||||
|
||||
String boolName = "isLoggedIn";
|
||||
boolean boolVal = true;
|
||||
dataModel.put(boolName, boolVal);
|
||||
|
||||
|
||||
String intName = "tabCount";
|
||||
int intVal = 7;
|
||||
dataModel.put(intName, intVal);
|
||||
|
||||
|
||||
String dateName = "now";
|
||||
Date dateVal = new Date();
|
||||
dataModel.put(dateName, dateVal);
|
||||
|
||||
|
||||
String listName = "fruit";
|
||||
List<String> listVal = new ArrayList<String>();
|
||||
listVal.add("apples");
|
||||
listVal.add("bananas");
|
||||
listVal.add("oranges");
|
||||
dataModel.put(listName, listVal);
|
||||
|
||||
|
||||
SortedMap<String, Object> expectedDump = new TreeMap<String, Object>();
|
||||
|
||||
|
||||
Map<String, Object> expectedStringDump = new HashMap<String, Object>();
|
||||
expectedStringDump.put(Key.TYPE.toString(), Type.STRING);
|
||||
expectedStringDump.put(Key.VALUE.toString(), stringVal);
|
||||
expectedDump.put(stringName, expectedStringDump);
|
||||
|
||||
|
||||
Map<String, Object> expectedBoolDump = new HashMap<String, Object>();
|
||||
expectedBoolDump.put(Key.TYPE.toString(), Type.BOOLEAN);
|
||||
expectedBoolDump.put(Key.VALUE.toString(), boolVal);
|
||||
expectedDump.put(boolName, expectedBoolDump);
|
||||
|
||||
|
||||
Map<String, Object> expectedIntDump = new HashMap<String, Object>();
|
||||
expectedIntDump.put(Key.TYPE.toString(), Type.NUMBER);
|
||||
expectedIntDump.put(Key.VALUE.toString(), intVal);
|
||||
expectedDump.put(intName, expectedIntDump);
|
||||
|
||||
|
||||
Map<String, Object> expectedDateDump = new HashMap<String, Object>();
|
||||
expectedDateDump.put(Key.TYPE.toString(), Type.DATE);
|
||||
expectedDateDump.put(Key.DATE_TYPE.toString(), DateType.UNKNOWN);
|
||||
expectedDateDump.put(Key.VALUE.toString(), dateVal);
|
||||
expectedDump.put(dateName, expectedDateDump);
|
||||
|
||||
|
||||
Map<String, Object> expectedListDump = new HashMap<String, Object>();
|
||||
expectedListDump.put(Key.TYPE.toString(), Type.SEQUENCE);
|
||||
List<Map<String, Object>> listItemsExpectedDump = new ArrayList<Map<String, Object>>(listVal.size());
|
||||
|
@ -102,32 +102,32 @@ public class DumpAllDirectiveTest {
|
|||
Map<String, Object> itemDump = new HashMap<String, Object>();
|
||||
itemDump.put(Key.TYPE.toString(), Type.STRING);
|
||||
itemDump.put(Key.VALUE.toString(), str);
|
||||
listItemsExpectedDump.add(itemDump);
|
||||
listItemsExpectedDump.add(itemDump);
|
||||
}
|
||||
expectedListDump.put(Key.VALUE.toString(), listItemsExpectedDump);
|
||||
expectedDump.put(listName, expectedListDump);
|
||||
|
||||
|
||||
SortedMap<String, Object> dump = getDump(dataModel);
|
||||
assertEquals(expectedDump, dump);
|
||||
|
||||
|
||||
// Test sorting of the data model
|
||||
List<String> expectedKeys = new ArrayList<String>(expectedDump.keySet());
|
||||
List<String> actualKeys = new ArrayList<String>(dump.keySet());
|
||||
assertEquals(expectedKeys, actualKeys);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////// Private helper methods ///////////////////////////
|
||||
|
||||
private SortedMap<String, Object> getDump(Map<String, Object> dataModel) {
|
||||
try {
|
||||
Environment env = template.createProcessingEnvironment(dataModel, new StringWriter());
|
||||
return new DumpAllDirective().getDataModelDump(env);
|
||||
return new DumpAllDirective().getDataModelDump(env);
|
||||
} catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -37,7 +37,7 @@ public class PropertyRestrictionBeanStub extends PropertyRestrictionBean {
|
|||
/**
|
||||
* Prohibit some namespaces and restrict some properties from modification
|
||||
* by anybody. They may still be displayed or published.
|
||||
*
|
||||
*
|
||||
* We can implement more granular control if we need it.
|
||||
*/
|
||||
public static PropertyRestrictionBeanStub getInstance(
|
||||
|
|
|
@ -505,4 +505,4 @@ public class IndividualStub implements Individual {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
|||
* A version of ConfigurationProperties that we can use for unit tests. Unlike
|
||||
* the basic implementation, this starts as an empty map, and allows the user to
|
||||
* add properties as desired.
|
||||
*
|
||||
*
|
||||
* Call setBean() to store these properties in the ServletContext.
|
||||
*/
|
||||
public class ConfigurationPropertiesStub extends ConfigurationProperties {
|
||||
|
|
|
@ -9,7 +9,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
|
|||
|
||||
/**
|
||||
* A minimal implementation of the ApplicationDao.
|
||||
*
|
||||
*
|
||||
* I have only implemented the methods that I needed. Feel free to implement
|
||||
* others.
|
||||
*/
|
||||
|
|
|
@ -20,7 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
|||
|
||||
/**
|
||||
* A minimal implementation of the DataPropertyDao.
|
||||
*
|
||||
*
|
||||
* I have only implemented the methods that I needed. Feel free to implement
|
||||
* others.
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
|||
|
||||
/**
|
||||
* A minimal implementation of the IndividualDao.
|
||||
*
|
||||
*
|
||||
* I have only implemented the methods that I needed. Feel free to implement
|
||||
* others.
|
||||
*/
|
||||
|
@ -32,12 +32,12 @@ public class IndividualDaoStub implements IndividualDao {
|
|||
if (individual == null) {
|
||||
throw new NullPointerException("individual may not be null.");
|
||||
}
|
||||
|
||||
|
||||
String uri = individual.getURI();
|
||||
if (uri == null) {
|
||||
throw new NullPointerException("uri may not be null.");
|
||||
}
|
||||
|
||||
|
||||
indMap.put(uri, individual);
|
||||
}
|
||||
|
||||
|
@ -133,13 +133,13 @@ public class IndividualDaoStub implements IndividualDao {
|
|||
public Collection<String> getAllIndividualUris() {
|
||||
throw new RuntimeException(
|
||||
"IndividualDaoStub.getAllIndividualUris() not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> getUpdatedSinceIterator(long updatedSince) {
|
||||
throw new RuntimeException(
|
||||
"IndividualDaoStub.getUpdatedSinceIterator() not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndividualOfClass(String vclassURI, String indURI) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import javax.servlet.ServletRequest;
|
|||
|
||||
/**
|
||||
* A minimal implementation of the MenuDao.
|
||||
*
|
||||
*
|
||||
* I have only implemented the methods that I needed. Feel free to implement
|
||||
* others.
|
||||
*/
|
||||
|
|
|
@ -20,7 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
|||
|
||||
/**
|
||||
* A minimal implementation of the ObjectPropertyDao.
|
||||
*
|
||||
*
|
||||
* I have only implemented the methods that I needed. Feel free to implement
|
||||
* others.
|
||||
*/
|
||||
|
|
|
@ -16,7 +16,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
|||
|
||||
/**
|
||||
* A minimal implementation of the ObjectPropertyStatementDao
|
||||
*
|
||||
*
|
||||
* I have only implemented the methods that I needed. Feel free to implement
|
||||
* others.
|
||||
*/
|
||||
|
|
|
@ -12,7 +12,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
|||
|
||||
/**
|
||||
* A minimal implementation of the OntologyDao.
|
||||
*
|
||||
*
|
||||
* I have only implemented the methods that I needed. Feel free to implement
|
||||
* others.
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ public class OntologyDaoStub implements OntologyDao {
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private final Map<String, Ontology> ontologies = new HashMap<String, Ontology>();
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Stub methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -14,11 +14,11 @@ public class PropertyGroupDaoStub implements PropertyGroupDao {
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private final Map<String, PropertyGroup> map = new HashMap<>();
|
||||
|
||||
|
||||
public void addPropertyGroup(PropertyGroup group) {
|
||||
map.put(group.getURI(), group);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Stub methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -27,7 +27,7 @@ public class PropertyGroupDaoStub implements PropertyGroupDao {
|
|||
public PropertyGroup getGroupByURI(String uri) {
|
||||
return (uri == null) ? null : copyGroup(map.get(uri), false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<PropertyGroup> getPublicGroups(boolean withProperties) {
|
||||
List<PropertyGroup> list = new ArrayList<>();
|
||||
|
@ -36,22 +36,22 @@ public class PropertyGroupDaoStub implements PropertyGroupDao {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private PropertyGroup copyGroup(PropertyGroup source, boolean withProperties) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
PropertyGroup target = new PropertyGroup();
|
||||
|
||||
|
||||
target.setURI(source.getURI());
|
||||
target.setPickListName(source.getPickListName());
|
||||
|
||||
|
||||
target.setDisplayRank(source.getDisplayRank());
|
||||
target.setName(source.getName());
|
||||
target.setStatementCount(source.getStatementCount());
|
||||
target.setPublicDescription(source.getPublicDescription());
|
||||
|
||||
|
||||
if (withProperties) {
|
||||
target.setPropertyList(source.getPropertyList());
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class UserAccountsDaoStub implements UserAccountsDao {
|
|||
public void addUser(UserAccount user) {
|
||||
userAccountsByUri.put(user.getUri(), user);
|
||||
}
|
||||
|
||||
|
||||
public void addPermissionSet(PermissionSet ps) {
|
||||
permissionSetsByUri.put(ps.getUri(), ps);
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ public class VClassGroupDaoStub implements VClassGroupDao {
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private List<VClassGroup> groups = new ArrayList<>();
|
||||
|
||||
|
||||
public void setGroups(VClassGroup... groups) {
|
||||
this.groups = new ArrayList<>(Arrays.asList(groups));
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Stub methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -34,7 +34,7 @@ public class VClassGroupDaoStub implements VClassGroupDao {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<VClassGroup> getPublicGroupsWithVClasses() {
|
||||
List<VClassGroup> list = new ArrayList<>();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue