@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 testCreatingSandboxedRelationshipsWithoutAddPermissionPrivilege() { List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); getOntologyRepository().getOrCreateRelationshipType(null, thing, thing, SANDBOX_RELATIONSHIP_IRI, null, true, user, workspaceId); }
@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(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 testCreatingSandboxedPropertyWithoutAddPermissionPrivilege() { List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); OntologyPropertyDefinition ontologyPropertyDefinition = new OntologyPropertyDefinition(thing, SANDBOX_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, PropertyType.DATE); getOntologyRepository().getOrCreateProperty(ontologyPropertyDefinition, user, workspaceId); }
@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(expected = VisalloAccessDeniedException.class) public void testPublishingPropertyWithoutPublishPrivilege() { setPrivileges(user, Collections.singleton(Privilege.ONTOLOGY_ADD)); List<Concept> thing = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); OntologyPropertyDefinition ontologyPropertyDefinition = new OntologyPropertyDefinition(thing, SANDBOX_PROPERTY_IRI, SANDBOX_DISPLAY_NAME, PropertyType.DATE); OntologyProperty sandboxedProperty = getOntologyRepository().getOrCreateProperty(ontologyPropertyDefinition, user, workspaceId); getOntologyRepository().publishProperty(sandboxedProperty, 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 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 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 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 testProperlyConfiguredThingConcept() throws Exception { createSampleOntology(); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); assertNotNull(thing.getTitleFormula()); assertNotNull(thing.getSubtitleFormula()); assertNotNull(thing.getTimeFormula()); }
@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 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 testExceptionDeletingSandboxedRelationshipsWithDescendants() throws Exception { createSampleOntology(); Relationship relationship = getOntologyRepository().getRelationshipByIRI(SANDBOX_RELATIONSHIP_IRI, workspaceId); VisibilityJson.updateVisibilitySourceAndAddWorkspaceId(new VisibilityJson(), "", workspaceId); List<Concept> things = Collections.singletonList(getOntologyRepository().getEntityConcept(workspaceId)); getOntologyRepository().getOrCreateRelationshipType(relationship, things, things, SANDBOX_RELATIONSHIP_IRI + "child", true, adminUser, workspaceId); getOntologyRepository().clearCache(workspaceId); thrown.expect(VisalloException.class); thrown.expectMessage("Unable to delete relationship that have children"); getOntologyRepository().deleteRelationship(SANDBOX_RELATIONSHIP_IRI, adminUser, workspaceId); }
@Test public void testCreatingPublicConcepts() { setPrivileges(user, Sets.newHashSet(Privilege.ONTOLOGY_ADD, Privilege.ONTOLOGY_PUBLISH)); Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, null, user, PUBLIC); getOntologyRepository().clearCache(); Concept noWorkspace = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, PUBLIC); assertEquals(PUBLIC_DISPLAY_NAME, noWorkspace.getDisplayName()); Concept withWorkspace = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, workspaceId); assertEquals(PUBLIC_DISPLAY_NAME, withWorkspace.getDisplayName()); }
@Test public void testCreatingPublicConceptsAsSystem() { Concept thing = getOntologyRepository().getEntityConcept(workspaceId); getOntologyRepository().getOrCreateConcept(thing, PUBLIC_CONCEPT_IRI, PUBLIC_DISPLAY_NAME, null, systemUser, PUBLIC); getOntologyRepository().clearCache(); Concept noWorkspace = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, PUBLIC); assertEquals(PUBLIC_DISPLAY_NAME, noWorkspace.getDisplayName()); Concept withWorkspace = getOntologyRepository().getConceptByIRI(PUBLIC_CONCEPT_IRI, workspaceId); assertEquals(PUBLIC_DISPLAY_NAME, withWorkspace.getDisplayName()); }