@Test
public void handleRenamedSmell() throws QueryException {

    ArgumentCaptor<Smell> smellCaptor = ArgumentCaptor.forClass(Smell.class);
    addSmell(firstCommit, firstSmell);
    addSmell(secondCommit, secondSmell);
    // This means that the firstSmell instance has been renamed to second smell in the secondCommit
    Smell expectedSecondSmell = mockSmellRenamed(secondCommit, secondSmell, firstSmell);
    mockSmellId(expectedSecondSmell);
    mockEndCommit(secondCommit.sha);
    getAnalysis().query();
    debugSmellInsertions();
    verify(persistence, times(2)).execute(any());
    verify(smellQueries).smellInsertionStatement(projectId, firstSmell);
    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(3)).addStatements(any());
    verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE);
    verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION);
    // 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).smellCategoryInsertionStatement(projectId, secondCommit.sha, expectedSecondSmell, SmellCategory.PRESENCE);
}