use of org.hisp.dhis.feedback.ObjectReport in project dhis2-core by dhis2.
the class ObjectBundleServiceAttributesTest method testValidateMetadataAttributeValuesMandatoryFromPayload.
@Test
public void testValidateMetadataAttributeValuesMandatoryFromPayload() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/metadata_with_mandatory_attributes_from_payload_only.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.VALIDATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validationReport = objectBundleValidationService.validate(bundle);
List<ObjectReport> objectReports = validationReport.getObjectReports(DataElement.class);
assertFalse(objectReports.isEmpty());
assertEquals(4, objectReports.size());
objectReports.forEach(objectReport -> assertEquals(1, objectReport.getErrorReports().size()));
}
use of org.hisp.dhis.feedback.ObjectReport in project dhis2-core by dhis2.
the class ObjectBundleReportTest method createTypeReport.
private TypeReport createTypeReport(Class<?> mainKlass, Class<?> errorKlass) {
ObjectReport objectReport0 = new ObjectReport(mainKlass, 0);
ObjectReport objectReport1 = new ObjectReport(mainKlass, 1);
ObjectReport objectReport2 = new ObjectReport(mainKlass, 2);
objectReport0.addErrorReport(new ErrorReport(errorKlass, ErrorCode.E3000, "admin", errorKlass.getSimpleName()));
objectReport1.addErrorReport(new ErrorReport(errorKlass, ErrorCode.E3000, "admin", errorKlass.getSimpleName()));
objectReport2.addErrorReport(new ErrorReport(errorKlass, ErrorCode.E3000, "admin", errorKlass.getSimpleName()));
TypeReport typeReport = new TypeReport(mainKlass);
typeReport.addObjectReport(objectReport0);
typeReport.addObjectReport(objectReport1);
typeReport.addObjectReport(objectReport2);
return typeReport;
}
Aggregations