@Test
public void testLastCommitShaQuery() {

    List<Map<String, Object>> result;
    Commit branchCommit = prepareCommit("sha", 0);
    Commit anotherCommit = prepareCommit("another", 4);
    // No merged branch means no result
    result = persistence.query(queries.lastCommitShaQuery(projectId, 1));
    assertTrue(result.isEmpty());
    int firstBranchID = insertBranch(projectId, 4, originCommit, mergedIntoCommit);
    int secondBranchID = insertBranch(projectId, 5, mergedIntoCommit, originCommit);
    // Nothing returned if no commit in the branch
    result = persistence.query(queries.lastCommitShaQuery(projectId, firstBranchID));
    assertTrue(result.isEmpty());
    result = persistence.query(queries.lastCommitShaQuery(projectId, secondBranchID));
    assertTrue(result.isEmpty());
    executeSuccess(queries.branchCommitInsertionQuery(projectId, 4, branchCommit.sha, 5));
    executeSuccess(queries.branchCommitInsertionQuery(projectId, 4, anotherCommit.sha, 1));
    executeSuccess(queries.branchCommitInsertionQuery(projectId, 5, branchCommit.sha, 0));
    executeSuccess(queries.branchCommitInsertionQuery(projectId, 5, anotherCommit.sha, 1));
    // Adding commits to the branch will change our result
    result = persistence.query(queries.lastCommitShaQuery(projectId, firstBranchID));
    assertEquals(branchCommit.sha, result.get(0).get("sha1"));
    result = persistence.query(queries.lastCommitShaQuery(projectId, secondBranchID));
    assertEquals(anotherCommit.sha, result.get(0).get("sha1"));
}