← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2773: Fixed test error in mappingservice

 

------------------------------------------------------------
revno: 2773
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-01-27 19:30:34 +0100
message:
  Fixed test error in mappingservice
modified:
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.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-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2011-01-26 00:07:38 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2011-01-27 18:30:34 +0000
@@ -32,6 +32,7 @@
 import org.hibernate.Criteria;
 import org.hibernate.Session;
 import org.hibernate.SessionFactory;
+import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.mapping.MapLayer;
 import org.hisp.dhis.mapping.MapLegend;
@@ -238,7 +239,9 @@
 
         Criteria criteria = session.createCriteria( MapView.class );
         
-        criteria.add( Restrictions.or( Restrictions.eq( "user", user ), Restrictions.isNull( "user" ) ) );
+        Criterion nullUser = Restrictions.isNull( "user" );
+        
+        criteria.add( user != null ? Restrictions.or( Restrictions.eq( "user", user ), nullUser ) : nullUser );
 
         return criteria.list();
     }

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2011-01-26 00:07:38 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2011-01-27 18:30:34 +0000
@@ -52,7 +52,6 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.user.User;
 import org.junit.Test;
 
 /**
@@ -335,7 +334,7 @@
     @Test
     public void testAddGetMapView()
     {
-        MapView mapView = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView = new MapView( "MapViewA", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
             MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
@@ -352,7 +351,7 @@
     @Test
     public void testGetDeleteMapViewByName()
     {
-        MapView mapView = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView = new MapView( "MapViewA", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
             MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
@@ -369,12 +368,12 @@
     @Test
     public void testGetAllMapViews()
     {
-        MapView mapView1 = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView1 = new MapView( "MapViewA", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
             MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
 
-        MapView mapView2 = new MapView( "MapViewB", new User(), OrganisationUnit.FEATURETYPE_POLYGON,
+        MapView mapView2 = new MapView( "MapViewB", null, OrganisationUnit.FEATURETYPE_POLYGON,
             MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
             organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
@@ -389,18 +388,18 @@
     @Test
     public void testGetMapViewsByFeatureType()
     {
-        MapView mapView1 = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView1 = new MapView( "MapViewA", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
             MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
 
-        MapView mapView2 = new MapView( "MapViewB", new User(), OrganisationUnit.FEATURETYPE_POLYGON,
+        MapView mapView2 = new MapView( "MapViewB", null, OrganisationUnit.FEATURETYPE_POLYGON,
             MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
             organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
             "2", "2", 1 );
 
-        MapView mapView3 = new MapView( "MapViewC", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView3 = new MapView( "MapViewC", null, OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
             organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,