@Test public void testBranchCommitInsertionQuery() { long count = 0; executeSuccess(queries.branchInsertionStatement(projectId, 0, originCommit, mergedIntoCommit)); executeFailure(queries.branchCommitInsertionQuery(projectId, 1, "sha", 1)); assertEquals(count, getBranchCommitCount()); executeFailure(queries.branchCommitInsertionQuery(projectId, 0, "sha", 1)); assertEquals(count, getBranchCommitCount()); Commit branchCommit = prepareCommit("sha", 0); Commit anotherCommit = prepareCommit("another", 4); executeSuccess(queries.branchCommitInsertionQuery(projectId, 0, branchCommit.sha, 1)); assertEquals(++count, getBranchCommitCount()); executeSuccess(queries.branchCommitInsertionQuery(projectId, 0, anotherCommit.sha, 2)); assertEquals(++count, getBranchCommitCount()); executeSuccess(queries.branchInsertionStatement(projectId, 1, originCommit, mergedIntoCommit)); executeSuccess(queries.branchCommitInsertionQuery(projectId, 1, branchCommit.sha, 1)); assertEquals(++count, getBranchCommitCount()); executeSuccess(queries.branchCommitInsertionQuery(projectId, 1, anotherCommit.sha, 4)); assertEquals(++count, getBranchCommitCount()); int secondProjectID = createProject("anotherProject", projectQueries); executeSuccess(commitQueries.commitInsertionStatement(secondProjectID, originCommit, GitDiff.EMPTY)); executeSuccess(commitQueries.commitInsertionStatement(secondProjectID, mergedIntoCommit, GitDiff.EMPTY)); executeSuccess(commitQueries.commitInsertionStatement(secondProjectID, branchCommit, GitDiff.EMPTY)); executeSuccess(commitQueries.commitInsertionStatement(secondProjectID, anotherCommit, GitDiff.EMPTY)); executeSuccess(queries.branchInsertionStatement(secondProjectID, 0, originCommit, mergedIntoCommit)); executeSuccess(queries.branchCommitInsertionQuery(secondProjectID, 0, branchCommit.sha, 1)); assertEquals(++count, getBranchCommitCount()); executeSuccess(queries.branchCommitInsertionQuery(secondProjectID, 0, anotherCommit.sha, 3)); assertEquals(++count, getBranchCommitCount()); executeNothinhDone(queries.branchCommitInsertionQuery(projectId, 0, branchCommit.sha, 1)); assertEquals(count, getBranchCommitCount()); executeNothinhDone(queries.branchCommitInsertionQuery(projectId, 0, anotherCommit.sha, 2)); assertEquals(count, getBranchCommitCount()); executeNothinhDone(queries.branchCommitInsertionQuery(projectId, 0, anotherCommit.sha, 1)); assertEquals(count, getBranchCommitCount()); executeNothinhDone(queries.branchCommitInsertionQuery(projectId, 0, branchCommit.sha, 2)); assertEquals(count, getBranchCommitCount()); executeNothinhDone(queries.branchCommitInsertionQuery(projectId, 0, anotherCommit.sha, 45)); assertEquals(count, getBranchCommitCount()); executeNothinhDone(queries.branchCommitInsertionQuery(projectId, 0, branchCommit.sha, 27)); assertEquals(count, getBranchCommitCount()); }
@Override public String branchCommitInsertionQuery(int projectId, int branchOrdinal, String commitSha, int ordinal) { return "INSERT INTO branch_commit (branch_id, commit_id, ordinal) VALUES (" + "(" + idFromOrdinalQueryStatement(projectId, branchOrdinal) + "), " + "(" + commitQueries.idFromShaQuery(projectId, commitSha) + "), " + ordinal + ") ON CONFLICT DO NOTHING;"; }
JDBCBranchQueries extends JDBCQueriesHelper implements BranchQueries { @Override public String branchCommitInsertionQuery(int projectId, int branchOrdinal, String commitSha, int ordinal) { return "INSERT INTO branch_commit (branch_id, commit_id, ordinal) VALUES (" + "(" + idFromOrdinalQueryStatement(projectId, branchOrdinal) + "), " + "(" + commitQueries.idFromShaQuery(projectId, commitSha) + "), " + ordinal + ") ON CONFLICT DO NOTHING;"; } }
JDBCBranchQueries extends JDBCQueriesHelper implements BranchQueries { @Override public String branchCommitInsertionQuery(int projectId, int branchOrdinal, String commitSha, int ordinal) { return "INSERT INTO branch_commit (branch_id, commit_id, ordinal) VALUES (" + "(" + idFromOrdinalQueryStatement(projectId, branchOrdinal) + "), " + "(" + commitQueries.idFromShaQuery(projectId, commitSha) + "), " + ordinal + ") ON CONFLICT DO NOTHING;"; } JDBCBranchQueries(CommitQueries commitQueries, SmellQueries smellQueries); }
JDBCBranchQueries extends JDBCQueriesHelper implements BranchQueries { @Override public String branchCommitInsertionQuery(int projectId, int branchOrdinal, String commitSha, int ordinal) { return "INSERT INTO branch_commit (branch_id, commit_id, ordinal) VALUES (" + "(" + idFromOrdinalQueryStatement(projectId, branchOrdinal) + "), " + "(" + commitQueries.idFromShaQuery(projectId, commitSha) + "), " + ordinal + ") ON CONFLICT DO NOTHING;"; } JDBCBranchQueries(CommitQueries commitQueries, SmellQueries smellQueries); @Override String branchInsertionStatement(int projectId, int ordinal, Commit parentCommit, Commit mergedInto); @Override String branchCommitInsertionQuery(int projectId, int branchOrdinal, String commitSha, int ordinal); @Override String idFromOrdinalQueryStatement(int projectId, int branchOrdinal); String idFromCommitQueryStatement(int projectId, Commit commit); @Override String parentCommitSmellsQuery(int projectId, int branchId, String smellType); @Override String lastCommitSmellsQuery(int projectId, Commit merge, String smellType); @Override String mergedBranchIdQuery(int projectId, Commit commit); @Override String shaFromOrdinalQuery(int projectId, int branchId, int ordinal); @Override String shaFromOrdinalQuery(int projectId, int branchId, int ordinal, boolean paprikaOnly); @Override String parentCommitIdQuery(int projectId, int branchId); @Override String parentCommitShaQuery(int projectId, int branchId); @Override String lastCommitShaQuery(int projectId, int branchId); @Override String lastCommitIdQuery(int projectId, int branchId); @Override String commitOrdinalQuery(int projectId, int branchId, Commit commit); }
JDBCBranchQueries extends JDBCQueriesHelper implements BranchQueries { @Override public String branchCommitInsertionQuery(int projectId, int branchOrdinal, String commitSha, int ordinal) { return "INSERT INTO branch_commit (branch_id, commit_id, ordinal) VALUES (" + "(" + idFromOrdinalQueryStatement(projectId, branchOrdinal) + "), " + "(" + commitQueries.idFromShaQuery(projectId, commitSha) + "), " + ordinal + ") ON CONFLICT DO NOTHING;"; } JDBCBranchQueries(CommitQueries commitQueries, SmellQueries smellQueries); @Override String branchInsertionStatement(int projectId, int ordinal, Commit parentCommit, Commit mergedInto); @Override String branchCommitInsertionQuery(int projectId, int branchOrdinal, String commitSha, int ordinal); @Override String idFromOrdinalQueryStatement(int projectId, int branchOrdinal); String idFromCommitQueryStatement(int projectId, Commit commit); @Override String parentCommitSmellsQuery(int projectId, int branchId, String smellType); @Override String lastCommitSmellsQuery(int projectId, Commit merge, String smellType); @Override String mergedBranchIdQuery(int projectId, Commit commit); @Override String shaFromOrdinalQuery(int projectId, int branchId, int ordinal); @Override String shaFromOrdinalQuery(int projectId, int branchId, int ordinal, boolean paprikaOnly); @Override String parentCommitIdQuery(int projectId, int branchId); @Override String parentCommitShaQuery(int projectId, int branchId); @Override String lastCommitShaQuery(int projectId, int branchId); @Override String lastCommitIdQuery(int projectId, int branchId); @Override String commitOrdinalQuery(int projectId, int branchId, Commit commit);  }