dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13802
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4527: Unit test reflecting the non-uniqueness of codes
------------------------------------------------------------
revno: 4527
committer: Bob Jolliffe bobjolliffe@xxxxxxxxx
branch nick: dhis2
timestamp: Tue 2011-09-06 10:21:23 +0100
message:
Unit test reflecting the non-uniqueness of codes
modified:
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.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/dataelement/DataElementServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java 2011-09-05 23:27:47 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java 2011-09-06 09:21:23 +0000
@@ -178,11 +178,19 @@
{
DataElement dataElementA = createDataElement( 'A' );
DataElement dataElementB = createDataElement( 'B' );
+ DataElement dataElementC1 = createDataElement( 'C' );
+ DataElement dataElementC2 = createDataElement( 'D' );
+
dataElementA.setCode( "codeA");
dataElementB.setCode( "codeB");
+ dataElementC1.setCode( "codeC");
+ dataElementC2.setCode( "codeC");
+
int idA = dataElementService.addDataElement( dataElementA );
int idB = dataElementService.addDataElement( dataElementB );
+ int idC1 = dataElementService.addDataElement( dataElementC1 );
+ int idC2 = dataElementService.addDataElement( dataElementC2 );
dataElementA = dataElementService.getDataElementByCode( "codeA" );
assertNotNull( dataElementA );
@@ -194,8 +202,13 @@
assertEquals( idB, dataElementB.getId() );
assertEquals( "DataElementB", dataElementB.getName() );
- DataElement dataElementC = dataElementService.getDataElementByCode( "codeC" );
- assertNull( dataElementC );
+ try {
+ dataElementService.getDataElementByCode( "codeC" );
+ assertEquals("Should have thrown exception","not thrown");
+ } catch (org.hibernate.NonUniqueResultException e ) {}
+
+ DataElement dataElementE = dataElementService.getDataElementByCode( "codeE" );
+ assertNull(dataElementE);
}
@Test