blob: 7b571e335941dafc05d90e583985bd366841f4d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
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<Field> getSingleDataPointFields(ParameterSignature sig) {
Collection<Field> fields = super.getSingleDataPointFields(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List<Field> fieldsWithMatchingNames = new ArrayList<Field>();
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<Field> getDataPointsFields(ParameterSignature sig) {
Collection<Field> fields = super.getDataPointsFields(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List<Field> fieldsWithMatchingNames = new ArrayList<Field>();
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<FrameworkMethod> getSingleDataPointMethods(ParameterSignature sig) {
Collection<FrameworkMethod> methods = super.getSingleDataPointMethods(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();
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<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) {
Collection<FrameworkMethod> methods = super.getDataPointsMethods(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();
for (FrameworkMethod method : methods) {
String[] methodNames = method.getAnnotation(DataPoints.class).value();
if (Arrays.asList(methodNames).contains(requestedName)) {
methodsWithMatchingNames.add(method);
}
}
return methodsWithMatchingNames;
}
}
|