← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21798: test for getting refs by CODE

 

------------------------------------------------------------
revno: 21798
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-01-22 12:28:36 +0700
message:
  test for getting refs by CODE
modified:
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/preheat/PreheatServiceTest.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/preheat/PreheatServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/preheat/PreheatServiceTest.java	2016-01-22 05:01:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/preheat/PreheatServiceTest.java	2016-01-22 05:28:36 +0000
@@ -149,4 +149,43 @@
         assertTrue( references.get( DataElement.class ).contains( de3.getUid() ) );
         assertEquals( user.getUid(), references.get( User.class ).get( 0 ) );
     }
+
+    @Test
+    public void testScanReferenceCodeDEG()
+    {
+        DataElementGroup dataElementGroup = new DataElementGroup( "DataElementGroupA" );
+        dataElementGroup.setAutoFields();
+
+        DataElement de1 = new DataElement( "DataElement1" );
+        DataElement de2 = new DataElement( "DataElement1" );
+        DataElement de3 = new DataElement( "DataElement1" );
+
+        de1.setAutoFields();
+        de1.setCode( "DataElementCode1" );
+        de2.setAutoFields();
+        de2.setCode( "DataElementCode2" );
+        de3.setAutoFields();
+        de3.setCode( "DataElementCode3" );
+
+        User user = new User();
+        user.setAutoFields();
+
+        dataElementGroup.addDataElement( de1 );
+        dataElementGroup.addDataElement( de2 );
+        dataElementGroup.addDataElement( de3 );
+
+        dataElementGroup.setUser( user );
+
+        Map<Class<? extends IdentifiableObject>, List<String>> references = preheatService.scanObjectForReferences( dataElementGroup, PreheatIdentifier.CODE );
+
+        assertTrue( references.containsKey( DataElement.class ) );
+        assertTrue( references.containsKey( User.class ) );
+
+        assertEquals( 3, references.get( DataElement.class ).size() );
+        assertTrue( references.get( User.class ).isEmpty() );
+
+        assertTrue( references.get( DataElement.class ).contains( de1.getCode() ) );
+        assertTrue( references.get( DataElement.class ).contains( de2.getCode() ) );
+        assertTrue( references.get( DataElement.class ).contains( de3.getCode() ) );
+    }
 }