← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7784: Sqlview unit test - Fixed.

 

------------------------------------------------------------
revno: 7784
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-31 16:51:30 +0700
message:
  Sqlview unit test - Fixed.
modified:
  dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.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-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java	2012-07-21 13:43:46 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/sqlview/SqlViewServiceTest.java	2012-07-31 09:51:30 +0000
@@ -35,8 +35,7 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.DhisSpringTest;
-import org.junit.Ignore;
+import org.hisp.dhis.DhisTest;
 import org.junit.Test;
 
 /**
@@ -44,7 +43,7 @@
  * @version $Id$
  */
 public class SqlViewServiceTest
-    extends DhisSpringTest
+    extends DhisTest
 {
     private SqlViewService sqlViewService;
 
@@ -57,8 +56,7 @@
         + "GROUP BY _icgss.indicatorid;";
 
     protected static final String SQL4 = "SELECT de.name, dv.sourceid, dv.value, p.startdate "
-        + "FROM dataelement AS de, datavalue AS dv, period AS p " 
-        + "WHERE de.dataelementid=dv.dataelementid "
+        + "FROM dataelement AS de, datavalue AS dv, period AS p " + "WHERE de.dataelementid=dv.dataelementid "
         + "AND dv.periodid=p.periodid LIMIT 10";
 
     @Override
@@ -66,7 +64,7 @@
     {
         sqlViewService = (SqlViewService) getBean( SqlViewService.ID );
     }
-    
+
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
@@ -83,7 +81,6 @@
     // -------------------------------------------------------------------------
 
     @Test
-    @Ignore //FIXME
     public void testAddSqlView()
     {
         SqlView sqlViewA = createSqlView( 'A', SQL1 );
@@ -100,6 +97,9 @@
 
         assertEquals( idB, sqlViewB.getId() );
         assertEq( 'B', sqlViewB, SQL2 );
+
+        sqlViewService.deleteSqlView( sqlViewA );
+        sqlViewService.deleteSqlView( sqlViewB );
     }
 
     @Test
@@ -120,6 +120,8 @@
         sqlView = sqlViewService.getSqlView( id );
 
         assertEquals( sqlView.getName(), "SqlViewC" );
+
+        sqlViewService.deleteSqlView( sqlView );
     }
 
     @Test
@@ -158,6 +160,9 @@
         assertEquals( sqlViewService.getSqlView( "SqlViewA" ).getId(), idA );
         assertEquals( sqlViewService.getSqlView( "SqlViewB" ).getId(), idB );
         assertNull( sqlViewService.getSqlView( "SqlViewC" ) );
+
+        sqlViewService.deleteSqlView( sqlViewA );
+        sqlViewService.deleteSqlView( sqlViewB );
     }
 
     @Test
@@ -179,11 +184,15 @@
         assertTrue( sqlViews.contains( sqlViewB ) );
         assertTrue( sqlViews.contains( sqlViewC ) );
         assertTrue( !sqlViews.contains( sqlViewD ) );
+
+        sqlViewService.deleteSqlView( sqlViewA );
+        sqlViewService.deleteSqlView( sqlViewB );
+        sqlViewService.deleteSqlView( sqlViewC );
     }
 
     @Test
     public void testMakeUpForQueryStatement()
-    {
+    {        
         SqlView sqlViewA = createSqlView( 'A', SQL1 );
 
         sqlViewA.setSqlQuery( sqlViewService.makeUpForQueryStatement( sqlViewA.getSqlQuery() ) );
@@ -195,11 +204,13 @@
         SqlView sqlViewB = sqlViewService.getSqlView( idA );
 
         assertEq( 'A', sqlViewB, "SELECT * FROM _categorystructure;" );
+
+        sqlViewService.deleteSqlView( sqlViewService.getSqlView( idA ) );
     }
 
     @Test
     public void testSetUpViewTableName()
-    {
+    {        
         SqlView sqlViewC = createSqlView( 'C', SQL3 );
         SqlView sqlViewD = createSqlView( 'D', SQL4 );
 
@@ -210,7 +221,7 @@
 
     @Test
     public void testGetAllSqlViewNames()
-    {
+    {        
         SqlView sqlViewA = createSqlView( 'A', SQL4 );
         SqlView sqlViewB = createSqlView( 'B', SQL4 );
         SqlView sqlViewC = createSqlView( 'C', SQL4 );
@@ -224,5 +235,15 @@
         boolean flag = sqlViewService.createAllViewTables();
 
         assertTrue( flag );
+
+        sqlViewService.dropViewTable( sqlViewA.getViewName() );
+        sqlViewService.dropViewTable( sqlViewB.getViewName() );
+        sqlViewService.dropViewTable( sqlViewC.getViewName() );
+        sqlViewService.dropViewTable( sqlViewD.getViewName() );
+        
+        sqlViewService.deleteSqlView( sqlViewA );
+        sqlViewService.deleteSqlView( sqlViewB );
+        sqlViewService.deleteSqlView( sqlViewC );
+        sqlViewService.deleteSqlView( sqlViewD );
     }
 }