private ParameterSupplier getSupplier(ParameterSignature unassigned) throws Exception { ParametersSuppliedBy annotation = unassigned .findDeepAnnotation(ParametersSuppliedBy.class); if (annotation != null) { return buildParameterSupplierFromClass(annotation.value()); } else { return new AllMembersSupplier(fClass); } }
private ParameterSupplier buildParameterSupplierFromClass( Class<? extends ParameterSupplier> cls) throws Exception { Constructor<?>[] supplierConstructors = cls.getConstructors(); for (Constructor<?> constructor : supplierConstructors) { Class<?>[] parameterTypes = constructor.getParameterTypes(); if (parameterTypes.length == 1 && parameterTypes[0].equals(TestClass.class)) { return (ParameterSupplier) constructor.newInstance(fClass); } } return cls.newInstance(); }
public ParameterSupplier getSupplier(ParameterSignature unassigned) throws InstantiationException, IllegalAccessException { ParameterSupplier supplier = getAnnotatedSupplier(unassigned); if (supplier != null) { return supplier; } return new AllMembersSupplier(fClass); }
public ParameterSupplier getAnnotatedSupplier(ParameterSignature unassigned) throws InstantiationException, IllegalAccessException { ParametersSuppliedBy annotation = unassigned .findDeepAnnotation(ParametersSuppliedBy.class); if (annotation == null) { return null; } return annotation.value().newInstance(); }