    @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);

        // This means that the firstSmell instance has been renamed to second smell in the secondCommit
        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);
        // We introduce the new smell instance definition with renamed_from filled in.
        // Since we use a captor we have to check all invocations of smellInsertionStatement...
        verify(smellQueries, times(2)).smellInsertionStatement(eq(projectId), smellCaptor.capture());
        // Check that the renamed commit has a set parent
        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);
    }