← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18873: Unit tests

 

------------------------------------------------------------
revno: 18873
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-04-10 09:59:22 +0200
message:
  Unit tests
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.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/expression/ExpressionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java	2015-04-10 06:53:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java	2015-04-10 07:59:22 +0000
@@ -63,6 +63,8 @@
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import com.google.common.collect.Lists;
+
 /**
  * @author Lars Helge Overland
  */
@@ -270,10 +272,58 @@
         
         dataElements = expressionService.getDataElementsInExpression( expressionG );
 
-        assertTrue( dataElements.size() == 3 );
-        assertTrue( dataElements.contains( dataElementA ) );
-        assertTrue( dataElements.contains( dataElementB ) );
-        assertTrue( dataElements.contains( dataElementC ) );
+        assertEquals( 3, dataElements.size() );
+        assertTrue( dataElements.contains( dataElementA ) );
+        assertTrue( dataElements.contains( dataElementB ) );
+        assertTrue( dataElements.contains( dataElementC ) );
+    }
+
+    @Test
+    public void testGetDataElementsInIndicators()
+    {
+        Indicator inA = createIndicator( 'A', null );
+        inA.setNumerator( expressionA );
+        
+        Set<DataElement> dataElements = expressionService.getDataElementsInIndicators( Lists.newArrayList( inA ) );
+
+        assertTrue( dataElements.size() == 2 );
+        assertTrue( dataElements.contains( dataElementA ) );
+        assertTrue( dataElements.contains( dataElementB ) );
+
+        Indicator inG = createIndicator( 'G', null );
+        inG.setNumerator( expressionG );
+        
+        dataElements = expressionService.getDataElementsInIndicators( Lists.newArrayList( inG ) );
+
+        assertEquals( 3, dataElements.size() );
+        assertTrue( dataElements.contains( dataElementA ) );
+        assertTrue( dataElements.contains( dataElementB ) );
+        assertTrue( dataElements.contains( dataElementC ) );
+    }
+
+    @Test
+    public void testGetDataElementTotalsInIndicators()
+    {
+        Indicator inG = createIndicator( 'G', null );
+        inG.setNumerator( expressionG );
+        
+        Set<DataElement> dataElements = expressionService.getDataElementTotalsInIndicators( Lists.newArrayList( inG ) );
+
+        assertEquals( 2, dataElements.size() );
+        assertTrue( dataElements.contains( dataElementB ) );
+        assertTrue( dataElements.contains( dataElementC ) );
+    }
+
+    @Test
+    public void testGetDataElementWithOptionCombosInIndicators()
+    {
+        Indicator inG = createIndicator( 'G', null );
+        inG.setNumerator( expressionG );
+        
+        Set<DataElement> dataElements = expressionService.getDataElementWithOptionCombosInIndicators( Lists.newArrayList( inG ) );
+
+        assertEquals( 1, dataElements.size() );
+        assertTrue( dataElements.contains( dataElementA ) );
     }
 
     @Test