@Test
public void testRemoveVersionedRecord() throws Exception {

    // Setup:
    VersionedRecord record = versionedRecordFactory.createNew(VERSIONED_RECORD_IRI);
    record.setCatalog(catalogFactory.createNew(distributedCatalogId));
    Version version = versionFactory.createNew(VERSION_IRI);
    record.setVersion(Collections.singleton(version));
    record.setLatestVersion(version);
    Distribution dist = distributionFactory.createNew(DISTRIBUTION_IRI);
    version.setVersionedDistribution(Collections.singleton(dist));
    doReturn(Optional.of(record)).when(utilsService).optObject(eq(VERSIONED_RECORD_IRI), eq(versionedRecordFactory), any(RepositoryConnection.class));
    Record result = manager.removeRecord(distributedCatalogId, VERSIONED_RECORD_IRI, versionedRecordFactory);
    assertEquals(record, result);
    verify(utilsService).removeVersion(eq(record.getResource()), any(Resource.class), any(RepositoryConnection.class));
    verify(utilsService).removeObject(any(VersionedRDFRecord.class), any(RepositoryConnection.class));
}