Search in sources :

Example 26 with ObjectReport

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()));
}
Also used : ObjectBundleValidationReport(org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport) List(java.util.List) ObjectReport(org.hisp.dhis.feedback.ObjectReport) ClassPathResource(org.springframework.core.io.ClassPathResource) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 27 with ObjectReport

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;
}
Also used : ErrorReport(org.hisp.dhis.feedback.ErrorReport) TypeReport(org.hisp.dhis.feedback.TypeReport) ObjectReport(org.hisp.dhis.feedback.ObjectReport)

Aggregations

ObjectReport (org.hisp.dhis.feedback.ObjectReport)27 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)20 ErrorReport (org.hisp.dhis.feedback.ErrorReport)16 TypeReport (org.hisp.dhis.feedback.TypeReport)16 PreheatErrorReport (org.hisp.dhis.preheat.PreheatErrorReport)13 List (java.util.List)7 User (org.hisp.dhis.user.User)7 DhisSpringTest (org.hisp.dhis.DhisSpringTest)6 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)6 Test (org.junit.Test)6 ClassPathResource (org.springframework.core.io.ClassPathResource)6 ArrayList (java.util.ArrayList)5 ImportReport (org.hisp.dhis.dxf2.metadata.feedback.ImportReport)3 WebMessage (org.hisp.dhis.dxf2.webmessage.WebMessage)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 HashMap (java.util.HashMap)2 DeletedObjectQuery (org.hisp.dhis.deletedobject.DeletedObjectQuery)2 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)2 ErrorCode (org.hisp.dhis.feedback.ErrorCode)2 CreateAccessDeniedException (org.hisp.dhis.hibernate.exception.CreateAccessDeniedException)2