### Question:
OWLUtils { public static OWLOntologyID extractOntologyID(OWLOntology o) { String oiri; IRI viri = null; if (o.isAnonymous()) oiri = o.getOWLOntologyManager().getOntologyDocumentIRI(o).toString(); else { OWLOntologyID id = o.getOntologyID(); oiri = id.getOntologyIRI().toString(); viri = id.getVersionIRI(); } while (oiri.endsWith("#") || oiri.endsWith("?")) oiri = oiri.substring(0, oiri.length() - 1); if (viri != null) return new OWLOntologyID(IRI.create(oiri), viri); else return new OWLOntologyID(IRI.create(oiri)); } private  OWLUtils(); static OWLOntologyID extractOntologyID(OWLOntology o); static OWLOntologyID extractOntologyID(Graph graph); static OWLOntologyID guessOntologyID(InputStream content, Parser parser, String format); static OWLOntologyID guessOntologyID(InputStream content, Parser parser, String format, int limit); static OWLOntologyID guessOntologyID(InputStream content,
                                                Parser parser,
                                                String format,
                                                int limit,
                                                int versionIriOffset); static final String NS_STANBOL; }### Answer:
@Test public void namedIRI() throws Exception { InputStream inputStream = getClass().getResourceAsStream("/owl/maincharacters.owl"); Graph mg = TcManager.getInstance().createGraph(uri); parser.parse(mg, inputStream, "application/rdf+xml", uri); assertNotNull(OWLUtils.extractOntologyID(mg.getImmutableGraph())); }
@Test public void namelessIRI() throws Exception { InputStream inputStream = getClass().getResourceAsStream("/owl/nameless.owl"); Graph mg = TcManager.getInstance().createGraph(uri); parser.parse(mg, inputStream, "application/rdf+xml", uri); assertNull(OWLUtils.extractOntologyID(mg.getImmutableGraph())); }