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 47369c4ce..1d721c51a 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 @@ -512,9 +512,156 @@ public class AdditionalURIsForContextNodesTest { assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n2029" )); + } + + @Test + public void testPrincipalInvestigatorRoleChanges(){ + + String n3 = + + " . \n" + + " \"8, Test\" . \n" + + " \"8\"^^ . \n" + + " \"Test\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " \"Grant 2\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" ; + + + //make a test model with an person, a principal investigator role node and a grant + 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 grant needs to be updated + List uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n2368"); + assertTrue("did not find service for clinical role", uris.contains("http://vivo.scripps.edu/individual/n1742" )); + + //if the grant changes then the person needs to be updated + uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n1742"); + assertTrue("did not find person for clinical role", uris.contains("http://vivo.scripps.edu/individual/n2368" )); + + + } + + @Test + public void testCoPrincipalInvestigatorRoleChanges(){ + + String n3 = + + " \"9, Test\" . \n" + + " \"9\"^^ . \n" + + " \"Test\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " \"Grant 3\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" ; + + //make a test model with an person, a co-principal investigator role node and a grant + 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 copi changes then the grant needs to be updated + List uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n1373"); + assertTrue("did not find grant for co-pi", uris.contains("http://vivo.scripps.edu/individual/n4931" )); + + //if the grant changes then the copi needs to be updated + uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n4931"); + assertTrue("did not find co-pi for grant", uris.contains("http://vivo.scripps.edu/individual/n1373" )); + + } + + + @Test + public void testInvestigatorRoleChanges(){ + + String n3 = + + " \"10, Test\" . \n" + + " \"10\"^^ . \n" + + " \"Test\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + + " \"Grant 4\"^^ . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" + + " . \n" ; + + + //make a test model with an person, a investigator role node and a grant + 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 investigator changes then the grant needs to be updated + List uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n5282"); + assertTrue("did not find grant for co-pi", uris.contains("http://vivo.scripps.edu/individual/n160" )); + + //if the grant changes then the investigator needs to be updated + uris = uriFinder.findAdditionalURIsToIndex( "http://vivo.scripps.edu/individual/n160"); + assertTrue("did not find co-pi for grant", uris.contains("http://vivo.scripps.edu/individual/n5282" )); + + } - }