@Test
public void getHeadCommit() throws Exception {

    // Setup:
    Resource commitId = VALUE_FACTORY.createIRI(COMMITS + "test4a");
    Branch branch = branchFactory.createNew(BRANCH_IRI);
    Commit commit = commitFactory.createNew(commitId);
    doReturn(commitId).when(utilsService).getHeadCommitIRI(branch);
    doReturn(branch).when(utilsService).getExpectedObject(eq(BRANCH_IRI), eq(branchFactory), any(RepositoryConnection.class));
    doReturn(commit).when(utilsService).getExpectedObject(eq(commitId), eq(commitFactory), any(RepositoryConnection.class));
    Commit result = manager.getHeadCommit(distributedCatalogId, RECORD_IRI, BRANCH_IRI);
    verify(utilsService).validateBranch(eq(distributedCatalogId), eq(RECORD_IRI), eq(BRANCH_IRI), any(RepositoryConnection.class));
    verify(utilsService).getExpectedObject(eq(BRANCH_IRI), eq(branchFactory), any(RepositoryConnection.class));
    verify(utilsService).getExpectedObject(eq(commitId), eq(commitFactory), any(RepositoryConnection.class));
    assertEquals(commit, result);
}