@Test
public void testIdFromCommitQueryStatement() {

    List<Map<String, Object>> result;
    Commit branchCommit = prepareCommit("sha", 0);
    Commit anotherCommit = prepareCommit("another", 4);
    // No commit means no result
    result = persistence.query(queries.idFromCommitQueryStatement(projectId, branchCommit));
    assertTrue(result.isEmpty());
    int firstBranchID = insertBranch(projectId, 4, originCommit, mergedIntoCommit);
    int secondBranchID = insertBranch(projectId, 5, mergedIntoCommit, originCommit);
    // Parent and merged commits are not in the branch
    result = persistence.query(queries.idFromCommitQueryStatement(projectId, originCommit));
    assertTrue(result.isEmpty());
    result = persistence.query(queries.idFromCommitQueryStatement(projectId, mergedIntoCommit));
    assertTrue(result.isEmpty());
    persistence.execute(queries.branchCommitInsertionQuery(projectId, 4, branchCommit.sha, 0));
    persistence.execute(queries.branchCommitInsertionQuery(projectId, 4, anotherCommit.sha, 1));
    // Right commit returns branch ID
    result = persistence.query(queries.idFromCommitQueryStatement(projectId, branchCommit));
    assertEquals(firstBranchID, result.get(0).get("id"));
    result = persistence.query(queries.idFromCommitQueryStatement(projectId, anotherCommit));
    assertEquals(firstBranchID, result.get(0).get("id"));
    // TODO: Commit should not appear in 2 distinct branches
    persistence.execute(queries.branchCommitInsertionQuery(projectId, 5, branchCommit.sha, 2));
    result = persistence.query(queries.idFromCommitQueryStatement(projectId, branchCommit));
    assertEquals(firstBranchID, result.get(0).get("id"));
}