Search in sources :

Example 1 with JsonObjectReport

use of org.hisp.dhis.webapi.json.domain.JsonObjectReport in project dhis2-core by dhis2.

the class WebClientUtils method assertError.

/**
 * Assumes the {@link org.hisp.dhis.webapi.json.domain.JsonError} has a
 * {@link org.hisp.dhis.webapi.json.domain.JsonTypeReport} containing a
 * single {@link org.hisp.dhis.webapi.json.domain.JsonErrorReport} with the
 * expected properties.
 *
 * @param expectedCode The code the single error is expected to have
 * @param expectedMessage The message the single error is expected to have
 * @param actual the actual error from the {@link HttpResponse}
 */
public static void assertError(ErrorCode expectedCode, String expectedMessage, JsonError actual) {
    JsonList<JsonObjectReport> reports = actual.getTypeReport().getObjectReports();
    assertEquals(1, reports.size());
    JsonList<JsonErrorReport> errors = reports.get(0).getErrorReports();
    assertEquals(1, errors.size());
    JsonErrorReport error = errors.get(0);
    assertEquals(expectedCode, error.getErrorCode());
    assertEquals(expectedMessage, error.getMessage());
}
Also used : JsonObjectReport(org.hisp.dhis.webapi.json.domain.JsonObjectReport) JsonErrorReport(org.hisp.dhis.webapi.json.domain.JsonErrorReport)

Aggregations

JsonErrorReport (org.hisp.dhis.webapi.json.domain.JsonErrorReport)1 JsonObjectReport (org.hisp.dhis.webapi.json.domain.JsonObjectReport)1