@Test
public void testDeletingSandboxedConcepts() throws Exception {
createSampleOntology();
Concept concept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId);
assertTrue("Concept exists", concept != null && concept.getIRI().equals(SANDBOX_CONCEPT_IRI));
OntologyProperty property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT, workspaceId);
assertTrue("Property exists", property != null && property.getIri().equals(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT));
assertTrue("Concept has property", concept.getProperties().stream().anyMatch(ontologyProperty -> ontologyProperty.getIri().equals(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT)));
getOntologyRepository().deleteConcept(SANDBOX_CONCEPT_IRI, adminUser, workspaceId);
getOntologyRepository().clearCache(workspaceId);
concept = getOntologyRepository().getConceptByIRI(SANDBOX_CONCEPT_IRI, workspaceId);
assertTrue("Concept should have been deleted", concept == null);
property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI_ONLY_SANDBOXED_CONCEPT, workspaceId);
assertTrue("Property only used in this concept is deleted", property == null);
property = getOntologyRepository().getPropertyByIRI(SANDBOX_PROPERTY_IRI, workspaceId);
assertTrue("Property used in other concepts is updated", property != null);
assertEquals(1, property.getConceptIris().size());
assertEquals(PUBLIC_CONCEPT_IRI, property.getConceptIris().get(0));
}