dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41128
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20946: fix for In operator + tests
------------------------------------------------------------
revno: 20946
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-11-04 15:29:32 +0700
message:
fix for In operator + tests
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/In.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/In.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/In.java 2015-11-04 06:46:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/In.java 2015-11-04 08:29:32 +0000
@@ -40,7 +40,7 @@
{
public In( String arg )
{
- super( Typed.from( Collection.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 07:52:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java 2015-11-04 08:29:32 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.query.operators.GreaterEqual;
import org.hisp.dhis.query.operators.GreaterThan;
import org.hisp.dhis.query.operators.ILike;
+import org.hisp.dhis.query.operators.In;
import org.hisp.dhis.query.operators.LessEqual;
import org.hisp.dhis.query.operators.LessThan;
import org.hisp.dhis.query.operators.Like;
@@ -328,4 +329,40 @@
assertFalse( operator.test( null ) );
assertTrue( operator.test( "test" ) );
}
+
+ @Test
+ public void testInValidTypes()
+ {
+ In operator = new In( "[1,2,3]" );
+
+ assertTrue( operator.isValid( String.class ) );
+ assertTrue( operator.isValid( Number.class ) );
+ assertTrue( operator.isValid( Date.class ) );
+ assertTrue( operator.isValid( Boolean.class ) );
+ assertTrue( operator.isValid( Enum.class ) );
+ }
+
+ @Test
+ public void testInInt()
+ {
+ In operator = new In( "[1,2,3]" );
+
+ assertFalse( operator.test( 0 ) );
+ assertTrue( operator.test( 1 ) );
+ assertTrue( operator.test( 2 ) );
+ assertTrue( operator.test( 3 ) );
+ assertFalse( operator.test( 4 ) );
+ }
+
+ @Test
+ public void testInString()
+ {
+ In operator = new In( "[b,c,d]" );
+
+ assertFalse( operator.test( "a" ) );
+ assertTrue( operator.test( "b" ) );
+ assertTrue( operator.test( "c" ) );
+ assertTrue( operator.test( "d" ) );
+ assertFalse( operator.test( "e" ) );
+ }
}