@Inject
private Event<DroneLifecycleEvent> droneLifecycleEvent;
@Override
public void enrich(Object testCase) {
DroneContext context = droneContext.get();
Map<Field, DronePoint<?>> injectionPoints = InjectionPoints.fieldsInClass(droneContext.get(),
testCase.getClass());
for (Field field : injectionPoints.keySet()) {
// omit setting if already set
if (SecurityActions.getFieldValue(testCase, field) != null) {
log.log(Level.FINER, "Skipped injection of field {0}", field.getName());
continue;
}
DronePoint<?> dronePoint = injectionPoints.get(field);
ensureInjectionPointPrepared(dronePoint);
log.log(Level.FINE, "Injecting @Drone for field {0}, injection point {1}",
new Object[] { dronePoint.getDroneType().getSimpleName(), dronePoint }
);
Object drone = context.get(dronePoint).getInstance();
Validate.stateNotNull(drone, "Retrieved a null from Drone Context, " +
"which is not a valid Drone browser object. \nClass: {0}, field: {1}, injection point: {2}",
testCase.getClass().getName(), field.getName(), dronePoint
);
SecurityActions.setFieldValue(testCase, field, drone);