@Test(expected = VisalloAccessDeniedException.class) public void testCreatingPublicRelationshipsWithoutPublishPrivilege() { List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); getOntologyRepository().getOrCreateRelationshipType(null, thing, thing, PUBLIC_RELATIONSHIP_IRI, null, true, user, PUBLIC); }
@Test(expected = VisalloAccessDeniedException.class) public void testCreatingPublicConceptsWithoutPublishPrivilege() { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, null, user, PUBLIC); }
@Test(expected = VisalloAccessDeniedException.class) public void testCreatingConceptsWithNoUserOrWorkspace() { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, null, null, PUBLIC); }
@Test(expected = VisalloAccessDeniedException.class) public void testCreatingSandboxedConceptsWithoutAddPermissionPrivilege() { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, null, user, workspaceId); }
@Test(expected = VisalloAccessDeniedException.class) public void testPublishingRelationshipsWithoutPublishPrivilege() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); Relationship sandboxedRelationship = getOntologyRepository().getOrCreateRelationshipType(null, thing, thing, SANDBOX_RELATIONSHIP_IRI, null, true, user, workspaceId); getOntologyRepository().publishRelationship(sandboxedRelationship, user, workspaceId); }
@Test public void testExceptionDeletingSandboxedConceptsWithRelationshipsRange() throws Exception { createSampleOntology(); Concept concept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId); // Add an edge type List<Concept> things = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); getOntologyRepository().getOrCreateRelationshipType(null, things, Arrays.asList(concept), "sandboxed-relationship-withsandboxed-concepts", true, adminUser, workspaceId); getOntologyRepository().clearCache(workspaceId); thrown.expect(VisalloException.class); thrown.expectMessage("Unable to delete concept that is used in domain/range of relationship"); getOntologyRepository().deleteConcept(SANDBOX_CONCEPT_IRI, adminUser, workspaceId); }
@Test public void testPublishingConcepts() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); Concept sandboxedConcept = getOntologyRepository().getOrCreateConcept(thing, SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, null, user, workspaceId); getOntologyRepository().publishConcept(sandboxedConcept, user, workspaceId); getOntologyRepository().clearCache(); Concept publicConcept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, PUBLIC); assertEquals(SANDBOX_DISPLAY_NAME, publicConcept.getDisplayName()); }
@Test public void testPublishingRelationships() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); Relationship sandboxedRelationship = getOntologyRepository().getOrCreateRelationshipType(null, thing, thing, SANDBOX_RELATIONSHIP_IRI, null, true, user, workspaceId); getOntologyRepository().publishRelationship(sandboxedRelationship, user, workspaceId); getOntologyRepository().clearCache(); Relationship publicRelationship = getOntologyRepository().getRelationshipByIRI(SANDBOX_RELATIONSHIP_IRI, PUBLIC); assertEquals(SANDBOX_RELATIONSHIP_IRI, publicRelationship.getIRI()); }
@Test(expected = VisalloAccessDeniedException.class) public void testCreatingPropertyWithNoUserOrWorkspace() { List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); OntologyPropertyDefinition ontologyPropertyDefinition = new OntologyPropertyDefinition(thing, PUBLIC_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, PropertyType.DATE); getOntologyRepository().getOrCreateProperty(ontologyPropertyDefinition, null, PUBLIC); }
@Test(expected = VisalloAccessDeniedException.class) public void testCreatingPublicPropertyWithoutPublishPrivilege() { List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); OntologyPropertyDefinition ontologyPropertyDefinition = new OntologyPropertyDefinition(thing, PUBLIC_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, PropertyType.DATE); getOntologyRepository().getOrCreateProperty(ontologyPropertyDefinition, user, PUBLIC); }
@Test public void testCreatingSandboxedConcepts() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, SANDBOX_CONCEPT_IRI, SANDBOX_DISPLAY_NAME, null, user, workspaceId); getOntologyRepository().clearCache(); Concept noWorkspace = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, PUBLIC); assertNull(noWorkspace); Concept withWorkspace = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId); assertEquals(SANDBOX_DISPLAY_NAME, withWorkspace.getDisplayName()); }
@Test public void testDeletingProperties() throws Exception { createSampleOntology(); OntologyProperty property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, workspaceId); assertTrue("Property exists", property != null); getOntologyRepository().deleteProperty(SANDBOX_PROPERTY_IRI, adminUser, workspaceId); getOntologyRepository().clearCache(workspaceId); property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, workspaceId); assertTrue("Property is deleted", property == null); }
@Test public void testCreatingPublicRelationshipsAsSystem() { List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); getOntologyRepository().getOrCreateRelationshipType(null, thing, thing, PUBLIC_RELATIONSHIP_IRI, null, true, systemUser, PUBLIC); getOntologyRepository().clearCache(); Relationship noWorkspace = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, PUBLIC); assertEquals(PUBLIC_RELATIONSHIP_IRI, noWorkspace.getIRI()); Relationship withWorkspace = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, workspaceId); assertEquals(PUBLIC_RELATIONSHIP_IRI, withWorkspace.getIRI()); }
@Test public void testCreatingPublicRelationships() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); getOntologyRepository().getOrCreateRelationshipType(null, thing, thing, PUBLIC_RELATIONSHIP_IRI, null, true, user, PUBLIC); getOntologyRepository().clearCache(); Relationship noWorkspace = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, PUBLIC); assertEquals(PUBLIC_RELATIONSHIP_IRI, noWorkspace.getIRI()); Relationship withWorkspace = getOntologyRepository().getRelationshipByIRI(PUBLIC_RELATIONSHIP_IRI, workspaceId); assertEquals(PUBLIC_RELATIONSHIP_IRI, withWorkspace.getIRI()); }
@Test(expected = VisalloAccessDeniedException.class) public void testExceptionWhenDeletingPublicProperties() throws Exception { createSampleOntology(); getOntologyRepository().deleteProperty(PUBLIC_PROPERTY_IRI, user, null); }
private OntologyProperty createProperty(String iri, String displayName, List<Concept> concepts, List<Relationship> relationships, String workspaceId) { OntologyPropertyDefinition publicPropertyDefinition = new OntologyPropertyDefinition(concepts, relationships, iri, displayName, PropertyType.STRING); publicPropertyDefinition.setTextIndexHints(Collections.singleton(TextIndexHint.EXACT_MATCH)); publicPropertyDefinition.setUserVisible(true); return getOntologyRepository().getOrCreateProperty(publicPropertyDefinition, systemUser, workspaceId); }
@Test(expected = VisalloAccessDeniedException.class) public void testExceptionWhenDeletingPublicRelationships() throws Exception { createSampleOntology(); getOntologyRepository().deleteRelationship(PUBLIC_RELATIONSHIP_IRI, user, null); }
@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()); }
@Test public void testProperlyConfiguredThingConcept() throws Exception { createSampleOntology(); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); assertNotNull(thing.getTitleFormula()); assertNotNull(thing.getSubtitleFormula()); assertNotNull(thing.getTimeFormula()); }
@Test public void testExceptionDeletingSandboxedPropertiesWithVertices() throws Exception { createSampleOntology(); VisibilityJson json = VisibilityJson.updateVisibilitySourceAndAddWorkspaceId(new VisibilityJson(), "", workspaceId); Visibility visibility = getVisibilityTranslator().toVisibility(json).getVisibility(); VertexBuilder vb = getGraph().prepareVertex(visibility); vb.setProperty(SANDBOX_PROPERTY_IRI, "a value", visibility); vb.save(authorizations); thrown.expect(VisalloException.class); thrown.expectMessage("Unable to delete property that have elements using it"); getOntologyRepository().deleteProperty(SANDBOX_PROPERTY_IRI, adminUser, workspaceId); }