/** * Checks if some annotation is present in the given array of annotations * * @param annotations - array of annotations * @param needle - annotation we are looking for * @return if the annotation is present an the given array of annotations */ private static boolean isAnnotationPresent(final Annotation[] annotations, final Class<? extends Annotation> needle) { return findAnnotation(annotations, needle) != null; }
/** * Checks if some annotation is present in the given array of annotations * * @param annotations - array of annotations * @param needle - annotation we are looking for * @return if the annotation is present an the given array of annotations */ private static boolean isAnnotationPresent(final Annotation[] annotations, final Class<? extends Annotation> needle) { return findAnnotation(annotations, needle) != null; }
@Override public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { StringBuffer errorMsgBegin = new StringBuffer(""); List<Object[]> paramCouple = new LinkedList<Object[]>(); paramCouple.addAll(ReflectionHelper.getParametersWithAnnotation(method, InFrame.class)); for (int i = 0; i < resolvedParams.length; i++) { if (paramCouple.get(i) != null && resolvedParams[i] != null) { Class<?> param = (Class<?>) paramCouple.get(i)[0]; Annotation[] parameterAnnotations = (Annotation[]) paramCouple.get(i)[1]; InFrame inFrame = ReflectionHelper.findAnnotation(parameterAnnotations, InFrame.class); int index = inFrame.index(); String nameOrId = inFrame.nameOrId(); checkInFrameParameters(method, param, index, nameOrId); try { registerInFrameInterceptor((GrapheneProxyInstance) resolvedParams[i], index, nameOrId); } catch (IllegalArgumentException e) { throw new GrapheneTestEnricherException( "Only org.openqa.selenium.WebElement, Page fragments fields and Page Object fields can be annotated with @InFrame. Check parameter " + param + " of the method: " + method.getName() + " declared in: " + method .getDeclaringClass(), e); } catch (Exception e) { throw new GrapheneTestEnricherException(e); } } } return resolvedParams; }
@Override public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { StringBuffer errorMsgBegin = new StringBuffer(""); List<Object[]> paramCouple = new LinkedList<Object[]>(); paramCouple.addAll(ReflectionHelper.getParametersWithAnnotation(method, InFrame.class)); for (int i = 0; i < resolvedParams.length; i++) { if (paramCouple.get(i) != null && resolvedParams[i] != null) { Class<?> param = (Class<?>) paramCouple.get(i)[0]; Annotation[] parameterAnnotations = (Annotation[]) paramCouple.get(i)[1]; InFrame inFrame = ReflectionHelper.findAnnotation(parameterAnnotations, InFrame.class); int index = inFrame.index(); String nameOrId = inFrame.nameOrId(); checkInFrameParameters(method, param, index, nameOrId); try { registerInFrameInterceptor((GrapheneProxyInstance) resolvedParams[i], index, nameOrId); } catch (IllegalArgumentException e) { throw new GrapheneTestEnricherException( "Only org.openqa.selenium.WebElement, Page fragments fields and Page Object fields can be annotated with @InFrame. Check parameter " + param + " of the method: " + method.getName() + " declared in: " + method .getDeclaringClass(), e); } catch (Exception e) { throw new GrapheneTestEnricherException(e); } } } return resolvedParams; }