diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForContextNodesTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForContextNodesTest.java index 1fd0b272c..be2be148e 100644 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForContextNodesTest.java +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/search/indexing/AdditionalURIsForContextNodesTest.java @@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.search.indexing; import static org.junit.Assert.assertTrue; -import java.io.BufferedInputStream; import java.io.StringReader; import java.util.List; @@ -13,6 +12,8 @@ import org.junit.Test; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.rdf.model.ModelFactory; +import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForContextNodes; + public class AdditionalURIsForContextNodesTest { @@ -118,6 +119,204 @@ public class AdditionalURIsForContextNodesTest { } + @Test + public void testLeaderRoleChanges(){ + String n3= + + " \"1, Test\" . \n " + + " \"1\"^^ . \n " + + " \"Test\"^^ . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + + + " \"Leader Role\"^^ . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + + " \"University1\"^^ . \n " + + " . \n " + + " .\n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " ; + + + //make a test model with an person, a leader role node and a university + OntModel model = ModelFactory.createOntologyModel(); + model.read( new StringReader(n3), null, "N3"); + + //make an AdditionalURIsForContextNodesTest object with that model + AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model ); + + //if the person changes then the university needs to be updated + List uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n2027"); + assertTrue("did not find org for context node", uris.contains("http://vivo.scripps.edu/individual/n7080" )); + + //if the university changes then the person needs to be updated + uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n7080"); + assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n2027" )); + + + } + + + @Test + public void testMemberRoleChanges(){ + String n3 = + + " . \n " + + " \"2, Test\" . \n " + + " \"2\"^^ . \n " + + " \"Test\"^^ . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + + " \"Member Role\"^^ . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + + + " \"University2\"^^ . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " + + " . \n " ; + + + + //make a test model with an person, a member role node and a university + OntModel model = ModelFactory.createOntologyModel(); + model.read( new StringReader(n3), null, "N3"); + + //make an AdditionalURIsForContextNodesTest object with that model + AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model ); + + //if the person changes then the university needs to be updated + List uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4519"); + assertTrue("did not find org for context node", uris.contains("http://vivo.scripps.edu/individual/n6004" )); + + //if the university changes then the person needs to be updated + uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n6004"); + assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n4519" )); + + + } + + + @Test + public void testClinicalRoleChangesForProject(){ + + String n3 = + + " \"3, Test\" . \n" + + " \"3\"^^ .\n" + + " \"Test\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " . \n" + + " \"Clinical Role\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " \"Project1\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" ; + + + + //make a test model with an person, a clinical role node and a project + OntModel model = ModelFactory.createOntologyModel(); + model.read( new StringReader(n3), null, "N3"); + + //make an AdditionalURIsForContextNodesTest object with that model + AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model ); + + //if the person changes then the project needs to be updated + List uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4858"); + assertTrue("did not find project for clinical role", uris.contains("http://vivo.scripps.edu/individual/n5177" )); + + //if the project changes then the person needs to be updated + uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5177"); + assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4858" )); + + } + + @Test + public void testClinicalRoleChangesForService(){ + + String n3 = + + " \"4, Test\" . \n" + + " \"4\"^^ . \n" + + " \"Test\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " . \n" + + " \"Clinical Role 2\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " \"Service1\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" ; + + //make a test model with an person, a clinical role node and a service + OntModel model = ModelFactory.createOntologyModel(); + model.read( new StringReader(n3), null, "N3"); + + //make an AdditionalURIsForContextNodesTest object with that model + AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model ); + + //if the person changes then the service needs to be updated + List uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5651"); + assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n4442" )); + + //if the service changes then the person needs to be updated + uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4442"); + assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n5651" )); + + + } }