BranchAwareSmellTypeAnalysis implements Query { @Override public void query() throws QueryException { Smell smell; Commit previousCommit; Commit commit = Commit.empty(); Integer previousBranch; Integer currentBranch = -1; Map<String, Object> instance; while (smells.hasNext()) { instance = smells.next(); previousCommit = commit; previousBranch = currentBranch; commit = Commit.fromInstance(instance); smell = Smell.fromPaprikaInstance(instance, smellType); try { currentBranch = fetchCommitBranch(commit); } catch (BranchNotFoundException e) { logger.warn("[" + projectId + "] ==> Unable to guess branch for commit (" + commit.sha + "), skipping", e.getMessage()); continue; } if (!branchAnalyzers.containsKey(currentBranch)) { logger.debug("[" + projectId + "] => Initializing new branch: " + currentBranch); initializeBranch(currentBranch); } commit.setBranchOrdinal(fetchCommitOrdinal(currentBranch, commit)); branchAnalyzers.get(currentBranch).notifyCommit(commit); if (!previousCommit.equals(commit)) { synchronizeMergeSmells(commit, currentBranch); } branchAnalyzers.get(currentBranch).notifySmell(smell); if (!previousCommit.equals(commit) && isLastBranchCommit(previousCommit, previousBranch)) { finalizeBranch(previousBranch); branchAnalyzers.remove(previousBranch); } } for (int branchId : branchAnalyzers.keySet()) { finalizeBranch(branchId); } } BranchAwareSmellTypeAnalysis(int projectId, Persistence persistence, Iterator<Map<String, Object>> smells,
                                 String smellType, SmellDuplicationChecker duplicationChecker,
                                 CommitQueries commitQueries, SmellQueries smellQueries, BranchQueries branchQueries); @Override void query();  }
@Test(expected = QueryException.class) public void testNoEndCommitFoundWillThrow() throws QueryException { addSmell(firstCommit, firstSmell); mockCommitBranch(firstCommit, 0, 0); mockNoEndCommit(); getAnalysis().query(); }
@Test public void testHandlePresenceAndIntroductionOnSingleCommitAlsoLastCommit() throws QueryException { addSmell(firstCommit, firstSmell); mockCommitBranch(firstCommit, 0, 0); mockLastBranchCommit(0, firstCommit); getAnalysis().query(); verify(persistence, times(1)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(persistence, times(2)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION); }
@Test public void testHandlePresenceAndIntroductionOnSingleCommitNotLastCommit() throws QueryException { addSmell(firstCommit, firstSmell); String lastCommitSha = "another"; mockCommitBranch(firstCommit, 0, 0); mockGapCommit(lastCommitSha, 0, 1); mockLastBranchCommit(0, lastCommitSha); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(1)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(persistence, times(3)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, lastCommitSha, firstSmell, SmellCategory.REFACTOR); }
@Test public void testHandleIntroductionAndRefactoring() throws QueryException { addSmell(firstCommit, firstSmell); addSmell(secondCommit, secondSmell); mockCommitBranch(firstCommit, 0, 0); mockCommitBranch(secondCommit, 0, 1); mockLastBranchCommit(0, secondCommit); getAnalysis().query(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(persistence, times(5)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, firstSmell, SmellCategory.REFACTOR); }
@Test public void testHandleIntroductionOnly() throws QueryException { addSmell(firstCommit, firstSmell); addSmell(secondCommit, firstSmell); addSmell(secondCommit, secondSmell); mockCommitBranch(firstCommit, 0, 0); mockCommitBranch(secondCommit, 0, 1); mockLastBranchCommit(0, secondCommit); getAnalysis().query(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(persistence, times(5)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, secondSmell, SmellCategory.INTRODUCTION); }
@Test public void testHandleRefactorOnly() throws QueryException { addSmell(firstCommit, firstSmell); addSmell(firstCommit, secondSmell); addSmell(secondCommit, firstSmell); mockCommitBranch(firstCommit, 0, 0); mockCommitBranch(secondCommit, 0, 1); mockLastBranchCommit(0, secondCommit); getAnalysis().query(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(persistence, times(6)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, secondSmell, SmellCategory.REFACTOR); }
@Test public void testHandleNoChange() throws QueryException { addSmell(firstCommit, firstSmell); addSmell(secondCommit, firstSmell); mockCommitBranch(firstCommit, 0, 0); mockCommitBranch(secondCommit, 0, 1); mockLastBranchCommit(0, secondCommit); getAnalysis().query(); verify(persistence, times(1)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(persistence, times(3)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, firstSmell, SmellCategory.PRESENCE); }
@Test public void testHandleCommitGap() throws QueryException { Commit someCommit = new Commit("A", 57); Commit anotherCommit = new Commit("B", 60); mockCommitSmells(someCommit, firstSmell, secondSmell); mockCommitSmells(anotherCommit, secondSmell); mockCommitBranch(someCommit, 0, 0); mockCommitBranch(anotherCommit, 0, 2); mockLastBranchCommit(0, anotherCommit.sha); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(persistence, times(6)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, someCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, someCommit.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, someCommit.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, someCommit.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, anotherCommit.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).lostSmellCategoryInsertionStatement(projectId, firstSmell, SmellCategory.REFACTOR, someCommit.ordinal + 1, anotherCommit.ordinal); }
@Test public void testHandleRenamedSmell() throws QueryException { ArgumentCaptor<Smell> smellCaptor = ArgumentCaptor.forClass(Smell.class); addSmell(firstCommit, firstSmell); addSmell(secondCommit, secondSmell); mockCommitBranch(firstCommit, 0, 0); mockCommitBranch(secondCommit, 0, 1); Smell expectedSecondSmell = mockSmellRenamed(secondCommit, secondSmell, firstSmell); mockSmellId(expectedSecondSmell); mockLastBranchCommit(0, secondCommit.sha); getAnalysis().query(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries, times(2)).smellInsertionStatement(eq(projectId), smellCaptor.capture()); Smell renamed = smellCaptor.getAllValues().get(1); assertEquals(expectedSecondSmell, renamed); assertEquals(firstSmell, renamed.parent); verify(persistence, times(3)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, expectedSecondSmell, SmellCategory.PRESENCE); }
@Test public void testHandleRenamedSmellMultipleCommits() throws QueryException { ArgumentCaptor<Smell> smellCaptor = ArgumentCaptor.forClass(Smell.class); addSmell(firstCommit, firstSmell); addSmell(secondCommit, secondSmell); addSmell(thirdCommit, secondSmell); mockCommitBranch(firstCommit, 0, 0); mockCommitBranch(secondCommit, 0, 1); mockCommitBranch(thirdCommit, 0, 2); Smell expectedSecondSmell = mockSmellRenamed(secondCommit, secondSmell, firstSmell); mockSmellId(expectedSecondSmell); mockSmellRenamed(thirdCommit, secondSmell, firstSmell); mockLastBranchCommit(0, thirdCommit.sha); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries, times(2)).smellInsertionStatement(eq(projectId), smellCaptor.capture()); Smell renamed = smellCaptor.getAllValues().get(1); assertEquals(expectedSecondSmell, renamed); assertEquals(firstSmell, renamed.parent); verify(persistence, times(4)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, secondCommit.sha, expectedSecondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, thirdCommit.sha, expectedSecondSmell, SmellCategory.PRESENCE); }
@Test public void handleFirstCommitIsNotTheFirstOrdinal() throws QueryException { addSmell(thirdCommit, firstSmell); mockCommitBranch(thirdCommit, 0, 1); mockGapCommit(firstCommit.sha, 0, 0); mockLastBranchCommit(0, thirdCommit.sha); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(1)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(persistence, times(2)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, thirdCommit.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, thirdCommit.sha, firstSmell, SmellCategory.INTRODUCTION); }
@Test public void testAnotherBranchSeparateSmells() throws QueryException { Commit A0 = new Commit("0-A", 0); Commit B0 = new Commit("0-B", 1); Commit C0 = new Commit("0-C", 5); Commit A1 = new Commit("1-A", 2); Commit B1 = new Commit("1-B", 3); Commit C1 = new Commit("1-C", 4); mockCommitSmells(A0, thirdSmell); mockCommitSmells(B0, firstSmell); mockCommitSmells(A1, secondSmell, thirdSmell); mockCommitSmells(B1, secondSmell, thirdSmell); mockCommitSmells(C1, secondSmell, thirdSmell); mockCommitSmells(C0, firstSmell, secondSmell, thirdSmell); mockCommitBranch(A0, 0, 0); mockCommitBranch(B0, 0, 1); mockCommitBranch(C0, 0, 2); mockLastBranchCommit(0, C0); mockCommitBranch(A1, 1, 0); mockCommitBranch(B1, 1, 1); mockCommitBranch(C1, 1, 2); mockLastBranchCommit(1, C1); mockMergeCommit(C0, C1); mockBranchParentCommitSmells(1, thirdSmell); getAnalysis().query(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(persistence, times(15)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, A0.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A0.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, B0.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B0.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, B0.sha, thirdSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, A1.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A1.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, A1.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B1.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B1.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C1.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C1.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C0.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C0.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C0.sha, thirdSmell, SmellCategory.PRESENCE); }
@Test public void testSuccessiveBranchesSeparateSmells() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("0-B", 1); Commit C = new Commit("0-C", 3); Commit D = new Commit("1-D", 2); Commit E = new Commit("1-E", 4); Commit F = new Commit("0-F", 5); Commit G = new Commit("2-G", 6); Commit H = new Commit("0-H", 7); Commit I = new Commit("0-I", 8); mockCommitSmells(A, firstSmell); mockCommitSmells(B, firstSmell); mockCommitSmells(D, firstSmell); mockCommitSmells(C, firstSmell); mockCommitSmells(E, firstSmell, secondSmell); mockCommitSmells(F, firstSmell, secondSmell); mockCommitSmells(G, firstSmell); mockCommitSmells(H, firstSmell, secondSmell, thirdSmell); mockCommitSmells(I, firstSmell, thirdSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 0, 1); mockCommitBranch(C, 0, 2); mockCommitBranch(D, 1, 0); mockCommitBranch(E, 1, 1); mockCommitBranch(F, 0, 3); mockCommitBranch(G, 2, 0); mockCommitBranch(H, 0, 4); mockCommitBranch(I, 0, 5); mockLastBranchCommit(0, I); mockLastBranchCommit(1, E); mockLastBranchCommit(2, G); mockMergeCommit(F, E); mockMergeCommit(I, G); mockBranchParentCommitSmells(1, firstSmell); mockBranchParentCommitSmells(2, firstSmell, secondSmell); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(persistence, times(18)).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, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, secondSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, thirdSmell, SmellCategory.PRESENCE); }
@Test public void testContinuingBranchesSeparateSmells() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("0-B", 1); Commit C = new Commit("0-C", 3); Commit D = new Commit("1-D", 2); Commit E = new Commit("1-E", 4); Commit F = new Commit("0-F", 5); Commit G = new Commit("1-G", 6); Commit H = new Commit("0-H", 7); Commit I = new Commit("0-I", 8); mockCommitSmells(A, firstSmell); mockCommitSmells(B, firstSmell); mockCommitSmells(D, firstSmell); mockCommitSmells(C, firstSmell); mockCommitSmells(E, firstSmell, secondSmell); mockCommitSmells(F, firstSmell, thirdSmell); mockCommitSmells(G, firstSmell, secondSmell); mockCommitSmells(H, firstSmell, thirdSmell); mockCommitSmells(I, firstSmell, thirdSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 0, 1); mockCommitBranch(C, 0, 2); mockCommitBranch(D, 1, 0); mockCommitBranch(E, 1, 1); mockCommitBranch(F, 0, 3); mockCommitBranch(G, 1, 2); mockCommitBranch(H, 0, 4); mockCommitBranch(I, 0, 5); mockLastBranchCommit(0, I); mockLastBranchCommit(1, G); mockMergeCommit(I, G); mockBranchParentCommitSmells(1, firstSmell); getAnalysis().query(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(persistence, times(17)).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, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, thirdSmell, SmellCategory.PRESENCE); }
@Test public void testOverlappingBranchesSeparateSmells() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("0-B", 1); Commit C = new Commit("0-C", 3); Commit D = new Commit("1-D", 2); Commit E = new Commit("2-E", 4); Commit F = new Commit("1-F", 5); Commit G = new Commit("1-G", 6); Commit H = new Commit("0-H", 7); Commit I = new Commit("0-I", 8); mockCommitSmells(A, firstSmell); mockCommitSmells(B, firstSmell); mockCommitSmells(D, firstSmell); mockCommitSmells(C, firstSmell); mockCommitSmells(E, firstSmell, secondSmell); mockCommitSmells(F, firstSmell, thirdSmell); mockCommitSmells(G, firstSmell, secondSmell, thirdSmell); mockCommitSmells(I, secondSmell, thirdSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 0, 1); mockCommitBranch(C, 0, 2); mockCommitBranch(D, 1, 0); mockCommitBranch(E, 2, 0); mockCommitBranch(F, 1, 1); mockCommitBranch(G, 1, 2); mockCommitBranch(H, 0, 3); mockCommitBranch(I, 0, 4); mockLastBranchCommit(0, I); mockLastBranchCommit(1, G); mockLastBranchCommit(2, E); mockMergeCommit(I, G); mockMergeCommit(G, E); mockBranchParentCommitSmells(1, firstSmell); mockBranchParentCommitSmells(2, firstSmell); getAnalysis().query(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(persistence, times(17)).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, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, firstSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, thirdSmell, SmellCategory.PRESENCE); }
@Test public void testParallelBranchesSeparateSmells() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("0-B", 1); Commit C = new Commit("0-C", 3); Commit D = new Commit("1-D", 2); Commit E = new Commit("2-E", 4); Commit F = new Commit("1-F", 5); Commit G = new Commit("1-G", 6); Commit H = new Commit("0-H", 7); Commit I = new Commit("0-I", 8); mockCommitSmells(A, firstSmell); mockCommitSmells(B, firstSmell); mockCommitSmells(D, firstSmell, secondSmell); mockCommitSmells(C, firstSmell); mockCommitSmells(E, firstSmell, thirdSmell); mockCommitSmells(F, firstSmell, secondSmell); mockCommitSmells(G, firstSmell, secondSmell); mockCommitSmells(H, firstSmell, thirdSmell); mockCommitSmells(I, firstSmell, secondSmell, thirdSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 0, 1); mockCommitBranch(C, 0, 2); mockCommitBranch(D, 1, 0); mockCommitBranch(E, 2, 0); mockCommitBranch(F, 1, 1); mockCommitBranch(G, 1, 2); mockCommitBranch(H, 0, 3); mockCommitBranch(I, 0, 4); mockLastBranchCommit(0, I); mockLastBranchCommit(1, G); mockLastBranchCommit(2, E); mockMergeCommit(I, G); mockMergeCommit(H, E); mockBranchParentCommitSmells(1, firstSmell); mockBranchParentCommitSmells(2, firstSmell); getAnalysis().query(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(persistence, times(19)).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, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, thirdSmell, SmellCategory.PRESENCE); }
@Test public void testCrossedBranchesSeparateSmells() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("0-B", 1); Commit C = new Commit("0-C", 3); Commit D = new Commit("2-D", 2); Commit E = new Commit("1-E", 4); Commit F = new Commit("0-F", 5); Commit G = new Commit("1-G", 6); Commit H = new Commit("0-H", 7); mockCommitSmells(A, firstSmell); mockCommitSmells(B, firstSmell); mockCommitSmells(D, firstSmell, secondSmell); mockCommitSmells(C, firstSmell); mockCommitSmells(E, firstSmell); mockCommitSmells(F, firstSmell, secondSmell); mockCommitSmells(G, firstSmell); mockCommitSmells(H, firstSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 0, 1); mockCommitBranch(C, 0, 2); mockCommitBranch(D, 2, 0); mockCommitBranch(E, 1, 0); mockCommitBranch(F, 0, 3); mockCommitBranch(G, 1, 1); mockCommitBranch(H, 0, 4); mockLastBranchCommit(0, H); mockLastBranchCommit(1, G); mockLastBranchCommit(2, D); mockMergeCommit(H, G); mockMergeCommit(F, D); mockBranchParentCommitSmells(1, firstSmell); mockBranchParentCommitSmells(2, firstSmell); getAnalysis().query(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(persistence, times(12)).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, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, firstSmell, SmellCategory.PRESENCE); }
@Test public void testMergeBackAndForthBranchesSeparateSmells() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("0-B", 1); Commit C = new Commit("0-C", 3); Commit D = new Commit("1-D", 2); Commit E = new Commit("1-E", 4); Commit F = new Commit("0-F", 5); Commit G = new Commit("1-G", 6); Commit H = new Commit("0-H", 7); Commit I = new Commit("0-I", 8); mockCommitSmells(B, firstSmell); mockCommitSmells(D, secondSmell); mockCommitSmells(C, firstSmell); mockCommitSmells(E, firstSmell, secondSmell); mockCommitSmells(F, firstSmell, thirdSmell); mockCommitSmells(G, firstSmell, secondSmell); mockCommitSmells(H, firstSmell, thirdSmell); mockCommitSmells(I, firstSmell, secondSmell, thirdSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 0, 1); mockCommitBranch(C, 0, 2); mockCommitBranch(D, 1, 0); mockCommitBranch(E, 1, 1); mockCommitBranch(F, 0, 3); mockCommitBranch(G, 1, 2); mockCommitBranch(H, 0, 4); mockCommitBranch(I, 0, 5); mockLastBranchCommit(0, I); mockLastBranchCommit(1, G); mockMergeCommit(I, G); mockMergeCommit(E, C); mockBranchParentCommitSmells(1, Collections.emptyList()); getAnalysis().query(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(persistence, times(17)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, thirdSmell, SmellCategory.PRESENCE); }
@Test public void testMergeNotInDirectParentBranchesSeparateSmells() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("0-B", 1); Commit C = new Commit("0-C", 3); Commit D = new Commit("1-D", 2); Commit E = new Commit("2-E", 4); Commit F = new Commit("1-F", 5); Commit G = new Commit("0-G", 6); Commit H = new Commit("1-H", 7); Commit I = new Commit("0-I", 8); mockCommitSmells(A, firstSmell); mockCommitSmells(D, firstSmell, secondSmell); mockCommitSmells(E, secondSmell); mockCommitSmells(F, firstSmell, secondSmell); mockCommitSmells(G, secondSmell); mockCommitSmells(H, firstSmell, secondSmell, thirdSmell); mockCommitSmells(I, secondSmell, thirdSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 0, 1); mockCommitBranch(C, 0, 2); mockCommitBranch(D, 1, 0); mockCommitBranch(E, 2, 0); mockCommitBranch(F, 1, 1); mockCommitBranch(G, 0, 3); mockCommitBranch(H, 1, 2); mockCommitBranch(I, 0, 4); mockLastBranchCommit(0, I); mockLastBranchCommit(1, H); mockLastBranchCommit(2, E); mockMergeCommit(I, H); mockMergeCommit(G, E); mockBranchParentCommitSmells(1, firstSmell); mockBranchParentCommitSmells(2, firstSmell, secondSmell); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(persistence, times(17)).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, firstSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, H.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, I.sha, thirdSmell, SmellCategory.PRESENCE); }
@Test public void testMergeIsLastBranchCommitBranchesSeparateSmells() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("1-B", 1); Commit C = new Commit("3-C", 2); Commit D = new Commit("2-D", 3); Commit E = new Commit("1-E", 4); Commit F = new Commit("0-F", 5); mockCommitSmells(A, firstSmell, secondSmell); mockCommitSmells(B, firstSmell); mockCommitSmells(C, firstSmell, thirdSmell); mockCommitSmells(D, firstSmell, thirdSmell); mockCommitSmells(E, firstSmell, thirdSmell); mockCommitSmells(F, firstSmell, thirdSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 1, 0); mockCommitBranch(C, 3, 0); mockCommitBranch(D, 2, 0); mockCommitBranch(E, 1, 1); mockCommitBranch(F, 0, 1); mockLastBranchCommit(0, F); mockLastBranchCommit(1, E); mockLastBranchCommit(2, D); mockLastBranchCommit(3, C); mockMergeCommit(F, E); mockMergeCommit(E, D); mockMergeCommit(D, C); mockBranchParentCommitSmells(1, firstSmell, secondSmell); mockBranchParentCommitSmells(2, firstSmell); mockBranchParentCommitSmells(3, firstSmell); getAnalysis().query(); verify(persistence, times(3)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(persistence, times(15)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, secondSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, thirdSmell, SmellCategory.PRESENCE); }
@Test public void testMultipleMergeOnSameBranch() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("1-B", 1); Commit C = new Commit("0-C", 2); Commit D = new Commit("0-D", 3); Commit E = new Commit("1-E", 4); Commit F = new Commit("0-F", 5); mockCommitSmells(A, firstSmell); mockCommitSmells(B, firstSmell, secondSmell); mockCommitSmells(C, firstSmell); mockCommitSmells(D, firstSmell, secondSmell); mockCommitSmells(E, firstSmell, secondSmell); mockCommitSmells(F, firstSmell, secondSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 1, 0); mockCommitBranch(C, 0, 1); mockCommitBranch(D, 0, 2); mockCommitBranch(E, 1, 1); mockCommitBranch(F, 0, 3); mockLastBranchCommit(0, F); mockLastBranchCommit(1, E); mockMergeCommit(F, E); mockMergeCommit(D, B); mockBranchParentCommitSmells(1, firstSmell); getAnalysis().query(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(persistence, times(12)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, secondSmell, SmellCategory.PRESENCE); }
@Test public void testMergeBackAndForthRefactoring() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("1-B", 1); Commit C = new Commit("0-C", 2); Commit D = new Commit("1-D", 3); Commit E = new Commit("0-E", 4); Commit F = new Commit("1-F", 5); Commit G = new Commit("0-G", 6); mockCommitSmells(A, firstSmell, secondSmell); mockCommitSmells(B, firstSmell, secondSmell); mockCommitSmells(C, firstSmell); mockCommitSmells(D, firstSmell); mockCommitSmells(E, firstSmell); mockCommitSmells(F, firstSmell); mockCommitSmells(G, firstSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 1, 0); mockCommitBranch(C, 0, 1); mockCommitBranch(D, 1, 1); mockCommitBranch(E, 0, 2); mockCommitBranch(F, 1, 2); mockCommitBranch(G, 0, 3); mockLastBranchCommit(0, G); mockLastBranchCommit(1, F); mockMergeCommit(G, F); mockMergeCommit(F, E); mockMergeCommit(D, C); mockBranchParentCommitSmells(1, Arrays.asList(secondSmell, firstSmell)); getAnalysis().query(); debugSmellInsertions(); verify(persistence, times(2)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(persistence, times(12)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, secondSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, D.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, E.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, F.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, G.sha, firstSmell, SmellCategory.PRESENCE); }
@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); mockCommitSmells(A, firstSmell); mockCommitSmells(B, secondSmell); mockCommitSmells(C, secondSmell); mockCommitSmells(D, firstSmell); mockCommitSmells(E, firstSmell); mockCommitSmells(F, firstSmell); mockCommitSmells(G, firstSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 0, 1); mockCommitBranch(C, 0, 2); mockCommitBranch(D, 0, 3); mockCommitBranch(E, 0, 4); mockCommitBranch(F, 0, 5); mockCommitBranch(G, 0, 6); mockLastBranchCommit(0, G); 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); }
@Test public void testMergeCommitRefactorAndIntroduces() throws QueryException { Commit A = new Commit("0-A", 0); Commit B = new Commit("1-B", 1); Commit C = new Commit("0-C", 2); Smell fourthSmell = new Smell(smellType, "fourthSmellInstance", "fourthSmellFile"); mockSmellId(fourthSmell); mockCommitSmells(A, firstSmell, secondSmell); mockCommitSmells(B, firstSmell, thirdSmell); mockCommitSmells(C, thirdSmell, fourthSmell); mockCommitBranch(A, 0, 0); mockCommitBranch(B, 1, 0); mockCommitBranch(C, 0, 1); mockLastBranchCommit(0, C); mockLastBranchCommit(1, B); mockMergeCommit(C, B); mockBranchParentCommitSmells(1, firstSmell, secondSmell); getAnalysis().query(); verify(persistence, times(4)).execute(any()); verify(smellQueries).smellInsertionStatement(projectId, firstSmell); verify(smellQueries).smellInsertionStatement(projectId, secondSmell); verify(smellQueries).smellInsertionStatement(projectId, thirdSmell); verify(smellQueries).smellInsertionStatement(projectId, fourthSmell); verify(persistence, times(12)).addStatements(any()); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, firstSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, secondSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, A.sha, secondSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, firstSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, secondSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, B.sha, thirdSmell, SmellCategory.INTRODUCTION); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, firstSmell, SmellCategory.REFACTOR); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, thirdSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, fourthSmell, SmellCategory.PRESENCE); verify(smellQueries).smellCategoryInsertionStatement(projectId, C.sha, fourthSmell, SmellCategory.INTRODUCTION); }