openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsandt...@apache.org
Subject svn commit: r1797684 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java test/java/org/apache/webbeans/test/configurator/AnnotatedTypeConfiguratorImplTest.java
Date Mon, 05 Jun 2017 18:34:54 GMT
Author: rsandtner
Date: Mon Jun  5 18:34:53 2017
New Revision: 1797684

URL: http://svn.apache.org/viewvc?rev=1797684&view=rev
Log:
OWB-1187 added tests for Field/MethodConfigurator

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/configurator/AnnotatedTypeConfiguratorImplTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java?rev=1797684&r1=1797683&r2=1797684&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java
Mon Jun  5 18:34:53 2017
@@ -52,7 +52,7 @@ public class AnnotatedMethodConfigurator
     }
 
     @Override
-    public AnnotatedMethodConfigurator<T> remove(Predicate annotation)
+    public AnnotatedMethodConfigurator<T> remove(Predicate<Annotation> annotation)
     {
         annotatedMethod.getAnnotations().removeIf(annotation);
         return this;
@@ -71,9 +71,4 @@ public class AnnotatedMethodConfigurator
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
-    @Override
-    public Stream<AnnotatedParameterConfigurator<T>> filterParams(Predicate predicate)
-    {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
-    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/configurator/AnnotatedTypeConfiguratorImplTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/configurator/AnnotatedTypeConfiguratorImplTest.java?rev=1797684&r1=1797683&r2=1797684&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/configurator/AnnotatedTypeConfiguratorImplTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/configurator/AnnotatedTypeConfiguratorImplTest.java
Mon Jun  5 18:34:53 2017
@@ -162,6 +162,27 @@ public class AnnotatedTypeConfiguratorIm
     }
 
     @Test
+    public void testRemoveAnnotationFromMethod()
+    {
+        final String methodName = "method2";
+
+        checkAnnotatedType(
+                pat -> pat.configureAnnotatedType()
+                          .filterMethods(m -> methodName.equals(m.getJavaMember().getName()))
+                          .findFirst()
+                          .get()
+                          .removeAll(),
+                pba -> assertTrue(((AnnotatedType<?>) pba.getAnnotated()).getMethods()
+                                                                         .stream()
+                                                                         .filter(m ->
methodName.equals(m.getJavaMember().getName()))
+                                                                         .findFirst()
+                                                                         .get()
+                                                                         .getAnnotations()
+                                                                         .isEmpty()),
+                AnnotatedTypeConfigClassWithAnnotation.class);
+    }
+
+    @Test
     public void testAddAnnotationToField()
     {
         checkAnnotatedType(
@@ -189,6 +210,28 @@ public class AnnotatedTypeConfiguratorIm
             }, AnnotatedTypeConfigClass.class);
     }
 
+    @Test
+    public void testRemoveAnnotationFromField()
+    {
+        checkAnnotatedType(pat -> pat.configureAnnotatedType()
+                                     .filterFields(af -> "field2".equals(af.getJavaMember().getName()))
+                                     .findFirst()
+                                     .get()
+                                     .remove(a -> a.annotationType() == TheQualifier.class),
+                           pba ->
+                           {
+                               Assert.assertTrue(pba.getAnnotated() instanceof AnnotatedType);
+                               assertTrue(((AnnotatedType<?>) pba.getAnnotated()).getFields()
+                                                                                 .stream()
+                                                                                 .filter(m
-> m.getJavaMember().getName().equals("field2"))
+                                                                                 .findFirst()
+                                                                                 .get()
+                                                                                 .getAnnotations()
+                                                                                 .isEmpty());
+                           },
+                           AnnotatedTypeConfigClassWithAnnotation.class);
+    }
+
 
     private void checkAnnotatedType(Consumer<ProcessAnnotatedType<AnnotatedTypeConfigClass>>
typeConfigurator,
                                     Consumer<ProcessBeanAttributes> beanAttributesConsumer,
@@ -242,12 +285,46 @@ public class AnnotatedTypeConfiguratorIm
         {
             return "method 2";
         }
+
+        public String methodWithParameters(String param1, Integer param2)
+        {
+            return "parameters: " + param1 + ", " + param2;
+        }
     }
 
     @TheQualifier(value = "default")
     public static class AnnotatedTypeConfigClassWithAnnotation
     {
 
+        @TheQualifier(value = "default_field1")
+        private String field1;
+
+        @TheQualifier(value = "default_field2")
+        private Integer field2;
+
+        @TheQualifier(value = "default_method1")
+        public void method1()
+        {
+            // do nothing
+        }
+
+        @TheQualifier(value = "default_method2")
+        public String method2()
+        {
+            return "method 2";
+        }
+
+        @TheQualifier(value = "default_methodWithParameters")
+        public String methodWithParameters(String param1, String param2)
+        {
+            return "parameters: " + param1 + ", " + param2;
+        }
+
+        public void methodWithAnnotatedParameters(@TheQualifier(value = "default_param1")
String param1,
+                                                  @TheQualifier(value = "default_param2")
Integer param2)
+        {
+            // nothing to do here
+        }
     }
 
     @Qualifier



Mime
View raw message