@Test
public void testShaFromOrdinalQuery() {

    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.shaFromOrdinalQuery(projectId, 0, 1));
    assertTrue(result.isEmpty());
    int firstBranchID = insertBranch(projectId, 4, originCommit, mergedIntoCommit);
    int secondBranchID = insertBranch(projectId, 5, mergedIntoCommit, originCommit);
    // Right branch id returned for each merge commit
    result = persistence.query(queries.mergedBranchIdQuery(projectId, mergedIntoCommit));
    assertEquals(firstBranchID, result.get(0).get("id"));
    result = persistence.query(queries.mergedBranchIdQuery(projectId, originCommit));
    assertEquals(secondBranchID, result.get(0).get("id"));
    persistence.execute(queries.branchCommitInsertionQuery(projectId, 4, branchCommit.sha, 0));
    persistence.execute(queries.branchCommitInsertionQuery(projectId, 4, anotherCommit.sha, 1));
    // Adding commits to the branch will change our result
    result = persistence.query(queries.mergedBranchIdQuery(projectId, mergedIntoCommit));
    assertEquals(firstBranchID, result.get(0).get("id"));
}