ImportsResolverImpl implements ImportsResolver { @Override public Optional<Model> retrieveOntologyLocal(Resource ontologyIRI, OntologyManager ontologyManager) { Long startTime = getStartTime(); Model model = mf.createModel(); Optional<Resource> recordIRIOpt = ontologyManager.getOntologyRecordResource(ontologyIRI); if (recordIRIOpt.isPresent()) { Resource recordIRI = recordIRIOpt.get(); Optional<Resource> masterHead = catalogManager.getMasterBranch( catalogConfigProvider.getLocalCatalogIRI(), recordIRI).getHead_resource(); if (masterHead.isPresent()) { model = catalogManager.getCompiledResource(masterHead.get()); } } logDebug("Retrieving ontology from local catalog", startTime); return model.size() > 0 ? Optional.of(model) : Optional.empty(); }  @Override Optional<Model> retrieveOntologyFromWeb(Resource resource); @Override Optional<Model> retrieveOntologyLocal(Resource ontologyIRI, OntologyManager ontologyManager);  }
@Test public void retrieveOntologyLocalTest() { IRI iri = vf.createIRI("urn:localOntology"); Optional<Model> local = resolver.retrieveOntologyLocal(iri, ontologyManager); assertTrue(local.isPresent()); assertTrue(local.get().size() > 0); }
@Test public void retrieveOntologyLocalDoesNotExistTest() { IRI iri = vf.createIRI("urn:localOntology1"); Optional<Model> local = resolver.retrieveOntologyLocal(iri, ontologyManager); assertFalse(local.isPresent()); }
@Test public void retrieveOntologyLocalMasterDoesNotExistTest() { when(masterBranch.getHead_resource()).thenReturn(Optional.empty()); IRI iri = vf.createIRI("urn:localOntology"); Optional<Model> local = resolver.retrieveOntologyLocal(iri, ontologyManager); assertFalse(local.isPresent()); }