← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20983: tests for various match modes for LikeOperator

 

------------------------------------------------------------
revno: 20983
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-09 12:57:33 +0700
message:
  tests for various match modes for LikeOperator
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.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/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.java	2015-11-09 05:35:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.java	2015-11-09 05:57:33 +0000
@@ -169,7 +169,7 @@
     }
 
     @Test
-    public void getLikeQuery()
+    public void getLikeQueryAnywhere()
     {
         Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
         query.setObjects( dataElements );
@@ -181,6 +181,35 @@
     }
 
     @Test
+    public void getLikeQueryStart()
+    {
+        Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+        query.setObjects( dataElements );
+        query.add( Restrictions.like( "name", "Data", MatchMode.START ) );
+        List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+        assertEquals( 6, objects.size() );
+        assertEquals( "deabcdefghA", objects.get( 0 ).getUid() );
+        assertEquals( "deabcdefghB", objects.get( 1 ).getUid() );
+        assertEquals( "deabcdefghC", objects.get( 2 ).getUid() );
+        assertEquals( "deabcdefghD", objects.get( 3 ).getUid() );
+        assertEquals( "deabcdefghE", objects.get( 4 ).getUid() );
+        assertEquals( "deabcdefghF", objects.get( 5 ).getUid() );
+    }
+
+    @Test
+    public void getLikeQueryEnd()
+    {
+        Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+        query.setObjects( dataElements );
+        query.add( Restrictions.like( "name", "ElementE", MatchMode.END ) );
+        List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+        assertEquals( 1, objects.size() );
+        assertEquals( "deabcdefghE", objects.get( 0 ).getUid() );
+    }
+
+    @Test
     public void getGtQuery()
     {
         Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );