JDBCCommitQueries extends JDBCQueriesHelper implements CommitQueries { @Override public String fileRenameInsertionStatement(int projectId, String commitSha, GitRename rename) { return "INSERT INTO file_rename (project_id, commit_id, old_file, new_file, similarity) VALUES ('" + projectId + "', (" + idFromShaQuery(projectId, commitSha) + "), '" + rename.oldFile + "', '" + rename.newFile + "', " + rename.similarity + ") ON CONFLICT DO NOTHING;"; } 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 testFileRenameInsertionStatement() { long count = 0; Commit commit = generateCommit("sha", 1); Commit anotherSha = generateCommit("anotherSha", 1); GitRename rename = new GitRename("old", "new", 100); executeSuccess(queries.commitInsertionStatement(projectId, commit, GitDiff.EMPTY)); executeSuccess(queries.commitInsertionStatement(projectId, anotherSha, GitDiff.EMPTY)); executeSuccess(queries.fileRenameInsertionStatement(projectId, commit.sha, rename)); assertEquals(++count, getRenameCount()); int secondProjectID = createProject("anotherProject"); executeSuccess(queries.commitInsertionStatement(secondProjectID, commit, GitDiff.EMPTY)); executeSuccess(queries.fileRenameInsertionStatement(secondProjectID, commit.sha, rename)); assertEquals(++count, getRenameCount()); executeSuccess(queries.fileRenameInsertionStatement(projectId, anotherSha.sha, rename)); assertEquals(++count, getRenameCount()); GitRename anotherRename = new GitRename("new", "old", 50); executeSuccess(queries.fileRenameInsertionStatement(projectId, commit.sha, anotherRename)); assertEquals(++count, getRenameCount()); executeNothinhDone(queries.fileRenameInsertionStatement(projectId, commit.sha, rename)); assertEquals(count, getRenameCount()); }