@SuppressWarnings("deprecation") static void processAnnotationDeprecatedWay(AnnotationEngine annotationEngine, Object testClass, Field field) { boolean alreadyAssigned = false; for(Annotation annotation : field.getAnnotations()) { Object mock = annotationEngine.createMockFor(annotation, field); if (mock != null) { throwIfAlreadyAssigned(field, alreadyAssigned); alreadyAssigned = true; try { new FieldSetter(testClass, field).set(mock); } catch (Exception e) { throw new MockitoException("Problems setting field " + field.getName() + " annotated with " + annotation, e); } } } }
@SuppressWarnings("deprecation") static void processAnnotationDeprecatedWay(AnnotationEngine annotationEngine, Object testClass, Field field) { boolean alreadyAssigned = false; for(Annotation annotation : field.getAnnotations()) { Object mock = annotationEngine.createMockFor(annotation, field); if (mock != null) { throwIfAlreadyAssigned(field, alreadyAssigned); alreadyAssigned = true; try { new FieldSetter(testClass, field).set(mock); } catch (Exception e) { throw new MockitoException("Problems setting field " + field.getName() + " annotated with " + annotation, e); } } } }