@SuppressWarnings("ConstantConditions") public static void testDoGenerateForClass(final RandomGenerator randomGenerator,final Class<?> type){
  Affirm.affirmTrue(String.format("Failed to get the requested type=[%s] from [%s] received=[%s] instead",type,randomGenerator,randomGenerator.doGenerate(type)),type.isInstance(randomGenerator.doGenerate(type)));
  Object object=type.cast(randomGenerator.doGenerate(type));
  Affirm.affirmNotNull(String.format("Request to registered type [%s] must return non-null value!!",type),object);
  Object anotherObject=randomGenerator.doGenerate(type);
  if (object.equals(anotherObject)) {
    anotherObject=randomGenerator.doGenerate(type);
    if (object.equals(anotherObject) && type == Boolean.class) {
      for (int counter=0; counter < 20; counter++) {
        anotherObject=randomGenerator.doGenerate(type);
        if (!object.equals(anotherObject)) {
          break;
        }
      }
    }
  }
  Affirm.affirmFalse(String.format("[%s] generating the same values for type=[%s]",randomGenerator,type),object.equals(anotherObject));
}

@ SuppressWarnings ( "ConstantConditions" ) public static void testDoGenerateForClass ( final RandomGenerator randomGenerator , final Class < ? > type ) { Affirm . affirmTrue ( String . format ( "Failed to get the requested type=[%s] from [%s] received=[%s] instead" , type , randomGenerator , randomGenerator . doGenerate ( type ) ) , type . isInstance ( randomGenerator . doGenerate ( type ) ) ) ; Object object = type . cast ( randomGenerator . doGenerate ( type ) ) ; Affirm . affirmNotNull ( String . format ( "Request to registered type [%s] must return non-null value!!" , type ) , object ) ; Object anotherObject = randomGenerator . doGenerate ( type ) ; if ( object . equals ( anotherObject ) ) { anotherObject = randomGenerator . doGenerate ( type ) ; if ( object . equals ( anotherObject ) && type == Boolean . class ) { for ( int counter = 0 ; counter < 20 ; counter ++ ) { anotherObject = randomGenerator . doGenerate ( type ) ; if ( ! object . equals ( anotherObject ) ) { break ; } } } } Affirm . affirmFalse ( String . format ( "[%s] generating the same values for type=[%s]" , randomGenerator , type ) , object . equals ( anotherObject ) ) ; }
utility method to assist with testing all non - primitive classes .
