@Test
public void testAddVersion() throws Exception {

    // Setup:
    VersionedRecord record = versionedRecordFactory.createNew(VERSIONED_RECORD_IRI);
    doReturn(record).when(utilsService).getRecord(eq(distributedCatalogId), eq(VERSIONED_RECORD_IRI), eq(versionedRecordFactory), any(RepositoryConnection.class));
    Version version = versionFactory.createNew(NEW_IRI);
    manager.addVersion(distributedCatalogId, VERSIONED_RECORD_IRI, version);
    verify(utilsService).getRecord(eq(distributedCatalogId), eq(VERSIONED_RECORD_IRI), eq(versionedRecordFactory), any(RepositoryConnection.class));
    verify(utilsService).updateObject(eq(record), any(RepositoryConnection.class));
    verify(utilsService).addObject(eq(version), any(RepositoryConnection.class));
    assertTrue(record.getLatestVersion_resource().isPresent());
    assertEquals(NEW_IRI, record.getLatestVersion_resource().get());
    assertEquals(1, record.getVersion_resource().size());
}