← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16682: fixes for IdentifiableObjectManagerTest

 

------------------------------------------------------------
revno: 16682
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-09-10 12:14:23 +0700
message:
  fixes for IdentifiableObjectManagerTest
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.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	2014-09-09 22:38:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.java	2014-09-10 05:14:23 +0000
@@ -137,9 +137,9 @@
         identifiableObjectManager.save( createDataElement( 'D' ) );
 
         assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortA" ) );
-        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortA" ) );
-        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortA" ) );
-        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortA" ) );
+        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortB" ) );
+        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortC" ) );
+        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortD" ) );
     }
 
     @Test
@@ -232,23 +232,28 @@
         assertEquals( "DataElementD", dataElements.get( 3 ).getName() );
     }
 
-    /**
-     * Fetch all in between creating data elements to avoid equal last updated date.
-     */
     @Test
     public void getAllOrderedLastUpdated()
     {
-        identifiableObjectManager.save( createDataElement( 'A' ) );
-        assertNotNull( identifiableObjectManager.getAllSortedByLastUpdated( DataElement.class ) );
-        
-        identifiableObjectManager.save( createDataElement( 'B' ) );
-        assertNotNull( identifiableObjectManager.getAllSortedByLastUpdated( DataElement.class ) );
-        
-        identifiableObjectManager.save( createDataElement( 'C' ) );
-        assertNotNull( identifiableObjectManager.getAllSortedByLastUpdated( DataElement.class ) );
-        
-        identifiableObjectManager.save( createDataElement( 'D' ) );
-        assertNotNull( identifiableObjectManager.getAllSortedByLastUpdated( DataElement.class ) );
+        DataElement dataElementA = createDataElement( 'A' );
+        DataElement dataElementB = createDataElement( 'B' );
+        DataElement dataElementC = createDataElement( 'C' );
+        DataElement dataElementD = createDataElement( 'D' );
+
+        identifiableObjectManager.save( dataElementA );
+        identifiableObjectManager.save( dataElementB );
+        identifiableObjectManager.save( dataElementC );
+        identifiableObjectManager.save( dataElementD );
+
+        dataElementA.setLastUpdated( new GregorianCalendar( 2011, 0, 1 ).getTime() );
+        dataElementB.setLastUpdated( new GregorianCalendar( 2012, 0, 1 ).getTime() );
+        dataElementC.setLastUpdated( new GregorianCalendar( 2013, 0, 1 ).getTime() );
+        dataElementD.setLastUpdated( new GregorianCalendar( 2014, 0, 1 ).getTime() );
+
+        sessionFactory.getCurrentSession().update( dataElementA );
+        sessionFactory.getCurrentSession().update( dataElementB );
+        sessionFactory.getCurrentSession().update( dataElementC );
+        sessionFactory.getCurrentSession().update( dataElementD );
 
         List<DataElement> dataElements = new ArrayList<>( identifiableObjectManager.getAllSortedByLastUpdated( DataElement.class ) );