public void runCoordinatedOperation(Procedure spy, AcquireBarrierAnswer prepareOperation,
    BarrierAnswer commitOperation, String... cohort) throws Exception {
    List<String> expected = Arrays.asList(cohort);
    when(coordinator.createProcedure(any(), eq(procName), eq(procData), anyList())).thenReturn(spy);

    // use the passed controller responses
    doAnswer(prepareOperation).when(controller).sendGlobalBarrierAcquire(spy, procData, expected);
    doAnswer(commitOperation).when(controller).sendGlobalBarrierReached(eq(spy), anyList());

    // run the operation
    Procedure task =
      coordinator.startProcedure(spy.getErrorMonitor(), procName, procData, expected);
    // and wait for it to finish
    task.waitForCompleted();

    // make sure we mocked correctly
    prepareOperation.ensureRan();
    // we never got an exception
    InOrder inorder = inOrder(spy, controller);
    inorder.verify(spy).sendGlobalBarrierStart();
    inorder.verify(controller).sendGlobalBarrierAcquire(task, procData, expected);
    inorder.verify(spy).sendGlobalBarrierReached();
    inorder.verify(controller).sendGlobalBarrierReached(eq(task), anyList());
  }
Just run a procedure with the standard name and data, with not special task for the mock
coordinator (it works just like a regular coordinator). For custom behavior see
{@link #runCoordinatedOperation(Procedure, AcquireBarrierAnswer, BarrierAnswer, String[])} .
@param spy    Spy on a real {@link Procedure}
@param cohort expected cohort members
@throws Exception on failure
hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestProcedureCoordinator.java