org.junit.experimental.theories.internal.SpecificDataPointsSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-curves4 Show documentation
Show all versions of virtdata-lib-curves4 Show documentation
Statistical sampling library for use in virtualdataset libraries, based on apache commons math 4
package org.junit.experimental.theories.internal;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.experimental.theories.DataPoint;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.FromDataPoints;
import org.junit.experimental.theories.ParameterSignature;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.TestClass;
public class SpecificDataPointsSupplier extends AllMembersSupplier {
public SpecificDataPointsSupplier(TestClass testClass) {
super(testClass);
}
@Override
protected Collection getSingleDataPointFields(ParameterSignature sig) {
Collection fields = super.getSingleDataPointFields(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List fieldsWithMatchingNames = new ArrayList();
for (Field field : fields) {
String[] fieldNames = field.getAnnotation(DataPoint.class).value();
if (Arrays.asList(fieldNames).contains(requestedName)) {
fieldsWithMatchingNames.add(field);
}
}
return fieldsWithMatchingNames;
}
@Override
protected Collection getDataPointsFields(ParameterSignature sig) {
Collection fields = super.getDataPointsFields(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List fieldsWithMatchingNames = new ArrayList();
for (Field field : fields) {
String[] fieldNames = field.getAnnotation(DataPoints.class).value();
if (Arrays.asList(fieldNames).contains(requestedName)) {
fieldsWithMatchingNames.add(field);
}
}
return fieldsWithMatchingNames;
}
@Override
protected Collection getSingleDataPointMethods(ParameterSignature sig) {
Collection methods = super.getSingleDataPointMethods(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List methodsWithMatchingNames = new ArrayList();
for (FrameworkMethod method : methods) {
String[] methodNames = method.getAnnotation(DataPoint.class).value();
if (Arrays.asList(methodNames).contains(requestedName)) {
methodsWithMatchingNames.add(method);
}
}
return methodsWithMatchingNames;
}
@Override
protected Collection getDataPointsMethods(ParameterSignature sig) {
Collection methods = super.getDataPointsMethods(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List methodsWithMatchingNames = new ArrayList();
for (FrameworkMethod method : methods) {
String[] methodNames = method.getAnnotation(DataPoints.class).value();
if (Arrays.asList(methodNames).contains(requestedName)) {
methodsWithMatchingNames.add(method);
}
}
return methodsWithMatchingNames;
}
}