@Test public void testRenamedSmellsBackToOriginal() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("0-B", 1); Commit C = new Commit("0-C", 2); Commit D = new Commit("0-D", 3); Commit E = new Commit("0-E", 4); Commit F = new Commit("0-F", 5); Commit G = new Commit("0-G", 6); addSmell(A, firstSmell); addSmell(B, secondSmell); addSmell(C, secondSmell); addSmell(D, firstSmell); addSmell(E, firstSmell); addSmell(F, firstSmell); addSmell(G, firstSmell); mockEndCommit(G.sha); Smell expectedSecondSmell = mockSmellRenamed(B, secondSmell, firstSmell); mockSmellRenamed(C, secondSmell, firstSmell); Smell expectedRenamedFirstSmell = mockSmellRenamed(D, firstSmell, secondSmell); mockSmellRenamed(E, firstSmell, secondSmell); mockSmellRenamed(F, firstSmell, secondSmell); mockSmellRenamed(G, firstSmell, secondSmell); mockSmellId(expectedSecondSmell); expectedRenamedFirstSmell.parent = expectedSecondSmell; mockSmellId(expectedRenamedFirstSmell); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, expectedSecondSmell); verify(smellQueries).smellInsertionStatement(projectId, expectedRenamedFirstSmell); verify(persistence, times(8)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, expectedSecondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, expectedSecondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, expectedRenamedFirstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, expectedRenamedFirstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, expectedRenamedFirstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, expectedRenamedFirstSmell, SmellCategory.PRESENCE); }
@Override public void query() throws QueryException { Smell smell; Commit commit; Map<String, Object> instance; BranchAnalyzer branchAnalyzer = new BranchAnalyzer( projectId, persistence, duplicationChecker, commitQueries, smellQueries ); while (smells.hasNext()) { instance = smells.next(); smell = Smell.fromPaprikaInstance(instance, smellType); commit = Commit.fromInstance(instance); branchAnalyzer.notifyCommit(commit); branchAnalyzer.notifySmell(smell); } branchAnalyzer.notifyEnd(); }
OrdinalSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit commit; Map<String, Object> instance; BranchAnalyzer branchAnalyzer = new BranchAnalyzer( projectId, persistence, duplicationChecker, commitQueries, smellQueries ); while (smells.hasNext()) { instance = smells.next(); smell = Smell.fromPaprikaInstance(instance, smellType); commit = Commit.fromInstance(instance); branchAnalyzer.notifyCommit(commit); branchAnalyzer.notifySmell(smell); } branchAnalyzer.notifyEnd(); } }
OrdinalSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit commit; Map<String, Object> instance; BranchAnalyzer branchAnalyzer = new BranchAnalyzer( projectId, persistence, duplicationChecker, commitQueries, smellQueries ); while (smells.hasNext()) { instance = smells.next(); smell = Smell.fromPaprikaInstance(instance, smellType); commit = Commit.fromInstance(instance); branchAnalyzer.notifyCommit(commit); branchAnalyzer.notifySmell(smell); } branchAnalyzer.notifyEnd(); } OrdinalSmellTypeAnalysis(int projectId, Persistence persistence, Iterator<Map<String, Object>> smells,
                             String smellType, SmellDuplicationChecker duplicationChecker,
                             CommitQueries commitQueries, SmellQueries smellQueries); }
OrdinalSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit commit; Map<String, Object> instance; BranchAnalyzer branchAnalyzer = new BranchAnalyzer( projectId, persistence, duplicationChecker, commitQueries, smellQueries ); while (smells.hasNext()) { instance = smells.next(); smell = Smell.fromPaprikaInstance(instance, smellType); commit = Commit.fromInstance(instance); branchAnalyzer.notifyCommit(commit); branchAnalyzer.notifySmell(smell); } branchAnalyzer.notifyEnd(); } OrdinalSmellTypeAnalysis(int projectId, Persistence persistence, Iterator<Map<String, Object>> smells,
                             String smellType, SmellDuplicationChecker duplicationChecker,
                             CommitQueries commitQueries, SmellQueries smellQueries); @Override void query(); }
OrdinalSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit commit; Map<String, Object> instance; BranchAnalyzer branchAnalyzer = new BranchAnalyzer( projectId, persistence, duplicationChecker, commitQueries, smellQueries ); while (smells.hasNext()) { instance = smells.next(); smell = Smell.fromPaprikaInstance(instance, smellType); commit = Commit.fromInstance(instance); branchAnalyzer.notifyCommit(commit); branchAnalyzer.notifySmell(smell); } branchAnalyzer.notifyEnd(); } OrdinalSmellTypeAnalysis(int projectId, Persistence persistence, Iterator<Map<String, Object>> smells,
                             String smellType, SmellDuplicationChecker duplicationChecker,
                             CommitQueries commitQueries, SmellQueries smellQueries); @Override void query();  }