private Object invokeWithError(InvocationOnMock invocation, boolean errorBeforeUpdate)
      throws Throwable {
      if (errorBeforeUpdate) {
        throw new ReplicationException("mock error before update");
      }
      invocation.callRealMethod();
      throw new ReplicationException("mock error after update");
    }
All the modification method will fail once in the test and should finally succeed.
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationProcedureRetry.java