@Test public void testBranchInsertionStatement() { long count = 0; Commit notPersistedOriginCommit = generateCommit("origin", 0); Commit notPersistedMergedCommit = generateCommit("merged", 42); executeSuccess(queries.branchInsertionStatement(projectId, 9, notPersistedOriginCommit, notPersistedMergedCommit)); assertEquals(++count, getBranchCount()); Commit anotherCommit = prepareCommit("another", 4); executeSuccess(queries.branchInsertionStatement(projectId, 0, originCommit, mergedIntoCommit)); assertEquals(++count, getBranchCount()); executeSuccess(queries.branchInsertionStatement(projectId, 1, originCommit, mergedIntoCommit)); assertEquals(++count, getBranchCount()); executeSuccess(queries.branchInsertionStatement(projectId, 2, anotherCommit, mergedIntoCommit)); assertEquals(++count, getBranchCount()); executeSuccess(queries.branchInsertionStatement(projectId, 3, mergedIntoCommit, anotherCommit)); assertEquals(++count, getBranchCount()); int secondProjectID = createProject("anotherProject", projectQueries); executeSuccess(queries.branchInsertionStatement(secondProjectID, 0, originCommit, mergedIntoCommit)); assertEquals(++count, getBranchCount()); executeNothinhDone(queries.branchInsertionStatement(projectId, 0, originCommit, mergedIntoCommit)); assertEquals(count, getBranchCount()); executeNothinhDone(queries.branchInsertionStatement(projectId, 0, anotherCommit, mergedIntoCommit)); assertEquals(count, getBranchCount()); executeNothinhDone(queries.branchInsertionStatement(projectId, 0, mergedIntoCommit, anotherCommit)); assertEquals(count, getBranchCount()); }
@Override public String branchInsertionStatement(int projectId, int ordinal, Commit parentCommit, Commit mergedInto) { String parentCommitQuery = parentCommit == null ? null : "(" + commitQueries.idFromShaQuery(projectId, parentCommit.sha) + ")"; String mergedIntoQuery = mergedInto == null ? null : "(" + commitQueries.idFromShaQuery(projectId, mergedInto.sha) + ")"; return "INSERT INTO branch (project_id, ordinal, parent_commit, merged_into) VALUES ('" + projectId + "', '" + ordinal + "', " + parentCommitQuery + ", " + mergedIntoQuery + ") ON CONFLICT DO NOTHING;"; }
JDBCBranchQueries extends JDBCQueriesHelper implements BranchQueries { @Override public String branchInsertionStatement(int projectId, int ordinal, Commit parentCommit, Commit mergedInto) { String parentCommitQuery = parentCommit == null ? null : "(" + commitQueries.idFromShaQuery(projectId, parentCommit.sha) + ")"; String mergedIntoQuery = mergedInto == null ? null : "(" + commitQueries.idFromShaQuery(projectId, mergedInto.sha) + ")"; return "INSERT INTO branch (project_id, ordinal, parent_commit, merged_into) VALUES ('" + projectId + "', '" + ordinal + "', " + parentCommitQuery + ", " + mergedIntoQuery + ") ON CONFLICT DO NOTHING;"; } }
JDBCBranchQueries extends JDBCQueriesHelper implements BranchQueries { @Override public String branchInsertionStatement(int projectId, int ordinal, Commit parentCommit, Commit mergedInto) { String parentCommitQuery = parentCommit == null ? null : "(" + commitQueries.idFromShaQuery(projectId, parentCommit.sha) + ")"; String mergedIntoQuery = mergedInto == null ? null : "(" + commitQueries.idFromShaQuery(projectId, mergedInto.sha) + ")"; return "INSERT INTO branch (project_id, ordinal, parent_commit, merged_into) VALUES ('" + projectId + "', '" + ordinal + "', " + parentCommitQuery + ", " + mergedIntoQuery + ") ON CONFLICT DO NOTHING;"; } JDBCBranchQueries(CommitQueries commitQueries, SmellQueries smellQueries); }
JDBCBranchQueries extends JDBCQueriesHelper implements BranchQueries { @Override public String branchInsertionStatement(int projectId, int ordinal, Commit parentCommit, Commit mergedInto) { String parentCommitQuery = parentCommit == null ? null : "(" + commitQueries.idFromShaQuery(projectId, parentCommit.sha) + ")"; String mergedIntoQuery = mergedInto == null ? null : "(" + commitQueries.idFromShaQuery(projectId, mergedInto.sha) + ")"; return "INSERT INTO branch (project_id, ordinal, parent_commit, merged_into) VALUES ('" + projectId + "', '" + ordinal + "', " + parentCommitQuery + ", " + mergedIntoQuery + ") 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 branchInsertionStatement(int projectId, int ordinal, Commit parentCommit, Commit mergedInto) { String parentCommitQuery = parentCommit == null ? null : "(" + commitQueries.idFromShaQuery(projectId, parentCommit.sha) + ")"; String mergedIntoQuery = mergedInto == null ? null : "(" + commitQueries.idFromShaQuery(projectId, mergedInto.sha) + ")"; return "INSERT INTO branch (project_id, ordinal, parent_commit, merged_into) VALUES ('" + projectId + "', '" + ordinal + "', " + parentCommitQuery + ", " + mergedIntoQuery + ") 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);  }