@Test public void testInsertSmellCategory() { smell.id = createSmell(projectId, smell, queries); Commit commit = prepareCommit(); executeFailure( queries.smellCategoryInsertionStatement(projectId, "any", smell, SmellCategory.INTRODUCTION) ); executeSuccess( queries.smellCategoryInsertionStatement(projectId, commit.sha, smell, SmellCategory.INTRODUCTION) ); assertEquals(1, getSmellCount(SmellCategory.INTRODUCTION)); assertEquals(0, getSmellCount(SmellCategory.REFACTOR)); assertEquals(0, getSmellCount(SmellCategory.PRESENCE)); executeSuccess( queries.smellCategoryInsertionStatement(projectId, commit.sha, smell, SmellCategory.REFACTOR) ); assertEquals(1, getSmellCount(SmellCategory.INTRODUCTION)); assertEquals(1, getSmellCount(SmellCategory.REFACTOR)); assertEquals(0, getSmellCount(SmellCategory.PRESENCE)); executeSuccess( queries.smellCategoryInsertionStatement(projectId, commit.sha, smell, SmellCategory.PRESENCE) ); assertEquals(1, getSmellCount(SmellCategory.INTRODUCTION)); assertEquals(1, getSmellCount(SmellCategory.REFACTOR)); assertEquals(1, getSmellCount(SmellCategory.PRESENCE)); executeFailure( queries.smellCategoryInsertionStatement(projectId, commit.sha, smell, SmellCategory.PRESENCE) ); assertEquals(1, getSmellCount(SmellCategory.INTRODUCTION)); assertEquals(1, getSmellCount(SmellCategory.REFACTOR)); assertEquals(1, getSmellCount(SmellCategory.PRESENCE)); }
@Override public String smellCategoryInsertionStatement(int projectId, String sha1, Smell smell, SmellCategory category) { return "INSERT INTO " + category.getName() + " (project_id, smell_id, commit_id) VALUES " + "(" + projectId + ", " + smell.id + ", (" + commitQueries.idFromShaQuery(projectId, sha1) + "));"; }
JDBCSmellQueries extends JDBCQueriesHelper implements SmellQueries { @Override public String smellCategoryInsertionStatement(int projectId, String sha1, Smell smell, SmellCategory category) { return "INSERT INTO " + category.getName() + " (project_id, smell_id, commit_id) VALUES " + "(" + projectId + ", " + smell.id + ", (" + commitQueries.idFromShaQuery(projectId, sha1) + "));"; } }
JDBCSmellQueries extends JDBCQueriesHelper implements SmellQueries { @Override public String smellCategoryInsertionStatement(int projectId, String sha1, Smell smell, SmellCategory category) { return "INSERT INTO " + category.getName() + " (project_id, smell_id, commit_id) VALUES " + "(" + projectId + ", " + smell.id + ", (" + commitQueries.idFromShaQuery(projectId, sha1) + "));"; } JDBCSmellQueries(CommitQueries commitQueries); }
JDBCSmellQueries extends JDBCQueriesHelper implements SmellQueries { @Override public String smellCategoryInsertionStatement(int projectId, String sha1, Smell smell, SmellCategory category) { return "INSERT INTO " + category.getName() + " (project_id, smell_id, commit_id) VALUES " + "(" + projectId + ", " + smell.id + ", (" + commitQueries.idFromShaQuery(projectId, sha1) + "));"; } JDBCSmellQueries(CommitQueries commitQueries); @Override String smellInsertionStatement(int projectId, Smell smell); @Override String smellCategoryInsertionStatement(int projectId, String sha1, Smell smell, SmellCategory category); @Override String lostSmellCategoryInsertionStatement(int projectId, Smell smell, SmellCategory category, int since, int until); @Override String smellIdQuery(int projectId, Smell smell); @Override String commitSmellsQuery(int projectId, String commitId, String smellType); String lastSmellIdQuery(int projectId); String allRefactoredInstancesWithSha1(int projectId); String setAsDeleted(int projectId, int refactoringId, boolean deleted); }
JDBCSmellQueries extends JDBCQueriesHelper implements SmellQueries { @Override public String smellCategoryInsertionStatement(int projectId, String sha1, Smell smell, SmellCategory category) { return "INSERT INTO " + category.getName() + " (project_id, smell_id, commit_id) VALUES " + "(" + projectId + ", " + smell.id + ", (" + commitQueries.idFromShaQuery(projectId, sha1) + "));"; } JDBCSmellQueries(CommitQueries commitQueries); @Override String smellInsertionStatement(int projectId, Smell smell); @Override String smellCategoryInsertionStatement(int projectId, String sha1, Smell smell, SmellCategory category); @Override String lostSmellCategoryInsertionStatement(int projectId, Smell smell, SmellCategory category, int since, int until); @Override String smellIdQuery(int projectId, Smell smell); @Override String commitSmellsQuery(int projectId, String commitId, String smellType); String lastSmellIdQuery(int projectId); String allRefactoredInstancesWithSha1(int projectId); String setAsDeleted(int projectId, int refactoringId, boolean deleted);  }