SesameAdapter implements Closeable, Wrapper { URI generateIdentifier(URI classUri) throws SesameDriverException { startTransactionIfNotActive(); boolean unique = false; URI id = null; int counter = 0; while (!unique && counter++ < ID_GENERATION_THRESHOLD) { id = IdentifierUtils.generateIdentifier(classUri); unique = isIdentifierUnique(id, classUri); } if (!unique) { throw new IdentifierGenerationException("Unable to generate a unique identifier."); } return id; } SesameAdapter(Connector connector, DriverConfiguration configuration); @Override void close(); @Override boolean isOpen(); @Override T unwrap(Class<T> cls);  }
@Test void testGenerateIdentifierNeverUnique() throws Exception { final URI clsUri = URI.create("http: when( connectorMock.containsStatement(any(Resource.class), eq(RDF.TYPE), eq(vf.createIRI(clsUri.toString())), eq(true))).thenReturn(true); assertThrows(IdentifierGenerationException.class, () -> adapter.generateIdentifier(clsUri)); }