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 ( ) ; } }
Mock exception happens by period