code: public static <E extends Exception> void period(Object key, int period, Supplier<E> exceptionFactory) throws E {
      int index = cache(MockException.class, key, () -> 0) + 1;
      set(MockException.class, key, index);
      if (index % period == 0) {
        throw exceptionFactory.get();
      }
    }
docs: Mock exception happens by period
  
  @param key the unique key to decide these invocation are grouped
  @param period how many invocations will occur an exception
  @param exceptionFactory exception to throw
  @throws E exception type