@Test public void testGetRelationships() throws Exception { loadHierarchyOwlFile(); getOntologyRepository().clearCache(); Iterable<Relationship> relationships = getOntologyRepository().getRelationships(workspaceId); Map<String, Relationship> relationshipsByIri = StreamSupport.stream(relationships.spliterator(), false) .collect(Collectors.toMap(Relationship::getIRI, Function.identity())); assertNull(relationshipsByIri.get("http://www.w3.org/2002/07/owl#topObjectProperty").getParentIRI()); assertEquals("http://www.w3.org/2002/07/owl#topObjectProperty", relationshipsByIri.get("http://visallo.org/testhierarchy#personKnowsPerson").getParentIRI()); }
@Test public void testGettingParentConceptReturnsParentProperties() throws Exception { loadHierarchyOwlFile(); Concept concept = getOntologyRepository().getConceptByIRI(TEST_HIERARCHY_IRI + "#person", PUBLIC); Concept parentConcept = getOntologyRepository().getParentConcept(concept, PUBLIC); assertEquals(1, parentConcept.getProperties().size()); }
@Test public void testGetConceptsWithProperties() throws Exception { loadHierarchyOwlFile(); getOntologyRepository().clearCache(); Iterable<Concept> conceptsWithProperties = getOntologyRepository().getConceptsWithProperties(workspaceId); Map<String, Concept> conceptsByIri = StreamSupport.stream(conceptsWithProperties.spliterator(), false) .collect(Collectors.toMap(Concept::getIRI, Function.identity())); Concept personConcept = conceptsByIri.get("http://visallo.org/testhierarchy#person"); // Check parent iris assertNull(conceptsByIri.get("http://visallo.org#root").getParentConceptIRI()); assertEquals("http://visallo.org#root", conceptsByIri.get("http://www.w3.org/2002/07/owl#Thing").getParentConceptIRI()); assertEquals("http://www.w3.org/2002/07/owl#Thing", conceptsByIri.get("http://visallo.org/testhierarchy#contact").getParentConceptIRI()); assertEquals("http://visallo.org/testhierarchy#contact", personConcept.getParentConceptIRI()); // Check properties List<OntologyProperty> personProperties = new ArrayList<>(personConcept.getProperties()); assertEquals(1, personProperties.size()); assertEquals("http://visallo.org/testhierarchy#name", personProperties.get(0).getIri()); // Check intents List<String> intents = Arrays.asList(personConcept.getIntents()); assertEquals(2, intents.size()); assertTrue(intents.contains("face")); assertTrue(intents.contains("person")); // Spot check other concept values assertEquals("Person", personConcept.getDisplayName()); assertEquals("prop('http://visallo.org/testhierarchy#name') || ''", personConcept.getTitleFormula()); }
@Test public void testRelationshipHierarchy() throws Exception { loadHierarchyOwlFile(); Relationship relationship = getOntologyRepository().getRelationshipByIRI(TEST_HIERARCHY_IRI + "#personReallyKnowsPerson", PUBLIC); assertEquals(TEST_HIERARCHY_IRI + "#personKnowsPerson", relationship.getParentIRI()); relationship = getOntologyRepository().getParentRelationship(relationship, PUBLIC); assertEquals(TEST_HIERARCHY_IRI + "#personKnowsPerson", relationship.getIRI()); assertEquals(OntologyRepositoryBase.TOP_OBJECT_PROPERTY_IRI, relationship.getParentIRI()); }