@Test
public void removeBranchCompleteTest() {

    // Setup:
    Resource complexRecordIRI = VALUE_FACTORY.createIRI(RECORDS + "complex-record");
    Resource complexBranchIRI = VALUE_FACTORY.createIRI(BRANCHES + "complex-branch");
    Resource commitA = VALUE_FACTORY.createIRI(COMMITS + "complex-a");
    IRI commitARevision = VALUE_FACTORY.createIRI(REVISIONS + "complex-a");
    IRI commitAAdditions = VALUE_FACTORY.createIRI(ADDITIONS + "complex-a");
    IRI commitADeletions = VALUE_FACTORY.createIRI(DELETIONS + "complex-a");
    Resource commitB = VALUE_FACTORY.createIRI(COMMITS + "complex-b");
    Resource commitC = VALUE_FACTORY.createIRI(COMMITS + "complex-c");
    IRI commitCRevision = VALUE_FACTORY.createIRI(REVISIONS + "complex-c");
    IRI commitCAdditions = VALUE_FACTORY.createIRI(ADDITIONS + "complex-c");
    IRI commitCDeletions = VALUE_FACTORY.createIRI(DELETIONS + "complex-c");
    Resource commitD = VALUE_FACTORY.createIRI(COMMITS + "complex-d");
    try (RepositoryConnection conn = repo.getConnection()) {
        assertTrue(conn.getStatements(complexRecordIRI, BRANCH_CATALOG_IRI, complexBranchIRI, complexRecordIRI).hasNext());
        assertTrue(conn.getStatements(commitA, typeIRI, COMMIT_CATALOG_IRI, commitA).hasNext());
        assertTrue(conn.getStatements(commitARevision, ADDITIONS_CATALOG_IRI, commitAAdditions, commitA).hasNext());
        assertTrue(conn.getStatements(commitARevision, DELETIONS_CATALOG_IRI, commitADeletions, commitA).hasNext());
        assertTrue(conn.getStatements(commitC, typeIRI, COMMIT_CATALOG_IRI, commitC).hasNext());
        assertTrue(conn.getStatements(commitCRevision, ADDITIONS_CATALOG_IRI, commitCAdditions, commitC).hasNext());
        assertTrue(conn.getStatements(commitCRevision, DELETIONS_CATALOG_IRI, commitCDeletions, commitC).hasNext());
        assertTrue(conn.getStatements(commitB, typeIRI, COMMIT_CATALOG_IRI, commitB).hasNext());
        assertTrue(conn.getStatements(commitD, typeIRI, COMMIT_CATALOG_IRI, commitD).hasNext());
        List<Resource> deletedCommits = service.removeBranch(complexRecordIRI, complexBranchIRI, conn);
        assertEquals(2, deletedCommits.size());
        assertTrue(deletedCommits.contains(commitA));
        assertTrue(deletedCommits.contains(commitC));
        assertFalse(conn.getStatements(complexRecordIRI, BRANCH_CATALOG_IRI, complexBranchIRI, complexRecordIRI).hasNext());
        assertFalse(conn.getStatements(commitA, typeIRI, COMMIT_CATALOG_IRI, commitA).hasNext());
        assertFalse(conn.getStatements(commitARevision, ADDITIONS_CATALOG_IRI, commitAAdditions, commitA).hasNext());
        assertFalse(conn.getStatements(commitARevision, DELETIONS_CATALOG_IRI, commitADeletions, commitA).hasNext());
        assertFalse(conn.getStatements(commitC, typeIRI, COMMIT_CATALOG_IRI, commitC).hasNext());
        assertFalse(conn.getStatements(commitCRevision, ADDITIONS_CATALOG_IRI, commitCAdditions, commitC).hasNext());
        assertFalse(conn.getStatements(commitCRevision, DELETIONS_CATALOG_IRI, commitCDeletions, commitC).hasNext());
        assertTrue(conn.getStatements(commitB, typeIRI, COMMIT_CATALOG_IRI, commitB).hasNext());
        assertTrue(conn.getStatements(commitD, typeIRI, COMMIT_CATALOG_IRI, commitD).hasNext());
    }
}