@Test
public void testRemoveVersionedRDFRecord() throws Exception {

    // Setup:
    VersionedRDFRecord record = versionedRDFRecordFactory.createNew(VERSIONED_RDF_RECORD_IRI);
    record.setCatalog(catalogFactory.createNew(distributedCatalogId));
    Tag tag = tagFactory.createNew(TAG_IRI);
    Distribution dist = distributionFactory.createNew(DISTRIBUTION_IRI);
    Branch branch = branchFactory.createNew(MASTER_BRANCH_IRI);
    tag.setVersionedDistribution(Collections.singleton(dist));
    record.setVersion(Collections.singleton(tag));
    record.setLatestVersion(tag);
    record.setBranch(Collections.singleton(branch));
    record.setMasterBranch(branch);
    doReturn(Optional.of(record)).when(utilsService).optObject(eq(VERSIONED_RDF_RECORD_IRI), eq(versionedRDFRecordFactory), any(RepositoryConnection.class));
    Record result = manager.removeRecord(distributedCatalogId, VERSIONED_RDF_RECORD_IRI, versionedRDFRecordFactory);
    assertEquals(record, result);
    verify(mergeRequestManager).deleteMergeRequestsWithRecordId(eq(VERSIONED_RDF_RECORD_IRI), any(RepositoryConnection.class));
    verify(utilsService).removeVersion(eq(record.getResource()), any(Resource.class), any(RepositoryConnection.class));
    verify(utilsService).removeBranch(eq(record.getResource()), any(Resource.class), any(List.class), any(RepositoryConnection.class));
    verify(utilsService).removeObject(any(VersionedRDFRecord.class), any(RepositoryConnection.class));
}