JDBCBranchQueries extends JDBCQueriesHelper implements BranchQueries { @Override public String parentCommitSmellsQuery(int projectId, int branchId, String smellType) { return smellQueries.commitSmellsQuery(projectId, "(" + parentCommitIdQuery(projectId, branchId) + ")", smellType); } 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);  }
@Test public void testParentCommitSmellsQuery() { List<Map<String, Object>> result; result = persistence.query(queries.parentCommitSmellsQuery(projectId, 0, null)); assertTrue(result.isEmpty()); String filtered_type = "MIM"; result = persistence.query(queries.parentCommitSmellsQuery(projectId, 0, filtered_type)); assertTrue(result.isEmpty()); Smell smell1 = new Smell(filtered_type, "instance1", "file1"); Smell smell2 = new Smell(filtered_type, "instance2", "file2"); Smell smell3 = new Smell("LIC", "instance3", "file3"); addSmells(originCommit, smell1, smell2, smell3); addSmells(mergedIntoCommit, smell3); int firstBranchID = insertBranch(projectId, 4, originCommit, mergedIntoCommit); int secondBranchID = insertBranch(projectId, 5, mergedIntoCommit, originCommit); result = persistence.query(queries.parentCommitSmellsQuery(projectId, firstBranchID, null)); checkContainsSmells(result, Arrays.asList(smell1, smell2, smell3)); result = persistence.query(queries.parentCommitSmellsQuery(projectId, firstBranchID, filtered_type)); checkContainsSmells(result, Arrays.asList(smell1, smell2)); result = persistence.query(queries.parentCommitSmellsQuery(projectId, firstBranchID, "LOL")); assertTrue(result.isEmpty()); result = persistence.query(queries.parentCommitSmellsQuery(projectId, secondBranchID, null)); checkContainsSmells(result, Collections.singletonList(smell3)); result = persistence.query(queries.parentCommitSmellsQuery(projectId, secondBranchID, smell3.type)); checkContainsSmells(result, Collections.singletonList(smell3)); }