dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37752
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19286: more tests for QueryServiceTest
------------------------------------------------------------
revno: 19286
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-06-04 12:24:23 +0700
message:
more tests for QueryServiceTest
modified:
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.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/QueryServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java 2015-06-04 05:18:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java 2015-06-04 05:24:23 +0000
@@ -525,12 +525,51 @@
}
@Test
+ public void testNumberTypeNumber()
+ {
+ createDataElements();
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+
+ Disjunction disjunction = query.disjunction();
+ disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_NUMBER ) );
+ query.add( disjunction );
+
+ Result result = queryService.query( query );
+
+ assertEquals( 2, result.size() );
+
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghA" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghD" ) );
+ }
+
+ @Test
public void testNumberTypeBoolOrInt()
{
createDataElements();
Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
Disjunction disjunction = query.disjunction();
+ disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_BOOL ) );
+ disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_INT ) );
+ query.add( disjunction );
+
+ Result result = queryService.query( query );
+
+ assertEquals( 4, result.size() );
+
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghB" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghC" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghE" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghF" ) );
+ }
+
+ @Test
+ public void testNumberTypeBoolOrIntOrNumber()
+ {
+ createDataElements();
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+
+ Disjunction disjunction = query.disjunction();
disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_NUMBER ) );
disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_BOOL ) );
disjunction.add( Restrictions.eq( "numberType", DataElement.VALUE_TYPE_INT ) );
@@ -539,6 +578,13 @@
Result result = queryService.query( query );
assertEquals( 6, result.size() );
+
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghA" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghB" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghC" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghD" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghE" ) );
+ assertTrue( collectionContainsUid( result.getItems(), "deabcdefghF" ) );
}
@Test