← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9083: Made option set tests pass again

 

------------------------------------------------------------
revno: 9083
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-11-20 09:44:23 +0100
message:
  Made option set tests pass again
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/option/OptionServiceTest.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.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/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java	2012-11-20 04:08:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java	2012-11-20 08:44:23 +0000
@@ -65,12 +65,18 @@
     @Override
     public List<String> getOptions( int optionSetId, String key, Integer max )
     {
-        String sql = "select optionvalue from optionset os inner join optionsetmembers as om on os.optionsetid=om.optionsetid "
-            + "where os.optionsetid=" + optionSetId;
+        //TODO Should ideally be cached and go through Hibernate
+        
+        String sql = 
+            "select optionvalue from optionset os " +
+            "inner join optionsetmembers as om on os.optionsetid=om.optionsetid " +
+            "where os.optionsetid=" + optionSetId;
+        
         if ( key != null )
         {
             sql += " and lower(om.optionvalue) like lower('%" + key + "%')";
         }
+        
         sql += " order by sort_order";
 
         if ( max != null )
@@ -79,10 +85,10 @@
         }
         
         List<String> optionValues = new ArrayList<String>();
+        
         optionValues = jdbcTemplate.query( sql, new RowMapper<String>()
         {
-            public String mapRow( ResultSet rs, int rowNum )
-                throws SQLException
+            public String mapRow( ResultSet rs, int rowNum ) throws SQLException
             {
                 return rs.getString( 1 );
             }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/option/OptionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/option/OptionServiceTest.java	2012-11-01 15:15:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/option/OptionServiceTest.java	2012-11-20 08:44:23 +0000
@@ -33,14 +33,14 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.DhisTest;
 import org.junit.Test;
 
 /**
  * @author Lars Helge Overland
  */
 public class OptionServiceTest
-    extends DhisSpringTest
+    extends DhisTest
 {
     private OptionService optionService;
     
@@ -51,6 +51,12 @@
     private OptionSet optionSetC = new OptionSet( "OptionSetC" );
     
     @Override
+    public boolean emptyDatabaseAfterTest()
+    {
+        return true;
+    }
+    
+    @Override
     public void setUpTest()
     {
         optionService = (OptionService) getBean( OptionService.ID );

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java	2012-03-18 12:15:26 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java	2012-11-20 08:44:23 +0000
@@ -144,6 +144,9 @@
         emptyTable( "categorycombo" );
         emptyTable( "dataelementcategory" );
         emptyTable( "dataelementcategoryoption" );
+        
+        emptyTable( "optionsetmembers" );
+        emptyTable( "optionset" );
 
         dropTable( "aggregateddatavalue" );
         dropTable( "aggregatedindicatorvalue" );