Search in sources :

Example 56 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class AbstractDataIntegrityControllerTest method getDetails.

protected final JsonDataIntegrityDetails getDetails(String check) {
    JsonObject content = GET("/dataIntegrity/details?checks={check}&timeout=1000", check).content();
    JsonDataIntegrityDetails details = content.get(check.replace('-', '_'), JsonDataIntegrityDetails.class);
    assertTrue(details.exists(), "check " + check + " did not complete in time or threw an exception");
    assertTrue(details.isObject());
    return details;
}
Also used : JsonDataIntegrityDetails(org.hisp.dhis.webapi.json.domain.JsonDataIntegrityDetails) JsonObject(org.hisp.dhis.jsontree.JsonObject)

Example 57 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class DomainJsonResponseTest method testCustomObjectType.

@Test
void testCustomObjectType() {
    JsonObject response = createJSON("{'user': {'id':'foo'}}");
    assertEquals("foo", response.get("user", JsonUser.class).getId());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 58 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class DomainJsonResponseTest method testErrorSummary_MessageAndErrorReports.

@Test
void testErrorSummary_MessageAndErrorReports() {
    JsonObject response = createJSON("{'message':'my message','response':{'errorReports': [{'errorCode':'E4000','message':'m1'}]}}");
    assertEquals("my message\n" + "  E4000 m1", response.as(JsonError.class).summary());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 59 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class DomainJsonResponseTest method testErrorSummary_MessageAndObjectReports.

@Test
void testErrorSummary_MessageAndObjectReports() {
    JsonObject response = createJSON("{'message':'my message','response':{'objectReports':[{'klass':'java.lang.String','errorReports': [{'errorCode':'E4000','message':'m1'}]}]}}");
    assertEquals("my message\n" + "* class java.lang.String\n" + "  E4000 m1", response.as(JsonError.class).summary());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 60 with JsonObject

use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.

the class AuthoritiesControllerTest method testGetAuthorities.

@Test
void testGetAuthorities() {
    JsonArray systemAuthorities = GET("/authorities").content().getArray("systemAuthorities");
    assertTrue(systemAuthorities.size() > 10);
    // its sorted
    JsonObject all = systemAuthorities.getObject(0);
    assertEquals("ALL", all.getString("id").string());
    assertEquals("ALL", all.getString("name").string());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Aggregations

JsonObject (org.hisp.dhis.jsontree.JsonObject)106 Test (org.junit.jupiter.api.Test)92 DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)51 JsonArray (org.hisp.dhis.jsontree.JsonArray)16 ProgramInstance (org.hisp.dhis.program.ProgramInstance)6 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)6 Relationship (org.hisp.dhis.relationship.Relationship)5 RelationshipType (org.hisp.dhis.relationship.RelationshipType)5 GeoJsonObject (org.geojson.GeoJsonObject)3 JsonString (org.hisp.dhis.jsontree.JsonString)3 HttpStatus (org.springframework.http.HttpStatus)3 ObjectType (org.hisp.dhis.attribute.Attribute.ObjectType)2 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)2 Arrays.stream (java.util.Arrays.stream)1 Date (java.util.Date)1 JsonResponse (org.hisp.dhis.jsontree.JsonResponse)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Program (org.hisp.dhis.program.Program)1 ApiToken (org.hisp.dhis.security.apikey.ApiToken)1 SettingKey (org.hisp.dhis.setting.SettingKey)1