groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 05/08: Add test cases for IndexedProperty, Bindable, and Vetoable
Date Fri, 28 Jun 2019 17:21:52 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit ddb8e04b77a47a8c6e201c776e6d2df03657b054
Author: aalmiray <aalmiray@gmail.com>
AuthorDate: Tue Jun 11 19:21:06 2019 +0200

    Add test cases for IndexedProperty, Bindable, and Vetoable
---
 .../groovy/generated/BindableGeneratedTest.groovy  | 98 ++++++++++++++++++++++
 .../generated/IndexedPropertyGeneratedTest.groovy  | 67 +++++++++++++++
 .../groovy/generated/SortableGeneratedTest.groovy  |  1 -
 .../groovy/generated/VetoableGeneratedTest.groovy  | 98 ++++++++++++++++++++++
 4 files changed, 263 insertions(+), 1 deletion(-)

diff --git a/src/test/groovy/generated/BindableGeneratedTest.groovy b/src/test/groovy/generated/BindableGeneratedTest.groovy
new file mode 100644
index 0000000..db2655d
--- /dev/null
+++ b/src/test/groovy/generated/BindableGeneratedTest.groovy
@@ -0,0 +1,98 @@
+package groovy.generated
+
+import groovy.transform.CompileStatic
+import org.junit.Test
+
+import java.beans.PropertyChangeListener
+
+@CompileStatic
+class BindableGeneratedTest extends AbstractGeneratedAstTestCase {
+    final Class<?> implicitBindable = parseClass('''@groovy.beans.Bindable
+      class ClassUnderTest {
+          String name
+          int age
+      }''')
+
+    final Class<?> explicitBindable = parseClass('''@groovy.beans.Bindable
+      class ClassUnderTest {
+          String name
+          int age
+          void addPropertyChangeListener(java.beans.PropertyChangeListener l) { }
+          void addPropertyChangeListener(String p, java.beans.PropertyChangeListener l) {
}
+          void removePropertyChangeListener(java.beans.PropertyChangeListener l) { }
+          void removePropertyChangeListener(String p, java.beans.PropertyChangeListener l)
{ }
+          void firePropertyChange(String p, Object o, Object n) { }
+          java.beans.PropertyChangeListener[] getPropertyChangeListeners() { null }
+          java.beans.PropertyChangeListener[] getPropertyChangeListeners(String p) { null
}
+      }''')
+
+    @Test
+    void test_addPropertyChangeListener_is_annotated() {
+        assertMethodIsAnnotated(implicitBindable, 'addPropertyChangeListener', PropertyChangeListener)
+    }
+
+    @Test
+    void test_addPropertyChangeListener2_is_annotated() {
+        assertMethodIsAnnotated(implicitBindable, 'addPropertyChangeListener', String, PropertyChangeListener)
+    }
+
+    @Test
+    void test_removePropertyChangeListener_is_annotated() {
+        assertMethodIsAnnotated(implicitBindable, 'removePropertyChangeListener', PropertyChangeListener)
+    }
+
+    @Test
+    void test_removePropertyChangeListener2_is_annotated() {
+        assertMethodIsAnnotated(implicitBindable, 'removePropertyChangeListener', String,
PropertyChangeListener)
+    }
+
+    @Test
+    void test_firePropertyChange_is_annotated() {
+        assertMethodIsAnnotated(implicitBindable, 'firePropertyChange', String, Object, Object)
+    }
+
+    @Test
+    void test_getPropertyChangeListeners_is_annotated() {
+        assertExactMethodIsAnnotated(implicitBindable, 'getPropertyChangeListeners', PropertyChangeListener[].class)
+    }
+
+    @Test
+    void test_getPropertyChangeListeners2_is_annotated() {
+        assertExactMethodIsAnnotated(implicitBindable, 'getPropertyChangeListeners', PropertyChangeListener[].class,
String)
+    }
+
+    @Test
+    void test_explicit_addPropertyChangeListener_is_annotated() {
+        assertMethodIsNotAnnotated(explicitBindable, 'addPropertyChangeListener', PropertyChangeListener)
+    }
+
+    @Test
+    void test_explicit_addPropertyChangeListener2_is_annotated() {
+        assertMethodIsNotAnnotated(explicitBindable, 'addPropertyChangeListener', String,
PropertyChangeListener)
+    }
+
+    @Test
+    void test_explicit_removePropertyChangeListener_is_annotated() {
+        assertMethodIsNotAnnotated(explicitBindable, 'removePropertyChangeListener', PropertyChangeListener)
+    }
+
+    @Test
+    void test_explicit_removePropertyChangeListener2_is_annotated() {
+        assertMethodIsNotAnnotated(explicitBindable, 'removePropertyChangeListener', String,
PropertyChangeListener)
+    }
+
+    @Test
+    void test_explicit_firePropertyChange_is_annotated() {
+        assertMethodIsNotAnnotated(explicitBindable, 'firePropertyChange', String, Object,
Object)
+    }
+
+    @Test
+    void test_explicit_getPropertyChangeListeners_is_annotated() {
+        assertExactMethodIsNotAnnotated(explicitBindable, 'getPropertyChangeListeners', PropertyChangeListener[].class)
+    }
+
+    @Test
+    void test_explicit_getPropertyChangeListeners2_is_annotated() {
+        assertExactMethodIsNotAnnotated(explicitBindable, 'getPropertyChangeListeners', PropertyChangeListener[].class,
String)
+    }
+}
\ No newline at end of file
diff --git a/src/test/groovy/generated/IndexedPropertyGeneratedTest.groovy b/src/test/groovy/generated/IndexedPropertyGeneratedTest.groovy
new file mode 100644
index 0000000..ae049d4
--- /dev/null
+++ b/src/test/groovy/generated/IndexedPropertyGeneratedTest.groovy
@@ -0,0 +1,67 @@
+package groovy.generated
+
+import groovy.transform.CompileStatic
+import org.junit.Test
+
+@CompileStatic
+class IndexedPropertyGeneratedTest extends AbstractGeneratedAstTestCase {
+    final Class<?> implicitIndex = parseClass('''import groovy.transform.IndexedProperty
+      class ClassUnderTest {
+          @IndexedProperty
+          String[] names
+          @IndexedProperty
+          List ages
+      }''')
+
+    final Class<?> explicitIndex = parseClass('''import groovy.transform.IndexedProperty
+      class ClassUnderTest {
+          @IndexedProperty
+          String[] names
+          @IndexedProperty
+          List ages
+          String getNames(int idx) { null }
+          Object getAges(int idx) { null }
+          void setNames(int idx, String n) { }
+          void setAges(int idx, Object o) { }
+      }''')
+
+    @Test
+    void test_implicit_getNames_is_annotated() {
+        assertExactMethodIsAnnotated(implicitIndex, 'getNames', String, int.class)
+    }
+
+    @Test
+    void test_implicit_getAges_is_annotated() {
+        assertExactMethodIsAnnotated(implicitIndex, 'getAges', Object, int.class)
+    }
+
+    @Test
+    void test_implicit_setNames_is_annotated() {
+        assertMethodIsAnnotated(implicitIndex, 'setNames', int.class, String)
+    }
+
+    @Test
+    void test_implicit_setAges_is_annotated() {
+        assertMethodIsAnnotated(implicitIndex, 'setAges', int.class, Object)
+    }
+
+    @Test
+    void test_explicit_getNames_is_annotated() {
+        assertExactMethodIsNotAnnotated(explicitIndex, 'getNames', String, int.class)
+    }
+
+    @Test
+    void test_explicit_getAges_is_annotated() {
+        assertExactMethodIsNotAnnotated(explicitIndex, 'getAges', Object, int.class)
+    }
+
+    @Test
+    void test_explicit_setNames_is_annotated() {
+        assertMethodIsNotAnnotated(explicitIndex, 'setNames', int.class, String)
+    }
+
+    @Test
+    void test_explicit_setAges_is_annotated() {
+        assertMethodIsNotAnnotated(explicitIndex, 'setAges', int.class, Object)
+    }
+}
\ No newline at end of file
diff --git a/src/test/groovy/generated/SortableGeneratedTest.groovy b/src/test/groovy/generated/SortableGeneratedTest.groovy
index 409795c..958dc50 100644
--- a/src/test/groovy/generated/SortableGeneratedTest.groovy
+++ b/src/test/groovy/generated/SortableGeneratedTest.groovy
@@ -39,7 +39,6 @@ class SortableGeneratedTest extends AbstractGeneratedAstTestCase {
         assertMethodIsAnnotated(implicitSortable, 'comparatorByAge')
     }
 
-
     @Test
     void test_explicit_compareTo_is_not_annotated() {
         assertMethodIsNotAnnotated(explicitSortable, 'compareTo', Object)
diff --git a/src/test/groovy/generated/VetoableGeneratedTest.groovy b/src/test/groovy/generated/VetoableGeneratedTest.groovy
new file mode 100644
index 0000000..8bb099d
--- /dev/null
+++ b/src/test/groovy/generated/VetoableGeneratedTest.groovy
@@ -0,0 +1,98 @@
+package groovy.generated
+
+import groovy.transform.CompileStatic
+import org.junit.Test
+
+import java.beans.VetoableChangeListener
+
+@CompileStatic
+class VetoableGeneratedTest extends AbstractGeneratedAstTestCase {
+    final Class<?> implicitVetoable = parseClass('''@groovy.beans.Vetoable
+      class ClassUnderTest {
+          String name
+          int age
+      }''')
+
+    final Class<?> explicitVetoable = parseClass('''@groovy.beans.Vetoable
+      class ClassUnderTest {
+          String name
+          int age
+          void addVetoableChangeListener(java.beans.VetoableChangeListener l) { }
+          void addVetoableChangeListener(String p, java.beans.VetoableChangeListener l) {
}
+          void removeVetoableChangeListener(java.beans.VetoableChangeListener l) { }
+          void removeVetoableChangeListener(String p, java.beans.VetoableChangeListener l)
{ }
+          void fireVetoableChange(String p, Object o, Object n) throws java.beans.PropertyVetoException
{ }
+          java.beans.VetoableChangeListener[] getVetoableChangeListeners() { null }
+          java.beans.VetoableChangeListener[] getVetoableChangeListeners(String p) { null
}
+      }''')
+
+    @Test
+    void test_addVetoableChangeListener_is_annotated() {
+        assertMethodIsAnnotated(implicitVetoable, 'addVetoableChangeListener', VetoableChangeListener)
+    }
+
+    @Test
+    void test_addVetoableChangeListener2_is_annotated() {
+        assertMethodIsAnnotated(implicitVetoable, 'addVetoableChangeListener', String, VetoableChangeListener)
+    }
+
+    @Test
+    void test_removeVetoableChangeListener_is_annotated() {
+        assertMethodIsAnnotated(implicitVetoable, 'removeVetoableChangeListener', VetoableChangeListener)
+    }
+
+    @Test
+    void test_removeVetoableChangeListener2_is_annotated() {
+        assertMethodIsAnnotated(implicitVetoable, 'removeVetoableChangeListener', String,
VetoableChangeListener)
+    }
+
+    @Test
+    void test_fireVetoableChange_is_annotated() {
+        assertMethodIsAnnotated(implicitVetoable, 'fireVetoableChange', String, Object, Object)
+    }
+
+    @Test
+    void test_getVetoableChangeListeners_is_annotated() {
+        assertExactMethodIsAnnotated(implicitVetoable, 'getVetoableChangeListeners', VetoableChangeListener[].class)
+    }
+
+    @Test
+    void test_getVetoableChangeListeners2_is_annotated() {
+        assertExactMethodIsAnnotated(implicitVetoable, 'getVetoableChangeListeners', VetoableChangeListener[].class,
String)
+    }
+
+    @Test
+    void test_explicit_addVetoableChangeListener_is_annotated() {
+        assertMethodIsNotAnnotated(explicitVetoable, 'addVetoableChangeListener', VetoableChangeListener)
+    }
+
+    @Test
+    void test_explicit_addVetoableChangeListener2_is_annotated() {
+        assertMethodIsNotAnnotated(explicitVetoable, 'addVetoableChangeListener', String,
VetoableChangeListener)
+    }
+
+    @Test
+    void test_explicit_removeVetoableChangeListener_is_annotated() {
+        assertMethodIsNotAnnotated(explicitVetoable, 'removeVetoableChangeListener', VetoableChangeListener)
+    }
+
+    @Test
+    void test_explicit_removeVetoableChangeListener2_is_annotated() {
+        assertMethodIsNotAnnotated(explicitVetoable, 'removeVetoableChangeListener', String,
VetoableChangeListener)
+    }
+
+    @Test
+    void test_explicit_fireVetoableChange_is_annotated() {
+        assertMethodIsNotAnnotated(explicitVetoable, 'fireVetoableChange', String, Object,
Object)
+    }
+
+    @Test
+    void test_explicit_getVetoableChangeListeners_is_annotated() {
+        assertExactMethodIsNotAnnotated(explicitVetoable, 'getVetoableChangeListeners', VetoableChangeListener[].class)
+    }
+
+    @Test
+    void test_explicit_getVetoableChangeListeners2_is_annotated() {
+        assertExactMethodIsNotAnnotated(explicitVetoable, 'getVetoableChangeListeners', VetoableChangeListener[].class,
String)
+    }
+}
\ No newline at end of file


Mime
View raw message