Adding unit test for NIHVIVO-2902 and AdditionalURIsForObjectProperties.java

This commit is contained in:
briancaruso 2011-07-15 19:21:46 +00:00
parent 061bc973bf
commit 6560bee602

View file

@ -98,4 +98,62 @@ public class AdditionalURIsForObjectPropertiesTest {
Assert.assertNotNull(uris);
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");
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(model);
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"));
}
// For NIHVIVO-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" +
"@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n" +
"@prefix scires: <http://vivoweb.org/ontology/scientific-research#> . \n" +
"@prefix scripps: <http://vivo.scripps.edu/> . \n" +
"@prefix dcterms: <http://purl.org/dc/terms/> . \n" +
"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . \n" +
"@prefix swrl: <http://www.w3.org/2003/11/swrl#> . \n" +
"@prefix vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#>. \n" +
"@prefix event: <http://purl.org/NET/c4dm/event.owl#> . \n" +
"@prefix bibo: <http://purl.org/ontology/bibo/> . \n" +
"@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . \n" +
"@prefix owl: <http://www.w3.org/2002/07/owl#> . \n" +
"@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> . \n" +
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . \n" +
"@prefix core: <http://vivoweb.org/ontology/core#> . \n" +
"@prefix skos: <http://www.w3.org/2004/02/skos/core#> . \n" +
"@prefix vivo: <http://vivo.library.cornell.edu/ns/0.1#> . \n" +
"@prefix dcelem: <http://purl.org/dc/elements/1.1/> . \n" +
"@prefix ero: <http://purl.obolibrary.org/obo/> . \n" +
" \n" +
"<http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2241> \n" +
" a core:FacultyMember , foaf:Person , owl:Thing , foaf:Agent ; \n" +
" rdfs:label \"Faculty, Jane\" ; \n" +
" vitro:modTime \"2011-07-15T15:08:35\"^^xsd:dateTime ; \n" +
" vitro:mostSpecificType \n" +
" core:FacultyMember ; \n" +
" core:hasResearchArea \n" +
" <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n7416> ; \n" +
" core:mailingAddress <http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n5993> ; \n" +
" foaf:firstName \"Jane\"^^xsd:string ; \n" +
" foaf:lastName \"Faculty\"^^xsd:string . ";
}