@Test
public void testBranchInsertionStatement() {

    long count = 0;
    // We can call on not persisted commits.
    // Warning: This will return null for both commit, which should be limited to the master branch
    Commit notPersistedOriginCommit = generateCommit("origin", 0);
    Commit notPersistedMergedCommit = generateCommit("merged", 42);
    executeSuccess(queries.branchInsertionStatement(projectId, 9,
            notPersistedOriginCommit, notPersistedMergedCommit));
    assertEquals(++count, getBranchCount());
    // We can insert any branch
    Commit anotherCommit = prepareCommit("another", 4);
    executeSuccess(queries.branchInsertionStatement(projectId, 0, originCommit, mergedIntoCommit));
    assertEquals(++count, getBranchCount());
    // We can insert another branch ordinal
    executeSuccess(queries.branchInsertionStatement(projectId, 1, originCommit, mergedIntoCommit));
    assertEquals(++count, getBranchCount());
    executeSuccess(queries.branchInsertionStatement(projectId, 2, anotherCommit, mergedIntoCommit));
    assertEquals(++count, getBranchCount());
    executeSuccess(queries.branchInsertionStatement(projectId, 3, mergedIntoCommit, anotherCommit));
    assertEquals(++count, getBranchCount());
    // We can insert the same branch ordinal in another project
    int secondProjectID = createProject("anotherProject", projectQueries);
    executeSuccess(queries.branchInsertionStatement(secondProjectID, 0, originCommit, mergedIntoCommit));
    assertEquals(++count, getBranchCount());
    // We don't insert the same ordinal, whichever the commit
    executeNothinhDone(queries.branchInsertionStatement(projectId, 0, originCommit, mergedIntoCommit));
    assertEquals(count, getBranchCount());
    executeNothinhDone(queries.branchInsertionStatement(projectId, 0, anotherCommit, mergedIntoCommit));
    assertEquals(count, getBranchCount());
    executeNothinhDone(queries.branchInsertionStatement(projectId, 0, mergedIntoCommit, anotherCommit));
    assertEquals(count, getBranchCount());
}