← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21865: Fixed a bug in unittests

 

Merge authors:
  Stian Sandvold (stian-sandvold)
------------------------------------------------------------
revno: 21865 [merge]
committer: Stian Sandvold <stian.sandvold@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-02-03 11:28:54 +0100
message:
  Fixed a bug in unittests
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/userkeyjsonvalue/UserKeyJsonValueStoreTest.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/userkeyjsonvalue/UserKeyJsonValueStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/userkeyjsonvalue/UserKeyJsonValueStoreTest.java	2016-02-03 02:17:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/userkeyjsonvalue/UserKeyJsonValueStoreTest.java	2016-02-03 10:14:04 +0000
@@ -30,7 +30,7 @@
 
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.user.User;
-import org.junit.Ignore;
+import org.hisp.dhis.user.UserService;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -41,14 +41,22 @@
 /**
  * @author Stian Sandvold.
  */
-@Ignore
 public class UserKeyJsonValueStoreTest
     extends DhisSpringTest
 {
     @Autowired
     private UserKeyJsonValueStore userKeyJsonValueStore;
 
-    private User user; //  = userService.getAllUsers().get( 0 );
+    @Autowired
+    private UserService injectUserService;
+
+    private User user;
+
+    @Override
+    public void setUpTest() {
+        this.userService = injectUserService;
+        user = createUserAndInjectSecurityContext( true );
+    }
 
     @Test
     public void testAddUserKeyJsonValue()
@@ -74,12 +82,16 @@
         userKeyJsonValueA.setKey( "test_a" );
         userKeyJsonValueA.setUser( user );
 
+        userKeyJsonValueStore.save(userKeyJsonValueA);
+
         UserKeyJsonValue userKeyJsonValueB = new UserKeyJsonValue();
 
         userKeyJsonValueB.setValue( "{}" );
         userKeyJsonValueB.setKey( "test_b" );
         userKeyJsonValueB.setUser( user );
 
+        userKeyJsonValueStore.save(userKeyJsonValueB);
+
         List<String> list = userKeyJsonValueStore.getKeysByUser( user );
 
         assertTrue( list.contains( "test_a" ) );
@@ -87,7 +99,7 @@
     }
 
     @Test
-    public void testAddUserKeyJsonValuesAndGetUserKEyJsonValuesByUser()
+    public void testAddUserKeyJsonValuesAndGetUserKeyJsonValuesByUser()
     {
         UserKeyJsonValue userKeyJsonValueA = new UserKeyJsonValue();
 
@@ -95,12 +107,16 @@
         userKeyJsonValueA.setKey( "test_a" );
         userKeyJsonValueA.setUser( user );
 
+        userKeyJsonValueStore.save(userKeyJsonValueA);
+
         UserKeyJsonValue userKeyJsonValueB = new UserKeyJsonValue();
 
         userKeyJsonValueB.setValue( "{}" );
         userKeyJsonValueB.setKey( "test_b" );
         userKeyJsonValueB.setUser( user );
 
+        userKeyJsonValueStore.save(userKeyJsonValueB);
+
         List<UserKeyJsonValue> list = userKeyJsonValueStore.getUserKeyJsonValueByUser( user );
 
         assertTrue( list.contains( userKeyJsonValueA ) );