@Test
public void handleCommitGap() throws QueryException {

    addSmell(firstCommit, firstSmell);
    addSmell(firstCommit, secondSmell);
    addSmell(thirdCommit, secondSmell);
    String gapCommitSha = "someSha";
    mockGapCommit(gapCommitSha);
    mockEndCommit(thirdCommit.sha);
    getAnalysis().query();
    debugSmellInsertions();
    verify(persistence, times(3)).execute(any());
    verify(smellQueries).smellInsertionStatement(projectId, firstSmell);
    verify(smellQueries, times(2)).smellInsertionStatement(projectId, secondSmell);
    verify(persistence, times(8)).addStatements(any());
    verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.PRESENCE);
    verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, firstSmell, SmellCategory.INTRODUCTION);
    // The 1st and 3rd commits will insert the secondSmell since 3rd has no idea it existed.
    verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, secondSmell, SmellCategory.PRESENCE);
    verify(smellQueries).smellCategoryInsertionStatement(projectId, firstCommit.sha, secondSmell, SmellCategory.INTRODUCTION);
    // The missing Ordinal 1 will be replaced by an empty commit
    verify(smellQueries).smellCategoryInsertionStatement(projectId, gapCommitSha, firstSmell, SmellCategory.REFACTOR);
    verify(smellQueries).smellCategoryInsertionStatement(projectId, gapCommitSha, secondSmell, SmellCategory.REFACTOR);
    // 3rd commit is counted as introducing the commit back.
    verify(smellQueries).smellCategoryInsertionStatement(projectId, thirdCommit.sha, secondSmell, SmellCategory.PRESENCE);
    verify(smellQueries).smellCategoryInsertionStatement(projectId, thirdCommit.sha, secondSmell, SmellCategory.INTRODUCTION);
}