@Test
public void addCommitToMasterWithCommitWithBaseAndUsedOntologyIRITest() throws Exception {

    // Setup:
    commit.setBaseCommit(commitFactory.createNew(VALUE_FACTORY.createIRI("http://mobi.com/test/commits#new")));
    when(catalogUtils.getAdditions(eq(commit), any(RepositoryConnection.class))).thenReturn(additionsUsed);
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Ontology already exists with IRI " + usedIRI);
    try (RepositoryConnection conn = repo.getConnection()) {
        service.addCommit(branch, commit, conn);
    } finally {
        verify(catalogUtils).getAdditions(eq(commit), any(RepositoryConnection.class));
        verify(catalogUtils).getObject(eq(record.getResource()), eq(ontologyRecordFactory), any(RepositoryConnection.class));
        verify(catalogUtils, times(0)).addCommit(eq(branch), eq(commit), any(RepositoryConnection.class));
        verify(ontologyManager).ontologyIriExists(usedIRI);
        assertTrue(record.getOntologyIRI().isPresent());
        assertEquals(originalIRI, record.getOntologyIRI().get());
        verify(catalogUtils, times(0)).updateObject(eq(record), any(RepositoryConnection.class));
        verify(ontologyCache).clearCacheImports(originalIRI);
    }
}