@Test
void matchingGroupPathAreBlocked()
{

    GroupedJobInitializer groupedJobInitializer = mock(GroupedJobInitializer.class);
    when(groupedJobInitializer.getPoolSize()).thenReturn(1);
    when(groupedJobInitializer.getDefaultPriority()).thenReturn(Thread.NORM_PRIORITY);
    when(this.groupedJobInitializerManager.getGroupedJobInitializer(any())).thenReturn(groupedJobInitializer);
    TestBasicGroupedJob jobA = groupedJob("A");
    TestBasicGroupedJob jobAB = groupedJob("A", "B");
    TestBasicGroupedJob job12 = groupedJob("1", "2");
    TestBasicGroupedJob job1 = groupedJob("1");
    // Pre-lock all jobs
    jobA.lock();
    jobAB.lock();
    job12.lock();
    job1.lock();
    // Give first jobs to JobExecutor
    this.executor.execute(jobA);
    this.executor.execute(job12);
    // Give enough time for the jobs to be fully taken into account
    waitJobWaiting(jobA);
    waitJobWaiting(job12);
    // Give following jobs to JobExecutor (to make sure they are actually after since the grouped job executor queue
    // is not "fair")
    this.executor.execute(jobAB);
    this.executor.execute(job1);
    ////////////////////
    // A and A/B
    assertSame(State.WAITING, jobA.getStatus().getState());
    assertNull(jobAB.getStatus().getState());
    // Next job
    jobA.unlock();
    waitJobWaiting(jobAB);
    assertSame(State.FINISHED, jobA.getStatus().getState());
    assertSame(State.WAITING, jobAB.getStatus().getState());
    // Next job
    jobAB.unlock();
    waitJobFinished(jobAB);
    assertSame(State.FINISHED, jobA.getStatus().getState());
    assertSame(State.FINISHED, jobAB.getStatus().getState());
    ////////////////////
    // 1/2 and 1
    assertSame(State.WAITING, job12.getStatus().getState());
    assertNull(job1.getStatus().getState());
    // Next job
    job12.unlock();
    waitJobWaiting(job1);
    assertSame(State.FINISHED, job12.getStatus().getState());
    assertSame(State.WAITING, job1.getStatus().getState());
    // Next job
    job1.unlock();
    waitJobFinished(job1);
    assertSame(State.FINISHED, job1.getStatus().getState());
    assertSame(State.FINISHED, job1.getStatus().getState());
}