use of org.eclipse.nebula.widgets.nattable.dataset.generator.IValueGenerator in project nebula.widgets.nattable by eclipse.
the class DataValueGeneratorTest method testClassAnnotationDataCanBeAccessed.
// TODO The following test probably has a race condition - test
// non-deterministic
@Test
public void testClassAnnotationDataCanBeAccessed() throws Exception {
final Random random = new Random();
final PricingDataBean bean = new PricingDataBean();
for (Field field : bean.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(DataValueGenerator.class)) {
field.setAccessible(true);
try {
Class<? extends IValueGenerator> generatorClass = field.getAnnotation(DataValueGenerator.class).value();
IValueGenerator generator = generatorClass.newInstance();
Object newValue = generator.newValue(random);
// System.out.println("newValue: "+newValue + "\t" +
// generator.getClass().getName());
assertNotNull(newValue);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
Aggregations