From 6d608df84c167a40ab24ab5755c60abf4b2d6289 Mon Sep 17 00:00:00 2001 From: briancaruso Date: Thu, 14 Jul 2011 15:22:15 +0000 Subject: [PATCH] Adding unit test for on context node update during incremental search update. NIHVIVO-2834 --- .../AdditionalURIsForContextNodesTest.java | 56 +++++++++++++++---- 1 file changed, 44 insertions(+), 12 deletions(-) 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 617ea47b4..26e87f7c8 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,6 +4,8 @@ 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; import org.junit.Test; @@ -15,19 +17,49 @@ import com.hp.hpl.jena.rdf.model.ModelFactory; public class AdditionalURIsForContextNodesTest { @Test - public void testFindAdditionalURIsToIndex() { + public void testPersonOnOrgChange() { + + String n3 ="@prefix dc: . \n" + + "@prefix rdfs: . \n" + + "@prefix swrl: . \n" + + "@prefix vitro: . \n" + + "@prefix xsd: . \n" + + "@prefix swrlb: . \n" + + "@prefix owl: . \n" + + "@prefix rdf: . \n" + + "@prefix core: . \n" + + "@prefix vivo: . \n" + + " " + + " \n" + + " a owl:Thing , core:Role , core:LeaderRole ; \n" + + " rdfs:label \"head\"^^xsd:string ; \n" + + " vitro:mostSpecificType \n" + + " core:LeaderRole ; \n" + + " core:dateTimeInterval \n" + + " ; \n" + + " core:leaderRoleOf ; \n" + + " core:roleIn . \n" + + " \n" + + " a , owl:Thing , , core:ClinicalOrganization ; \n" + + " rdfs:label \"Organization XYZ\"^^xsd:string ; \n" + + " vitro:mostSpecificType \n" + + " core:ClinicalOrganization ; \n" + + " core:relatedRole . \n"; + + + //make a test model with an person, an authorship context node and a book + OntModel model = ModelFactory.createOntologyModel(); + model.read( new StringReader(n3), null, "N3"); + + + //make an AdditionalURIsForContextNodesTest object with that model + AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model ); + + //get additional uris for org + List uris = uriFinder.findAdditionalURIsToIndex( "http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2592"); + + assertTrue("did not find person for context node", uris.contains("http://vivo.scripps.edu/individual/n14979" )); -// //make a test model with an person, an authorship context node and a book -// OntModel model = ModelFactory.createOntologyModel(); -// -// //make an AdditionalURIsForContextNodesTest object with that model -// AdditionalURIsForContextNodes uriFinder = new AdditionalURIsForContextNodes( model ); -// -// //execute the method and check the results -// List uris = uriFinder.findAdditionalURIsToIndex( "http://example.com/personA"); -// -// assertTrue("could not find authorship context node", uris.contains("http://example.com/authorshipNode")); -// assertTrue("could not find book indivdiual", uris.contains("http://example.com/bookA")); } }