← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20949: more eum operator fixes

 

------------------------------------------------------------
revno: 20949
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-11-04 16:24:10 +0700
message:
  more eum operator fixes
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/EqualOperator.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/EqualOperator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/EqualOperator.java	2015-11-04 08:43:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/EqualOperator.java	2015-11-04 09:24:10 +0000
@@ -40,7 +40,7 @@
 {
     public EqualOperator( String arg )
     {
-        super( Typed.from( String.class, Boolean.class, Number.class, Date.class ), arg );
+        super( Typed.from( String.class, Boolean.class, Number.class, Date.class, Enum.class ), arg );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java	2015-11-04 08:43:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java	2015-11-04 09:24:10 +0000
@@ -55,6 +55,11 @@
  */
 public class OperatorTest
 {
+    enum TestEnum
+    {
+        A, B, C
+    }
+
     @Test
     public void testBetweenValidTypes()
     {
@@ -99,6 +104,7 @@
         assertTrue( operator.isValid( Number.class ) );
         assertTrue( operator.isValid( Date.class ) );
         assertTrue( operator.isValid( Boolean.class ) );
+        assertTrue( operator.isValid( Enum.class ) );
         assertFalse( operator.isValid( Collection.class ) );
     }
 
@@ -114,6 +120,17 @@
     }
 
     @Test
+    public void testEqualEnum()
+    {
+        assertTrue( new EqualOperator( "A" ).test( TestEnum.A ) );
+        assertTrue( new EqualOperator( "B" ).test( TestEnum.B ) );
+        assertTrue( new EqualOperator( "C" ).test( TestEnum.C ) );
+
+        assertFalse( new EqualOperator( "A" ).test( 123 ) );
+        assertFalse( new EqualOperator( "A" ).test( "abc" ) );
+    }
+
+    @Test
     public void testNotEqualValidTypes()
     {
         NotEqualOperator operator = new NotEqualOperator( "operator" );
@@ -366,11 +383,6 @@
         assertFalse( operator.test( "e" ) );
     }
 
-    enum TestEnum
-    {
-        A, B, C
-    }
-
     @Test
     public void testInEnum()
     {