← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20942: more operator tests

 

------------------------------------------------------------
revno: 20942
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-11-04 13:08:28 +0700
message:
  more operator tests
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotNull.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Null.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/NotNull.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotNull.java	2015-11-04 05:48:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotNull.java	2015-11-04 06:08:28 +0000
@@ -37,9 +37,9 @@
  */
 public class NotNull extends Operator
 {
-    public NotNull( String propertyValue )
+    public NotNull()
     {
-        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+        super( null, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Null.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Null.java	2015-11-04 05:48:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Null.java	2015-11-04 06:08:28 +0000
@@ -37,9 +37,9 @@
  */
 public class Null extends Operator
 {
-    public Null( String propertyValue )
+    public Null()
     {
-        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+        super( null, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
     }
 
     @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 05:48:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java	2015-11-04 06:08:28 +0000
@@ -100,6 +100,17 @@
     }
 
     @Test
+    public void testNotEqual()
+    {
+        NotEqual operator = new NotEqual( "operator" );
+
+        assertFalse( operator.test( "operator" ) );
+        assertTrue( operator.test( Boolean.TRUE ) );
+        assertTrue( operator.test( new Float( 0 ) ) );
+        assertTrue( operator.test( Collections.emptyList() ) );
+    }
+
+    @Test
     public void testGreaterEqualValidTypes()
     {
         GreaterEqual operator = new GreaterEqual( "operator" );
@@ -112,6 +123,21 @@
     }
 
     @Test
+    public void testGreaterEqual()
+    {
+        GreaterEqual operator = new GreaterEqual( "10" );
+
+        assertFalse( operator.test( 6 ) );
+        assertFalse( operator.test( 7 ) );
+        assertFalse( operator.test( 8 ) );
+        assertFalse( operator.test( 9 ) );
+        assertTrue( operator.test( 10 ) );
+        assertTrue( operator.test( 11 ) );
+        assertTrue( operator.test( 12 ) );
+        assertTrue( operator.test( 13 ) );
+    }
+
+    @Test
     public void testGreaterThanValidTypes()
     {
         GreaterThan operator = new GreaterThan( "operator" );
@@ -124,6 +150,21 @@
     }
 
     @Test
+    public void testGreaterThan()
+    {
+        GreaterThan operator = new GreaterThan( "10" );
+
+        assertFalse( operator.test( 6 ) );
+        assertFalse( operator.test( 7 ) );
+        assertFalse( operator.test( 8 ) );
+        assertFalse( operator.test( 9 ) );
+        assertFalse( operator.test( 10 ) );
+        assertTrue( operator.test( 11 ) );
+        assertTrue( operator.test( 12 ) );
+        assertTrue( operator.test( 13 ) );
+    }
+
+    @Test
     public void testILikeValidTypes()
     {
         ILike operator = new ILike( "operator" );
@@ -160,6 +201,21 @@
     }
 
     @Test
+    public void testLessEqual()
+    {
+        LessEqual operator = new LessEqual( "10" );
+
+        assertTrue( operator.test( 6 ) );
+        assertTrue( operator.test( 7 ) );
+        assertTrue( operator.test( 8 ) );
+        assertTrue( operator.test( 9 ) );
+        assertTrue( operator.test( 10 ) );
+        assertFalse( operator.test( 11 ) );
+        assertFalse( operator.test( 12 ) );
+        assertFalse( operator.test( 13 ) );
+    }
+
+    @Test
     public void testLessThanValidTypes()
     {
         LessThan operator = new LessThan( "operator" );
@@ -172,9 +228,24 @@
     }
 
     @Test
+    public void testLessThan()
+    {
+        LessThan operator = new LessThan( "10" );
+
+        assertTrue( operator.test( 6 ) );
+        assertTrue( operator.test( 7 ) );
+        assertTrue( operator.test( 8 ) );
+        assertTrue( operator.test( 9 ) );
+        assertFalse( operator.test( 10 ) );
+        assertFalse( operator.test( 11 ) );
+        assertFalse( operator.test( 12 ) );
+        assertFalse( operator.test( 13 ) );
+    }
+
+    @Test
     public void testNullValidTypes()
     {
-        Null operator = new Null( "operator" );
+        Null operator = new Null();
 
         assertTrue( operator.isValid( String.class ) );
         assertTrue( operator.isValid( Number.class ) );
@@ -184,9 +255,18 @@
     }
 
     @Test
+    public void testNull()
+    {
+        Null operator = new Null();
+
+        assertFalse( operator.test( null ) );
+        assertTrue( operator.test( "test" ) );
+    }
+
+    @Test
     public void testNotNullValidTypes()
     {
-        NotNull operator = new NotNull( "operator" );
+        NotNull operator = new NotNull();
 
         assertTrue( operator.isValid( String.class ) );
         assertTrue( operator.isValid( Number.class ) );
@@ -194,4 +274,13 @@
         assertTrue( operator.isValid( Boolean.class ) );
         assertFalse( operator.isValid( Collection.class ) );
     }
+
+    @Test
+    public void testNotNull()
+    {
+        NotNull operator = new NotNull();
+
+        assertTrue( operator.test( null ) );
+        assertFalse( operator.test( "test" ) );
+    }
 }