MEECROWAVE-252: Use AnnotationUtils.findAnnotation
diff --git a/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java b/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java
index fd91ac7..18aaeea 100644
--- a/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java
+++ b/meecrowave-junit/src/main/java/org/apache/meecrowave/junit5/MeecrowaveExtension.java
@@ -18,23 +18,13 @@
  */
 package org.apache.meecrowave.junit5;
 
-import static java.util.Arrays.asList;
-import static java.util.Arrays.stream;
-import static java.util.Collections.emptyList;
 import static java.util.Optional.ofNullable;
-import static java.util.stream.Collectors.toSet;
+import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation;
 
 import java.io.File;
 import java.lang.annotation.Annotation;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
 import java.util.Optional;
 
 import javax.enterprise.context.spi.CreationalContext;
@@ -53,16 +43,14 @@
     
 	private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(MeecrowaveExtension.class.getName());
 	
-	private static final List<Class<? extends Annotation>> DEFAULT_ANNOTATION_TYPES = asList(Retention.class, Target.class, Documented.class);
-
     private final ScopesExtension scopes = new ScopesExtension() {
         @Override
         protected Optional<Class<? extends Annotation>[]> getScopes(final ExtensionContext context) {
             return context.getElement()
-                          .map(e -> getConfigAnnotation(asList(e.getAnnotations()))
+                          .map(e -> findAnnotation(context.getElement(), MeecrowaveConfig.class)
                                   .orElseGet(() -> context.getParent()
                                                           .flatMap(ExtensionContext::getElement)
-                                                          .flatMap(it -> getConfigAnnotation(asList(it.getAnnotations())))
+                                                          .flatMap(it -> findAnnotation(it, MeecrowaveConfig.class))
                                                           .orElse(null)))
                           .map(MeecrowaveConfig::scopes)
                           .filter(s -> s.length > 0);
@@ -72,8 +60,7 @@
     @Override
     public void beforeAll(final ExtensionContext context) {
         final Meecrowave.Builder builder = new Meecrowave.Builder();
-        final Optional<MeecrowaveConfig> meecrowaveConfig
-        	= getConfigAnnotation(context.getElement().map(AnnotatedElement::getAnnotations).map(Arrays::asList).orElse(emptyList()));
+        final Optional<MeecrowaveConfig> meecrowaveConfig = findAnnotation(context.getElement(), MeecrowaveConfig.class);
         final String ctx;
         if (meecrowaveConfig.isPresent()) {
             final MeecrowaveConfig config = meecrowaveConfig.get();
@@ -149,25 +136,6 @@
         }
     }
 
-    private static Optional<MeecrowaveConfig> getConfigAnnotation(Collection<Annotation> annotations) {
-    	while (!annotations.isEmpty()) {
-        	Optional<MeecrowaveConfig> config = annotations.stream()
-        			.filter(a -> a.annotationType().equals(MeecrowaveConfig.class))
-        			.map(a -> MeecrowaveConfig.class.cast(a))
-        			.findFirst();
-        	if (config.isPresent()) {
-        		return config;
-        	}
-        	annotations = annotations
-        			.stream()
-        			.map(Annotation::annotationType)
-        			.flatMap(a -> stream(a.getAnnotations()))
-        			.filter(a -> !DEFAULT_ANNOTATION_TYPES.contains(a.annotationType()))
-        			.collect(toSet());
-    	}
-    	return Optional.empty();
-    }
-
 	private void doRelease(final ExtensionContext context) {
         ofNullable(context.getStore(NAMESPACE).get(CreationalContext.class, CreationalContext.class))
                 .ifPresent(CreationalContext::release);