← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15063: Rewrote testDeleteDataApprovalLevel test

 

------------------------------------------------------------
revno: 15063
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-28 15:39:25 +0200
message:
  Rewrote testDeleteDataApprovalLevel test
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.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/dataapproval/DataApprovalLevelServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java	2014-04-28 12:45:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java	2014-04-28 13:39:25 +0000
@@ -33,6 +33,7 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
 
 import java.util.HashSet;
 import java.util.List;
@@ -230,45 +231,27 @@
     @Test
     public void testDeleteDataApprovalLevel() throws Exception
     {
-        dataApprovalLevelService.addDataApprovalLevel( level1A, 1 );
-        dataApprovalLevelService.addDataApprovalLevel( level2B, 2 );
-        dataApprovalLevelService.addDataApprovalLevel( level3C, 3 );
-        dataApprovalLevelService.addDataApprovalLevel( level4D, 4 );
-
-        List<DataApprovalLevel> levels = null;
-
-        levels = dataApprovalLevelService.getAllDataApprovalLevels();
-        assertEquals( 4, levels.size() );
-        assertEquals( "1A", levels.get( 0 ).getName() );
-        assertEquals( "2B", levels.get( 1 ).getName() );
-        assertEquals( "3C", levels.get( 2 ).getName() );
-        assertEquals( "4D", levels.get( 3 ).getName() );
+        int id1 = dataApprovalLevelService.addDataApprovalLevel( level1A, 1 );
+        int id2 = dataApprovalLevelService.addDataApprovalLevel( level2B, 2 );
+        int id3 = dataApprovalLevelService.addDataApprovalLevel( level3C, 3 );
+        int id4 = dataApprovalLevelService.addDataApprovalLevel( level4D, 4 );
+
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id1 ) );
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id2 ) );
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id3 ) );
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id4 ) );
 
         dataApprovalLevelService.deleteDataApprovalLevel( level2B );
-
-        levels = dataApprovalLevelService.getAllDataApprovalLevels();
-        assertEquals( 3, levels.size() );
-        assertEquals( "1A", levels.get( 0 ).getName() );
-        assertEquals( "3C", levels.get( 1 ).getName() );
-        assertEquals( "4D", levels.get( 2 ).getName() );
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id1 ) );
+        assertNull( dataApprovalLevelService.getDataApprovalLevel( id2 ) );
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id3 ) );
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id4 ) );
 
         dataApprovalLevelService.deleteDataApprovalLevel( level4D );
-
-        levels = dataApprovalLevelService.getAllDataApprovalLevels();
-        assertEquals( 2, levels.size() );
-        assertEquals( "1A", levels.get( 0 ).getName() );
-        assertEquals( "3C", levels.get( 1 ).getName() );
-
-        dataApprovalLevelService.deleteDataApprovalLevel( level1A );
-
-        levels = dataApprovalLevelService.getAllDataApprovalLevels();
-        assertEquals( 1, levels.size() );
-        assertEquals( "3C", levels.get( 0 ).getName() );
-
-        dataApprovalLevelService.deleteDataApprovalLevel( level3C );
-
-        levels = dataApprovalLevelService.getAllDataApprovalLevels();
-        assertEquals( 0, levels.size() );
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id1 ) );
+        assertNull( dataApprovalLevelService.getDataApprovalLevel( id2 ) );
+        assertNotNull( dataApprovalLevelService.getDataApprovalLevel( id3 ) );
+        assertNull( dataApprovalLevelService.getDataApprovalLevel( id4 ) );
     }
 
     @Test