Beispiel #1
0
 protected static void fillObject(boolean isRandom, ITuple tuple, Field field, int index) {
   Object instance = ReflectionUtils.newInstance(field.getObjectClass(), null);
   if (instance instanceof A) {
     A a = (A) instance;
     a.setId(isRandom ? random.nextInt() + "" : "");
     a.setUrl(isRandom ? random.nextLong() + "" : "");
   }
   tuple.set(index, instance);
 }
 /**
  * Creates a random sort criteria based in the specified schema.
  *
  * @throws TupleMRException
  */
 protected static OrderBy createRandomSortCriteria(Schema schema, int numFields)
     throws TupleMRException {
   List<SortElement> builder = new ArrayList<SortElement>();
   for (int i = 0; i < numFields; i++) {
     Field field = schema.getField(i);
     if (random.nextBoolean()) {
       // With custom comparator
       builder.add(
           new SortElement(
               field.getName(),
               random.nextBoolean() ? Order.ASC : Order.DESC,
               new ReverseEqualsComparator(field.getType(), field.getObjectClass())));
     } else {
       // Without custom comparator
       builder.add(
           new SortElement(field.getName(), random.nextBoolean() ? Order.ASC : Order.DESC));
     }
   }
   return new OrderBy(builder);
 }
Beispiel #3
0
 protected static void fillEnum(boolean isRandom, Field field, ITuple tuple, int index)
     throws Exception {
   Method method = field.getObjectClass().getMethod("values", (Class[]) null);
   Enum[] values = (Enum[]) method.invoke(null);
   tuple.set(index, values[isRandom ? random.nextInt(values.length) : 0]);
 }