dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41218
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20985: minor
------------------------------------------------------------
revno: 20985
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-09 14:08:19 +0700
message:
minor
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 06:56:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/InMemoryQueryEngineTest.java 2015-11-09 07:08:19 +0000
@@ -299,6 +299,113 @@
}
@Test
+ public void testDateRange()
+ {
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+ query.setObjects( dataElements );
+
+ query.add( Restrictions.ge( "created", Year.parseYear( "2002" ).getStart() ) );
+ query.add( Restrictions.le( "created", Year.parseYear( "2004" ).getStart() ) );
+
+ List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+ assertEquals( 3, objects.size() );
+
+ assertTrue( collectionContainsUid( objects, "deabcdefghB" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghC" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
+ }
+
+ @Test
+ public void testIsNull()
+ {
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+ query.setObjects( dataElements );
+ query.add( Restrictions.isNull( "categoryCombo" ) );
+
+ List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+ assertEquals( 6, objects.size() );
+
+ assertTrue( collectionContainsUid( objects, "deabcdefghA" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghB" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghC" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghE" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghF" ) );
+ }
+
+ @Test
+ public void testIsNotNull()
+ {
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+ query.setObjects( dataElements );
+ query.add( Restrictions.isNotNull( "categoryCombo" ) );
+
+ List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+ assertEquals( 0, objects.size() );
+ }
+
+ @Test
+ @Ignore
+ public void testDateRangeWithConjunction()
+ {
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+ query.setObjects( dataElements );
+
+ Conjunction conjunction = query.conjunction();
+ conjunction.add( Restrictions.ge( "created", Year.parseYear( "2002" ).getStart() ) );
+ conjunction.add( Restrictions.le( "created", Year.parseYear( "2004" ).getStart() ) );
+ query.add( conjunction );
+
+ List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+ assertEquals( 3, objects.size() );
+
+ assertTrue( collectionContainsUid( objects, "deabcdefghB" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghC" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
+ }
+
+ @Test
+ @Ignore
+ public void testDoubleEqConjunction()
+ {
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+ query.setObjects( dataElements );
+
+ Conjunction conjunction = query.conjunction();
+ conjunction.add( Restrictions.eq( "id", "deabcdefghD" ) );
+ conjunction.add( Restrictions.eq( "id", "deabcdefghF" ) );
+ query.add( conjunction );
+
+ List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+ assertEquals( 0, objects.size() );
+ }
+
+ @Test
+ @Ignore
+ public void testDoubleEqDisjunction()
+ {
+ Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
+ query.setObjects( dataElements );
+
+ Disjunction disjunction = query.disjunction();
+ disjunction.add( Restrictions.eq( "id", "deabcdefghD" ) );
+ disjunction.add( Restrictions.eq( "id", "deabcdefghF" ) );
+ query.add( disjunction );
+
+ List<? extends IdentifiableObject> objects = queryEngine.query( query );
+
+ assertEquals( 2, objects.size() );
+
+ assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
+ assertTrue( collectionContainsUid( objects, "deabcdefghF" ) );
+ }
+
+ @Test
@Ignore
public void sortNameDesc()
{
@@ -381,111 +488,4 @@
assertEquals( "deabcdefghE", objects.get( 4 ).getUid() );
assertEquals( "deabcdefghF", objects.get( 5 ).getUid() );
}
-
- @Test
- @Ignore
- public void testDoubleEqConjunction()
- {
- Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
- query.setObjects( dataElements );
-
- Conjunction conjunction = query.conjunction();
- conjunction.add( Restrictions.eq( "id", "deabcdefghD" ) );
- conjunction.add( Restrictions.eq( "id", "deabcdefghF" ) );
- query.add( conjunction );
-
- List<? extends IdentifiableObject> objects = queryEngine.query( query );
-
- assertEquals( 0, objects.size() );
- }
-
- @Test
- @Ignore
- public void testDoubleEqDisjunction()
- {
- Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
- query.setObjects( dataElements );
-
- Disjunction disjunction = query.disjunction();
- disjunction.add( Restrictions.eq( "id", "deabcdefghD" ) );
- disjunction.add( Restrictions.eq( "id", "deabcdefghF" ) );
- query.add( disjunction );
-
- List<? extends IdentifiableObject> objects = queryEngine.query( query );
-
- assertEquals( 2, objects.size() );
-
- assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghF" ) );
- }
-
- @Test
- public void testDateRange()
- {
- Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
- query.setObjects( dataElements );
-
- query.add( Restrictions.ge( "created", Year.parseYear( "2002" ).getStart() ) );
- query.add( Restrictions.le( "created", Year.parseYear( "2004" ).getStart() ) );
-
- List<? extends IdentifiableObject> objects = queryEngine.query( query );
-
- assertEquals( 3, objects.size() );
-
- assertTrue( collectionContainsUid( objects, "deabcdefghB" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghC" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
- }
-
- @Test
- @Ignore
- public void testDateRangeWithConjunction()
- {
- Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
- query.setObjects( dataElements );
-
- Conjunction conjunction = query.conjunction();
- conjunction.add( Restrictions.ge( "created", Year.parseYear( "2002" ).getStart() ) );
- conjunction.add( Restrictions.le( "created", Year.parseYear( "2004" ).getStart() ) );
- query.add( conjunction );
-
- List<? extends IdentifiableObject> objects = queryEngine.query( query );
-
- assertEquals( 3, objects.size() );
-
- assertTrue( collectionContainsUid( objects, "deabcdefghB" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghC" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
- }
-
- @Test
- public void testIsNull()
- {
- Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
- query.setObjects( dataElements );
- query.add( Restrictions.isNull( "categoryCombo" ) );
-
- List<? extends IdentifiableObject> objects = queryEngine.query( query );
-
- assertEquals( 6, objects.size() );
-
- assertTrue( collectionContainsUid( objects, "deabcdefghA" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghB" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghC" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghD" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghE" ) );
- assertTrue( collectionContainsUid( objects, "deabcdefghF" ) );
- }
-
- @Test
- public void testIsNotNull()
- {
- Query query = Query.from( schemaService.getDynamicSchema( DataElement.class ) );
- query.setObjects( dataElements );
- query.add( Restrictions.isNotNull( "categoryCombo" ) );
-
- List<? extends IdentifiableObject> objects = queryEngine.query( query );
-
- assertEquals( 0, objects.size() );
- }
}