MobiOntologyIRIMapper implements OWLOntologyIRIMapper { @Nullable @Override public IRI getDocumentIRI(IRI ontologyIRI) { Optional<Resource> recordId = manager.getOntologyRecordResource(SimpleOntologyValues.mobiIRI(ontologyIRI)); return recordId.map(resource -> IRI.create(resource.stringValue().replace(standardProtocol, protocol))).orElse(null); } MobiOntologyIRIMapper(OntologyManager manager); @Nullable @Override IRI getDocumentIRI(IRI ontologyIRI); static final String protocol; static final String standardProtocol; }
@Test public void getDocumentIRIThatExistsTest() throws Exception { String recordIRI = "https: when(ontologyManager.getOntologyRecordResource(any(Resource.class))).thenReturn(Optional.of(vf.createIRI(recordIRI))); IRI result = mapper.getDocumentIRI(owlIRI); assertNotNull(result); assertEquals(recordIRI.replace("https:", MobiOntologyIRIMapper.protocol), result.getIRIString()); }
@Test public void getDocumentIRIThatDoesNotExist() throws Exception { when(ontologyManager.getOntologyRecordResource(any(Resource.class))).thenReturn(Optional.empty()); assertNull(mapper.getDocumentIRI(owlIRI)); }