← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20264: Analytics, test

 

------------------------------------------------------------
revno: 20264
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-21 15:21:34 +0200
message:
  Analytics, test
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.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-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java	2015-09-21 12:51:27 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java	2015-09-21 13:21:34 +0000
@@ -51,6 +51,8 @@
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementDomain;
+import org.hisp.dhis.dataelement.DataElementGroup;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
@@ -104,6 +106,12 @@
     
     private OrganisationUnitGroupSet ouGroupSetA;
     
+    private DataElementGroup deGroupA;
+    private DataElementGroup deGroupB;
+    private DataElementGroup deGroupC;
+    
+    private DataElementGroupSet deGroupSetA;
+    
     private PeriodType monthly = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
     
     @Autowired
@@ -185,11 +193,7 @@
         ouGroupA = createOrganisationUnitGroup( 'A' );
         ouGroupB = createOrganisationUnitGroup( 'B' );
         ouGroupC = createOrganisationUnitGroup( 'C' );
-        
-        ouGroupA.setGroupSet( ouGroupSetA );
-        ouGroupB.setGroupSet( ouGroupSetA );
-        ouGroupC.setGroupSet( ouGroupSetA );
-        
+                
         ouGroupA.addOrganisationUnit( ouA );
         ouGroupA.addOrganisationUnit( ouB );
         ouGroupA.addOrganisationUnit( ouC );
@@ -198,12 +202,39 @@
         organisationUnitGroupService.addOrganisationUnitGroup( ouGroupB );
         organisationUnitGroupService.addOrganisationUnitGroup( ouGroupC );
         
-        ouGroupSetA.getOrganisationUnitGroups().add( ouGroupA );
-        ouGroupSetA.getOrganisationUnitGroups().add( ouGroupB );
-        ouGroupSetA.getOrganisationUnitGroups().add( ouGroupC );
+        ouGroupSetA.addOrganisationUnitGroup( ouGroupA );
+        ouGroupSetA.addOrganisationUnitGroup( ouGroupB );
+        ouGroupSetA.addOrganisationUnitGroup( ouGroupC );
         
         organisationUnitGroupService.updateOrganisationUnitGroupSet( ouGroupSetA );
 
+        deGroupSetA = createDataElementGroupSet( 'A' );
+        
+        dataElementService.addDataElementGroupSet( deGroupSetA );
+        
+        deGroupA = createDataElementGroup( 'A' );
+        deGroupB = createDataElementGroup( 'B' );
+        deGroupC = createDataElementGroup( 'C' );
+        
+        deGroupA.setGroupSet( deGroupSetA );
+        deGroupB.setGroupSet( deGroupSetA );
+        deGroupC.setGroupSet( deGroupSetA );
+        
+        deGroupA.setGroupSet( deGroupSetA );
+        deGroupA.addDataElement( deA );
+        deGroupA.addDataElement( deB );
+        deGroupA.addDataElement( deC );
+                
+        dataElementService.addDataElementGroup( deGroupA );
+        dataElementService.addDataElementGroup( deGroupB );
+        dataElementService.addDataElementGroup( deGroupC );
+        
+        deGroupSetA.addDataElementGroup( deGroupA );
+        deGroupSetA.addDataElementGroup( deGroupB );
+        deGroupSetA.addDataElementGroup( deGroupC );
+        
+        dataElementService.updateDataElementGroupSet( deGroupSetA );
+        
         // ---------------------------------------------------------------------
         // Mock injection
         // ---------------------------------------------------------------------
@@ -308,6 +339,21 @@
         assertEquals( ouGroupSetA.getName(), actual.getDisplayName() );
         assertEquals( items, actual.getItems() );  
     }
+
+    @Test
+    public void testGetDimensionDataElementGroupSet()
+    {
+        List<NameableObject> items = Lists.newArrayList( deGroupA, deGroupB );
+        
+        List<String> itemUids = IdentifiableObjectUtils.getUids( items );
+        
+        DimensionalObject actual = analyticsService.getDimension( deGroupSetA.getUid(), itemUids, null, null, null, false );
+        
+        assertEquals( deGroupSetA.getUid(), actual.getDimension() );
+        assertEquals( DimensionType.DATAELEMENT_GROUPSET, actual.getDimensionType() );
+        assertEquals( deGroupSetA.getName(), actual.getDisplayName() );
+        assertEquals( items, actual.getItems() );  
+    }
     
     @Test
     public void testGetFromUrlA()