/** * Determine if the supplied {@link Parameter} is an aggregator (i.e., of * type {@link ArgumentsAccessor} or annotated with {@link AggregateWith}). * * @return {@code true} if the parameter is an aggregator */ private static boolean isAggregator(Parameter parameter) { return ArgumentsAccessor.class.isAssignableFrom(parameter.getType()) || isAnnotated(parameter, AggregateWith.class); }
@Override public boolean test(Class<?> candidate) { //please do not collapse into single return if (!isInnerClass.test(candidate)) { return false; } return isAnnotated(candidate, Nested.class); }
@Override public boolean supportsTestTemplate(ExtensionContext context) { return isAnnotated(context.getTestMethod(), RepeatedTest.class); }
@Override public boolean isAnnotated(Class<? extends Annotation> annotationType) { return AnnotationUtils.isAnnotated(getEffectiveAnnotatedParameter(), annotationType); }
@Override public boolean isAnnotated(Class<? extends Annotation> annotationType) { Preconditions.notNull(annotationType, "annotationType must not be null"); return AnnotationUtils.isAnnotated(getMethod(), annotationType); }
@Override public boolean supportsTestTemplate(ExtensionContext context) { if (!context.getTestMethod().isPresent()) { return false; } Method testMethod = context.getTestMethod().get(); if (!isAnnotated(testMethod, ParameterizedTest.class)) { return false; } ParameterizedTestMethodContext methodContext = new ParameterizedTestMethodContext(testMethod); Preconditions.condition(methodContext.hasPotentiallyValidSignature(), () -> String.format( "@ParameterizedTest method [%s] declares formal parameters in an invalid order: " + "argument aggregators must be declared after any indexed arguments " + "and before any arguments resolved by another ParameterResolver.", testMethod.toGenericString())); getStore(context).put(METHOD_CONTEXT_KEY, methodContext); return true; }
@Override public boolean test(Method candidate) { // Please do not collapse the following into a single statement. if (isStatic(candidate)) { return false; } if (isPrivate(candidate)) { return false; } if (isAbstract(candidate)) { return false; } if (returnsVoid(candidate) != this.mustReturnVoid) { return false; } return isAnnotated(candidate, this.annotationType); }
private CreationScope scopeFor(Executable injectionTarget) { if (isAnnotated(injectionTarget, BeforeAll.class)) { return CreationScope.BEFORE_ALL; } else if (isAnnotated(injectionTarget, BeforeEach.class)) { return CreationScope.BEFORE_EACH; } return CreationScope.TEST; }
private static boolean hasBeanDefiningAnnotation(Class<?> clazz) { return AnnotationUtils.isAnnotated(clazz, ApplicationScoped.class) || AnnotationUtils.isAnnotated(clazz, SessionScoped.class) || AnnotationUtils.isAnnotated(clazz, ConversationScoped.class) || AnnotationUtils.isAnnotated(clazz, RequestScoped.class) || AnnotationUtils.isAnnotated(clazz, Dependent.class) || AnnotationUtils.isAnnotated(clazz, Stereotype.class); }
private static boolean hasBeanDefiningAnnotation(Class<?> clazz) { return AnnotationUtils.isAnnotated(clazz, ApplicationScoped.class) || AnnotationUtils.isAnnotated(clazz, SessionScoped.class) || AnnotationUtils.isAnnotated(clazz, ConversationScoped.class) || AnnotationUtils.isAnnotated(clazz, RequestScoped.class) || AnnotationUtils.isAnnotated(clazz, Dependent.class) || AnnotationUtils.isAnnotated(clazz, Stereotype.class); }
private List<Method> findAnnotatedMethods(Object testInstance) { Predicate<Method> isRuleMethod = method -> isAnnotated(method, Rule.class); Predicate<Method> hasCorrectReturnType = method -> TestRule.class.isAssignableFrom(method.getReturnType()); return findMethods(testInstance.getClass(), isRuleMethod.and(hasCorrectReturnType)); }
/** * Check that test method contain {@link RepeatedIfExceptionsTest} annotation * * @param extensionContext - encapsulates the context in which the current test or container is being executed * @return true/false */ @Override public boolean supportsTestTemplate(ExtensionContext extensionContext) { return isAnnotated(extensionContext.getTestMethod(), RepeatedIfExceptionsTest.class); }
@Override public boolean supportsTestTemplate(final ExtensionContext context) { return isAnnotated(context.getTestMethod(), EnvironmentalTest.class); }
@Override protected List<Method> findRuleAnnotatedMembers(Object testInstance) { Predicate<Method> isRuleMethod = method -> isAnnotated(method, Rule.class); Predicate<Method> hasCorrectReturnType = method -> method.getReturnType().isAssignableFrom(getRuleType()); return findMethods(testInstance.getClass(), isRuleMethod.and(hasCorrectReturnType)); }
/** * Get a collection of {@link SystemProperty} for the given {@code annotatedElement}. If the given * {@code annotatedElement} has no such annotations then an empty list is returned, if the given * {@code annotatedElement} is annotated with {@link SystemProperty} then a list with one element * is returned, if the given {@code annotatedElement} is annotated with {@link SystemProperties} * then a list with one element for each of the repeated {@link SystemProperty} values is * returned. * * <p>This is essentially a shortcut for logic such as: 'does this element have the {@link * SystemProperty} annotation, if not does it have the {@link SystemProperties}' followed by * gathering these annotation values. * * @param annotatedElement either a test class or a test method which may be annotated with a * system property annotation * @return 0..* {@link SystemProperty} elements */ private List<SystemProperty> getSystemProperties(AnnotatedElement annotatedElement) { List<SystemProperty> systemProperties = new ArrayList<>(); if (isAnnotated(annotatedElement, SystemProperties.class)) { // gather the repeating system property values systemProperties.addAll( Arrays.asList(annotatedElement.getAnnotation(SystemProperties.class).value())); } if (isAnnotated(annotatedElement, SystemProperty.class)) { // add the single system property value systemProperties.add(annotatedElement.getAnnotation(SystemProperty.class)); } return systemProperties; }
@Override public boolean supportsTestTemplate(ExtensionContext context) { return AnnotationUtils.isAnnotated(context.getTestMethod(), DualPlannerTest.class) && FDBRecordStoreQueryTestBase.class.isAssignableFrom(context.getRequiredTestClass()); }