@Override Iterable<FrameworkField> getAnnotatablesForTestClass(TestClass testClass) { return testClass.getAnnotatedFields(); }
protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) { List<FrameworkField> fields = clazz.getAnnotatedFields(DataPoint.class); Collection<Field> validFields = new ArrayList<Field>(); for (FrameworkField frameworkField : fields) { validFields.add(frameworkField.getField()); } return validFields; }
protected Collection<Field> getDataPointsFields(ParameterSignature sig) { List<FrameworkField> fields = clazz.getAnnotatedFields(DataPoints.class); Collection<Field> validFields = new ArrayList<Field>(); for (FrameworkField frameworkField : fields) { validFields.add(frameworkField.getField()); } return validFields; }
private List<FrameworkField> getAnnotatedFieldsByParameter() { return getTestClass().getAnnotatedFields(Parameter.class); }
private List<FrameworkField> getAnnotatedFieldsByParameter() { return getTestClass().getAnnotatedFields(Parameter.class); }
private List<FrameworkField> getAnnotatedFieldsByParameter() { return getTestClass().getAnnotatedFields(Parameter.class); }
private List<FrameworkField> getAnnotatedFieldsByParameter() { return getTestClass().getAnnotatedFields(Parameterized.Parameter.class); }
public <T> List<T> getAnnotatedFieldValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass) { List<T> results = new ArrayList<T>(); for (FrameworkField each : getAnnotatedFields(annotationClass)) { try { Object fieldValue = each.get(test); if (valueClass.isInstance(fieldValue)) { results.add(valueClass.cast(fieldValue)); } } catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); } } return results; }
/** * Finds the fields annotated with the specified annotation and having the specified type, * retrieves the values and passes those to the specified consumer. * * @since 4.13 */ public <T> void collectAnnotatedFieldValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass, MemberValueConsumer<T> consumer) { for (FrameworkField each : getAnnotatedFields(annotationClass)) { try { Object fieldValue = each.get(test); if (valueClass.isInstance(fieldValue)) { consumer.accept(each, valueClass.cast(fieldValue)); } } catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); } } }
/** * Validate the {@link org.junit.runners.model.TestClass} and adds reasons * for rejecting the class to a list of errors. * * @param target the {@code TestClass} to validate. * @param errors the list of errors. */ public void validate(TestClass target, List<Throwable> errors) { List<? extends FrameworkMember<?>> members = methods ? target.getAnnotatedMethods(annotation) : target.getAnnotatedFields(annotation); for (FrameworkMember<?> each : members) { validateMember(each, errors); } }
/** * Validate the {@link org.junit.runners.model.TestClass} and adds reasons * for rejecting the class to a list of errors. * * @param target the {@code TestClass} to validate. * @param errors the list of errors. */ public void validate(TestClass target, List<Throwable> errors) { List<? extends FrameworkMember<?>> members = fMethods ? target.getAnnotatedMethods(fAnnotation) : target.getAnnotatedFields(fAnnotation); for (FrameworkMember<?> each : members) { validateMember(each, errors); } }
private List<FrameworkField> getAnnotatedFieldsByParameter() { return getTestClass().getAnnotatedFields(Parameter.class); }
private List<FrameworkField> getAnnotatedFieldsByParameter() { return getTestClass().getAnnotatedFields(Parameter.class); }
private List<FrameworkField> getAnnotatedFieldsByParameter() { return getTestClass().getAnnotatedFields(Parameter.class); }
private List<FrameworkField> getAnnotatedFieldsByParameter() { return getTestClass().getAnnotatedFields(Parameter.class); }
public <T> List<T> getAnnotatedFieldValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass) { List<T> results = new ArrayList<T>(); for (FrameworkField each : getAnnotatedFields(annotationClass)) { try { Object fieldValue = each.get(test); if (valueClass.isInstance(fieldValue)) { results.add(valueClass.cast(fieldValue)); } } catch (IllegalAccessException e) { throw new RuntimeException( "How did getFields return a field we couldn't access?", e); } } return results; }
/** * Validate the {@link org.junit.runners.model.TestClass} and adds reasons * for rejecting the class to a list of errors. * * @param target the {@code TestClass} to validate. * @param errors the list of errors. */ public void validate(TestClass target, List<Throwable> errors) { List<? extends FrameworkMember<?>> members = fMethods ? target.getAnnotatedMethods(fAnnotation) : target.getAnnotatedFields(fAnnotation); for (FrameworkMember<?> each : members) { validateMember(each, errors); } }
this.superDescription = superDescription; this.features = features; List<FrameworkField> testerFields = testClass.get().getAnnotatedFields(Shared.class); if (testerFields.isEmpty()) { throw new InitializationError("No public @Shared field found");
public JpaUnitRunner(final Class<?> clazz) throws InitializationError { super(clazz); executor = new DecoratorExecutor(); final List<FrameworkField> ruleFields = getTestClass().getAnnotatedFields(Rule.class); if (ruleFields.stream().anyMatch(f -> f.getType().equals(JpaUnitRule.class))) { throw new InitializationError("JpaUnitRunner and JpaUnitRule exclude each other"); } }
private static Set<Field> getTestFactoryFields(TestClass testClass, TestEntityManagerFactory.Scope scope) { Set<Field> testFactoryFields = new HashSet<Field>(); for ( FrameworkField frameworkField : testClass.getAnnotatedFields( TestEntityManagerFactory.class ) ) { Field field = frameworkField.getField(); if ( scope == field.getAnnotation( TestEntityManagerFactory.class ).scope() ) { field.setAccessible( true ); testFactoryFields.add( field ); } } return testFactoryFields; }