@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);
    // This define the input order
    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());
    // Initial branch
    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);
    // Branch
    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);
    // Merge
    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);
}