| 1 |
|
package guru.mikelue.foxglove.annotation; |
| 2 |
|
|
| 3 |
|
import java.lang.reflect.AnnotatedElement; |
| 4 |
|
import java.util.function.Supplier; |
| 5 |
|
|
| 6 |
|
import guru.mikelue.foxglove.TableFacet; |
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 5 |
Complexity Density: 0.36 |
|
| 11 |
|
public class GenDataProcessor { |
| 12 |
|
private final boolean hasGenData; |
| 13 |
|
|
| 14 |
|
private final Object testingInstance; |
| 15 |
|
private final AnnotatedElement annotatedElement; |
| 16 |
|
private final Supplier<DataGenContext<TableFacet>> supplierOfDataGenContext; |
| 17 |
|
private final String name; |
| 18 |
|
|
| 19 |
|
|
| 20 |
|
@link |
| 21 |
|
|
| 22 |
|
@param |
| 23 |
|
@param@link |
| 24 |
|
@param |
| 25 |
|
@param |
| 26 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 27 |
44 |
public GenDataProcessor(... |
| 28 |
|
Object testingInstance, AnnotatedElement annotatedElement, |
| 29 |
|
Supplier<DataGenContext<TableFacet>> supplierOfDataGenContext, |
| 30 |
|
String name |
| 31 |
|
) { |
| 32 |
44 |
var genData = annotatedElement.getAnnotation(GenData.class); |
| 33 |
|
|
| 34 |
44 |
this.hasGenData = (genData != null); |
| 35 |
44 |
this.testingInstance = testingInstance; |
| 36 |
44 |
this.annotatedElement = annotatedElement; |
| 37 |
44 |
this.supplierOfDataGenContext = supplierOfDataGenContext; |
| 38 |
44 |
this.name = name; |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@link |
| 43 |
|
|
| 44 |
|
@return |
| 45 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
46 |
public boolean hasDataGenerating()... |
| 47 |
|
{ |
| 48 |
46 |
return hasGenData; |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@return |
| 55 |
|
|
| 56 |
|
@throws |
| 57 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 58 |
26 |
public int performGenerating() throws Exception... |
| 59 |
|
{ |
| 60 |
26 |
if (!hasDataGenerating()) { |
| 61 |
3 |
return -1; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
23 |
var objectFactory = buildObjectFactory( |
| 65 |
|
testingInstance, |
| 66 |
|
annotatedElement.getAnnotation(GenData.class), |
| 67 |
|
supplierOfDataGenContext.get(), |
| 68 |
|
name |
| 69 |
|
); |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
23 |
var dataGenerator = objectFactory.getDataGenerator(); |
| 75 |
23 |
var tableFacets = objectFactory.getTableFacets(); |
| 76 |
|
|
| 77 |
|
|
| 78 |
23 |
return dataGenerator.generate(tableFacets); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
@link |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
@param |
| 89 |
|
@param@link |
| 90 |
|
@param |
| 91 |
|
@param |
| 92 |
|
|
| 93 |
|
@return@link |
| 94 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 95 |
16 |
protected GenDataObjectFactory buildObjectFactory(... |
| 96 |
|
Object testingInstance, GenData genData, |
| 97 |
|
DataGenContext<TableFacet> dataGenContext, |
| 98 |
|
String name |
| 99 |
|
) { |
| 100 |
16 |
return new ReflectGenDataObjectFactory( |
| 101 |
|
testingInstance, genData, |
| 102 |
|
dataGenContext, |
| 103 |
|
name |
| 104 |
|
); |
| 105 |
|
} |
| 106 |
|
} |