@Test
public void testMergedCommitIdQuery() {

    List<Map<String, Object>> result;
    Commit commit = generateCommit("sha", 1);
    Commit secondCommit = generateCommit("anotherSha", 2);
    // No commit means no result
    result = persistence.query(queries.mergedCommitIdQuery(projectId, commit));
    assertTrue(result.isEmpty());
    executeSuccess(queries.commitInsertionStatement(projectId, commit, GitDiff.EMPTY));
    executeSuccess(queries.commitInsertionStatement(projectId, secondCommit, GitDiff.EMPTY));
    // Not a merge commit means no result in row
    result = persistence.query(queries.mergedCommitIdQuery(projectId, commit));
    assertFalse(result.isEmpty());
    assertNull("returned ID is null", result.get(0).get("id"));
    result = persistence.query(queries.mergedCommitIdQuery(projectId, secondCommit));
    assertFalse(result.isEmpty());
    assertNull("returned ID is null", result.get(0).get("id"));
    Commit mergeCommit = generateCommit("thirdSha", 3);
    mergeCommit.setParents(Arrays.asList(secondCommit, commit));
    executeSuccess(queries.commitInsertionStatement(projectId, mergeCommit, GitDiff.EMPTY));
    // Merge commit returns the ID of the second parent commit.
    result = persistence.query(queries.mergedCommitIdQuery(projectId, mergeCommit));
    assertEquals(1, result.get(0).get("id"));
}