dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43631
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22119: minor test fixes
------------------------------------------------------------
revno: 22119
committer: Morten Olav Hansen <morten@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-03-03 09:03:29 +0700
message:
minor test fixes
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java
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/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java 2016-03-03 01:20:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata2/objectbundle/DefaultObjectBundleService.java 2016-03-03 02:03:29 +0000
@@ -192,20 +192,19 @@
List<List<PreheatErrorReport>> referenceErrors = preheatService.checkReferences( bundle.getObjects().get( klass ), bundle.getPreheat(), bundle.getPreheatIdentifier() );
referenceErrors.forEach( objectBundleValidation::addErrorReports ); // collapsing for now, we might want to give pr object ref list
-
- List<List<ErrorReport>> validationErrorReports = new ArrayList<>();
-
- for ( IdentifiableObject object : bundle.getObjects().get( klass ) )
+ Iterator<IdentifiableObject> iterator = bundle.getObjects().get( klass ).iterator();
+
+ while ( iterator.hasNext() )
{
- List<ErrorReport> validate = schemaValidator.validate( object );
+ IdentifiableObject object = iterator.next();
+ List<ErrorReport> objectValidation = schemaValidator.validate( object );
- if ( !validate.isEmpty() )
+ if ( !objectValidation.isEmpty() )
{
- validationErrorReports.add( validate );
+ objectBundleValidation.addErrorReports( objectValidation );
+ iterator.remove();
}
}
-
- validationErrorReports.forEach( objectBundleValidation::addErrorReports );
}
bundle.setObjectBundleStatus( ObjectBundleStatus.VALIDATED );
=== 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-03-03 01:20:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/metadata2/objectbundle/ObjectBundleServiceTest.java 2016-03-03 02:03:29 +0000
@@ -276,8 +276,9 @@
ObjectBundle bundle = objectBundleService.create( params );
ObjectBundleValidation validate = objectBundleService.validate( bundle );
- assertEquals( 1, validate.getErrorReports( DataElement.class ).size() );
- assertEquals( 2, bundle.getObjects().get( DataElement.class ).size() );
+ assertEquals( 1, validate.getErrorReports( DataElement.class ).get( ErrorCode.E5000 ).size() );
+ assertFalse( validate.getErrorReports( DataElement.class ).get( ErrorCode.E4000 ).isEmpty() );
+ assertEquals( 0, bundle.getObjects().get( DataElement.class ).size() );
}
@Test