← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14314: enabled registration-multi-event-service tests again, flushes hibernate session so that sql to ge...

 

------------------------------------------------------------
revno: 14314
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-03-20 14:46:11 +0100
message:
  enabled registration-multi-event-service tests again, flushes hibernate session so that sql to get events don't fail
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.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-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	2014-03-19 17:31:43 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java	2014-03-20 13:46:11 +0000
@@ -28,14 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-import java.util.HashSet;
-
 import org.hamcrest.CoreMatchers;
+import org.hibernate.SessionFactory;
 import org.hisp.dhis.DhisSpringTest;
-import org.hisp.dhis.DhisTest;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dxf2.events.enrollment.Enrollment;
@@ -58,6 +53,11 @@
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.HashSet;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -79,6 +79,9 @@
     @Autowired
     private EnrollmentService enrollmentService;
 
+    @Autowired
+    private SessionFactory sessionFactory;
+
     private org.hisp.dhis.trackedentity.TrackedEntityInstance maleA;
 
     private org.hisp.dhis.trackedentity.TrackedEntityInstance maleB;
@@ -109,7 +112,7 @@
     {
         identifiableObjectManager = (IdentifiableObjectManager) getBean( IdentifiableObjectManager.ID );
         userService = (UserService) getBean( UserService.ID );
-        
+
         organisationUnitA = createOrganisationUnit( 'A' );
         organisationUnitB = createOrganisationUnit( 'B' );
         identifiableObjectManager.save( organisationUnitA );
@@ -250,18 +253,15 @@
         importSummary = eventService.addEvent( event );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
-        // ERROR
-        // assertEquals( 2, eventService.getEvents( programA, organisationUnitA ).getEvents().size() );
-        assertEquals( 1, eventService.getEvents( programA, organisationUnitA ).getEvents().size() );
-
-        event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(),
-            trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementB.getUid() );
-        importSummary = eventService.addEvent( event );
-        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
-
-        // ERROR
-        // assertEquals( 3, eventService.getEvents( programA, organisationUnitA ).getEvents().size() );
+        sessionFactory.getCurrentSession().flush();
         assertEquals( 2, eventService.getEvents( programA, organisationUnitA ).getEvents().size() );
+
+        event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(),
+            trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementB.getUid() );
+        importSummary = eventService.addEvent( event );
+        assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
+
+        assertEquals( 3, eventService.getEvents( programA, organisationUnitA ).getEvents().size() );
     }
 
     @Test
@@ -281,9 +281,8 @@
         importSummary = eventService.addEvent( event );
         assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() );
 
-        // ERROR
-        // assertEquals( 2, eventService.getEvents( programA, organisationUnitA ).getEvents().size() );
-        assertEquals( 1, eventService.getEvents( programA, organisationUnitA ).getEvents().size() );
+        sessionFactory.getCurrentSession().flush();
+        assertEquals( 2, eventService.getEvents( programA, organisationUnitA ).getEvents().size() );
 
         event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(),
             trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementB.getUid() );