← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18917: Convenience test, removed need for injecting id object manager. ApprovalServiceTest, ignored two ...

 

------------------------------------------------------------
revno: 18917
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-04-15 22:26:30 +0200
message:
  Convenience test, removed need for injecting id object manager. ApprovalServiceTest, ignored two tests.
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/NoRegistrationSingleEventServiceTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.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/common/IdentifiableObjectManagerTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.java	2015-03-26 16:20:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.java	2015-04-15 20:26:30 +0000
@@ -65,7 +65,7 @@
     private DataElementService dataElementService;
 
     @Autowired
-    private IdentifiableObjectManager _identifiableObjectManager;
+    private IdentifiableObjectManager identifiableObjectManager;
 
     @Autowired
     private UserService _userService;
@@ -73,7 +73,6 @@
     @Override
     protected void setUpTest() throws Exception
     {
-        this.identifiableObjectManager = _identifiableObjectManager;
         this.userService = _userService;
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java	2015-04-15 20:14:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java	2015-04-15 20:26:30 +0000
@@ -116,7 +116,7 @@
     private OrganisationUnitService organisationUnitService;
 
     @Autowired
-    protected IdentifiableObjectManager _identifiableObjectManager;
+    protected IdentifiableObjectManager identifiableObjectManager;
 
     @Autowired
     private SystemSettingManager systemSettingManager;
@@ -271,7 +271,6 @@
     @Override
     public void setUpTest() throws Exception
     {
-        identifiableObjectManager = _identifiableObjectManager;
         userService = _userService;
 
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java	2015-04-15 19:28:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java	2015-04-15 20:26:30 +0000
@@ -74,6 +74,8 @@
     extends DhisTest
 {
     private static final String AUTH_APPR_LEVEL = "F_SYSTEM_SETTING";
+    
+    private final static boolean NOT_ACCEPTED = false;
 
     @Autowired
     private DataApprovalService dataApprovalService;
@@ -97,7 +99,7 @@
     private OrganisationUnitService organisationUnitService;
    
     @Autowired 
-    protected IdentifiableObjectManager _identifiableObjectManager;
+    protected IdentifiableObjectManager identifiableObjectManager;
     
     @Autowired
     protected UserService _userService;
@@ -109,8 +111,6 @@
     // Supporting data
     // -------------------------------------------------------------------------
 
-    private final static boolean NOT_ACCEPTED = false;
-
     private DataElementCategoryOptionCombo defaultCombo;
 
     private DataSet dataSetA;
@@ -191,7 +191,6 @@
     @Override
     public void setUpTest() throws Exception
     {
-        identifiableObjectManager = _identifiableObjectManager;
         userService = _userService;
         
         // ---------------------------------------------------------------------
@@ -511,8 +510,8 @@
         assertNull( level );
     }
 
+    @Ignore //TODO enable, fails randomly with DataMayNotBeApprovedException
     @Test
-    @Ignore //TODO enable, fails randomly with DataMayNotBeApprovedException
     public void testAddDuplicateDataApproval() throws Exception
     {
         dataApprovalLevelService.addDataApprovalLevel( level1 );
@@ -535,6 +534,7 @@
         dataApprovalService.approveData( asList( dataApprovalB ) ); // Redundant, so call is ignored.
     }
 
+    @Ignore //TODO enable, fails randomly with DataMayNotBeApprovedException
     @Test
     public void testDeleteDataApproval() throws Exception
     {
@@ -1221,6 +1221,7 @@
         assertFalse( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitF, defaultCombo ).getPermissions().isMayUnapprove());
     }
 
+    @Ignore //Enable this test, fails at line 1270 randomly
     @Test
     public void testMayUnapproveWithAcceptAuthority() throws Exception
     {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java	2015-03-09 09:41:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/QueryServiceTest.java	2015-04-15 20:26:30 +0000
@@ -28,7 +28,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.google.common.collect.Lists;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.Iterator;
+
 import org.hisp.dhis.DhisSpringTest;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.IdentifiableObjectManager;
@@ -40,10 +46,7 @@
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.Collection;
-import java.util.Iterator;
-
-import static org.junit.Assert.*;
+import com.google.common.collect.Lists;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -58,13 +61,7 @@
     private QueryService queryService;
 
     @Autowired
-    private IdentifiableObjectManager _identifiableObjectManager;
-
-    @Override
-    protected void setUpTest() throws Exception
-    {
-        this.identifiableObjectManager = _identifiableObjectManager;
-    }
+    private IdentifiableObjectManager identifiableObjectManager;
 
     private void createDataElements()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/NoRegistrationSingleEventServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/NoRegistrationSingleEventServiceTest.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/NoRegistrationSingleEventServiceTest.java	2015-04-15 20:26:30 +0000
@@ -73,7 +73,7 @@
     private ProgramStageInstanceService programStageInstanceService;
 
     @Autowired
-    private IdentifiableObjectManager _identifiableObjectManager;
+    private IdentifiableObjectManager identifiableObjectManager;
 
     @Autowired
     private UserService _userService;
@@ -87,7 +87,6 @@
     protected void setUpTest() 
         throws Exception
     {
-        identifiableObjectManager = _identifiableObjectManager;
         userService = _userService;
 
         organisationUnitA = createOrganisationUnit( 'A' );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java	2015-04-09 11:03:09 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java	2015-04-15 20:26:30 +0000
@@ -85,7 +85,7 @@
     private SessionFactory sessionFactory;
     
     @Autowired 
-    private IdentifiableObjectManager _identifiableObjectManager;
+    private IdentifiableObjectManager identifiableObjectManager;
     
     @Autowired
     private UserService _userService;
@@ -118,7 +118,6 @@
     protected void setUpTest()
         throws Exception
     {
-        identifiableObjectManager = _identifiableObjectManager;
         userService = _userService;
 
         organisationUnitA = createOrganisationUnit( 'A' );

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java	2015-04-09 11:02:21 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java	2015-04-15 20:26:30 +0000
@@ -83,7 +83,7 @@
     private EnrollmentService enrollmentService;
     
     @Autowired 
-    private IdentifiableObjectManager _identifiableObjectManager;
+    private IdentifiableObjectManager identifiableObjectManager;
     
     @Autowired
     private UserService _userService;
@@ -104,7 +104,6 @@
     @Override
     protected void setUpTest() throws Exception
     {
-        identifiableObjectManager = _identifiableObjectManager;
         userService = _userService;
 
         organisationUnitA = createOrganisationUnit( 'A' );

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2015-04-15 11:58:48 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2015-04-15 20:26:30 +0000
@@ -53,7 +53,6 @@
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.common.DimensionalObject;
-import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.constant.Constant;
 import org.hisp.dhis.dataelement.CategoryOptionGroup;
 import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
@@ -85,12 +84,12 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
 import org.hisp.dhis.programrule.ProgramRule;
 import org.hisp.dhis.programrule.ProgramRuleAction;
 import org.hisp.dhis.programrule.ProgramRuleVariable;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageDataElement;
-import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
 import org.hisp.dhis.relationship.RelationshipType;
 import org.hisp.dhis.sqlview.SqlView;
 import org.hisp.dhis.sqlview.SqlViewType;
@@ -149,8 +148,6 @@
 
     protected UserService userService;
     
-    protected IdentifiableObjectManager identifiableObjectManager;
-
     static
     {
         DateTime dateTime = new DateTime( 1970, 1, 1, 0, 0 );
@@ -1554,7 +1551,6 @@
      */
     protected User createUserAndInjectSecurityContext( Set<OrganisationUnit> organisationUnits, Set<OrganisationUnit> dataViewOrganisationUnits, boolean allAuth, String... auths )
     {
-        Assert.notNull( identifiableObjectManager, "IdentifiableObjectManager must be injected in test" );
         Assert.notNull( userService, "UserService must be injected in test" );
 
         UserAuthorityGroup userAuthorityGroup = new UserAuthorityGroup();
@@ -1573,7 +1569,7 @@
             }
         }
 
-        identifiableObjectManager.save( userAuthorityGroup );
+        userService.addUserAuthorityGroup( userAuthorityGroup );
 
         User user = createUser( 'A' );