dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43192
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21941: testing of object bundle validation with existing valid references
------------------------------------------------------------
revno: 21941
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-02-11 13:53:05 +0700
message:
testing of object bundle validation with existing valid references
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleServiceTest.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/metadata2/objectbundle/ObjectBundleServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleServiceTest.java 2016-02-11 05:40:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleServiceTest.java 2016-02-11 06:53:05 +0000
@@ -159,6 +159,55 @@
}
}
+ @Test
+ public void testPreheatValidationsWithCatCombo() throws IOException
+ {
+ Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(
+ new ClassPathResource( "dxf2/de_validate1.json" ).getInputStream(), RenderFormat.JSON );
+
+ DataElementCategoryCombo categoryCombo = manager.getByName( DataElementCategoryCombo.class, "default" );
+ categoryCombo.setUid( "p0KPaWEg3cf" );
+ manager.update( categoryCombo );
+
+ OptionSet optionSet = new OptionSet( "OptionSet: pQYCiuosBnZ" );
+ optionSet.setAutoFields();
+ optionSet.setUid( "pQYCiuosBnZ" );
+ manager.save( optionSet );
+
+ ObjectBundleParams params = new ObjectBundleParams();
+ params.setObjectBundleMode( ObjectBundleMode.VALIDATE );
+ params.setObjects( metadata );
+
+ ObjectBundle bundle = objectBundleService.create( params );
+ ObjectBundleValidation validate = objectBundleService.validate( bundle );
+ assertFalse( validate.getPreheatValidations().isEmpty() );
+ List<PreheatValidation> dataElementValidations = validate.getPreheatValidations().get( DataElement.class );
+ assertFalse( dataElementValidations.isEmpty() );
+
+ for ( PreheatValidation preheatValidation : dataElementValidations )
+ {
+ assertFalse( preheatValidation.getInvalidReferences().isEmpty() );
+
+ for ( InvalidReference invalidReference : preheatValidation.getInvalidReferences() )
+ {
+ assertEquals( PreheatIdentifier.UID, invalidReference.getIdentifier() );
+
+ if ( DataElementCategoryCombo.class.isInstance( invalidReference.getRefObject() ) )
+ {
+ assertFalse( true );
+ }
+ else if ( User.class.isInstance( invalidReference.getRefObject() ) )
+ {
+ assertEquals( "GOLswS44mh8", invalidReference.getRefObject().getUid() );
+ }
+ else if ( OptionSet.class.isInstance( invalidReference.getRefObject() ) )
+ {
+ assertFalse( true );
+ }
+ }
+ }
+ }
+
private void defaultSetup()
{
DataElement de1 = createDataElement( 'A' );