@Test
public void addCommitToMasterWithChangesWithBaseAndUsedOntologyIRITest() throws Exception {

    // Setup:
    Model additionsModel = MODEL_FACTORY.createModel(additionsUsed.collect(Collectors.toSet()));
    Model deletions = MODEL_FACTORY.createModel();
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Ontology already exists with IRI " + usedIRI);
    try (RepositoryConnection conn = repo.getConnection()) {
        service.addCommit(branch, user, "Message", additionsModel, deletions, commit, null, conn);
    } finally {
        verify(catalogManager).createInProgressCommit(user);
        verify(catalogManager).createCommit(inProgressCommit, "Message", commit, null);
        verify(catalogUtils, times(0)).getCommitChain(any(com.mobi.rdf.api.Resource.class), eq(false), any(RepositoryConnection.class));
        verify(catalogUtils, times(0)).getCompiledResource(anyListOf(com.mobi.rdf.api.Resource.class), any(RepositoryConnection.class));
        verify(catalogUtils).applyDifference(any(Model.class), any(Difference.class));
        verify(catalogUtils).getObject(eq(record.getResource()), eq(ontologyRecordFactory), any(RepositoryConnection.class));
        verify(ontologyManager).ontologyIriExists(usedIRI);
        verify(catalogUtils, times(0)).updateCommit(eq(commit), eq(additionsModel), eq(deletions), any(RepositoryConnection.class));
        verify(catalogUtils, times(0)).addCommit(eq(branch), eq(commit), any(RepositoryConnection.class));
        assertTrue(record.getOntologyIRI().isPresent());
        assertEquals(originalIRI, record.getOntologyIRI().get());
        verify(catalogUtils, times(0)).updateObject(eq(record), any(RepositoryConnection.class));
        verify(ontologyCache).clearCacheImports(originalIRI);
    }
}