JDBCCommitQueries extends JDBCQueriesHelper implements CommitQueries { @Override public String mergedCommitIdQuery(int projectId, Commit commit) { return "SELECT merged_commit_id AS id FROM commit_entry where sha1 = '" + commit.sha + "'"; } JDBCCommitQueries(DeveloperQueries developerQueries); @Override String commitInsertionStatement(int projectId, Commit commit, GitDiff diff); @Override String idFromShaQuery(int projectId, String sha); @Override String shaFromOrdinalQuery(int projectId, int ordinal); @Override String idFromShaQuery(int projectId, String sha, boolean paprikaOnly); @Override String shaFromOrdinalQuery(int projectId, int ordinal, boolean paprikaOnly); @Override String lastProjectCommitShaQuery(int projectId); @Override String lastProjectCommitShaQuery(int projectId, boolean paprikaOnly); @Override String fileRenameInsertionStatement(int projectId, String commitSha, GitRename rename); @Override String mergedCommitIdQuery(int projectId, Commit commit); @Override String projectIdFromShaQuery(String sha); @Override String updateCommitSizeQuery(int projectId, String tempTable); @Override String fileChangedInsertionStatement(int projectId, String commitSha, GitChangedFile changedFile);  }
@Test public void testMergedCommitIdQuery() { List<Map<String, Object>> result; Commit commit = generateCommit("sha", 1); Commit secondCommit = generateCommit("anotherSha", 2); result = persistence.query(queries.mergedCommitIdQuery(projectId, commit)); assertTrue(result.isEmpty()); executeSuccess(queries.commitInsertionStatement(projectId, commit, GitDiff.EMPTY)); executeSuccess(queries.commitInsertionStatement(projectId, secondCommit, GitDiff.EMPTY)); 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)); result = persistence.query(queries.mergedCommitIdQuery(projectId, mergeCommit)); assertEquals(1, result.get(0).get("id")); }