Search in sources :

Example 16 with JsonObject

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

the class GistValidationControllerTest method testValidation_Access_UserPublicFields.

@Test
void testValidation_Access_UserPublicFields() {
    switchToGuestUser();
    JsonObject userLookup = GET("/users/{id}/gist?fields=id,code,surname,firstName", getSuperuserUid()).content();
    assertTrue(userLookup.has("id", "code", "surname", "firstName"));
    assertEquals(getSuperuserUid(), userLookup.getString("id").string());
    assertEquals("admin", userLookup.getString("code").string());
    assertEquals("admin", userLookup.getString("surname").string());
    assertEquals("admin", userLookup.getString("firstName").string());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 17 with JsonObject

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

the class JobConfigurationControllerTest method testANALYTICS_TABLE.

@Test
void testANALYTICS_TABLE() {
    String jobId = assertStatus(HttpStatus.CREATED, POST("/jobConfigurations", "{'name':'test','jobType':'ANALYTICS_TABLE','cronExpression':'0 0 3 ? * *'," + "'jobParameters':{'lastYears':'1'," + "'skipTableTypes':['DATA_VALUE','COMPLETENESS','ENROLLMENT']," + "'skipPrograms':['" + UID1 + "','" + UID2 + "']," + "'skipResourceTables':true}}"));
    JsonObject parameters = assertJobConfigurationExists(jobId, "ANALYTICS_TABLE");
    assertEquals(1, parameters.getNumber("lastYears").intValue());
    assertTrue(parameters.getBoolean("skipResourceTables").booleanValue());
    assertContainsOnly(parameters.getArray("skipTableTypes").stringValues(), "DATA_VALUE", "COMPLETENESS", "ENROLLMENT");
    assertContainsOnly(parameters.getArray("skipPrograms").stringValues(), UID1, UID2);
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 18 with JsonObject

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

the class JobConfigurationControllerTest method testRESOURCE_TABLE.

@Test
void testRESOURCE_TABLE() {
    String jobId = assertStatus(HttpStatus.CREATED, POST("/jobConfigurations", "{'name':'test','jobType':'RESOURCE_TABLE','cronExpression':'0 0 3 ? * MON'}"));
    JsonObject parameters = assertJobConfigurationExists(jobId, "RESOURCE_TABLE");
    assertFalse(parameters.exists());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 19 with JsonObject

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

the class JobConfigurationControllerTest method testMONITORING.

@Test
void testMONITORING() {
    String jobId = assertStatus(HttpStatus.CREATED, POST("/jobConfigurations", "{'name':'test','jobType':'MONITORING','cronExpression':'0 0 12 ? * MON-FRI'," + "'jobParameters':{'relativeStart':'1','relativeEnd':'2','validationRuleGroups':[],'sendNotifications':true,'persistResults':true}}"));
    JsonObject parameters = assertJobConfigurationExists(jobId, "MONITORING");
    assertEquals(1, parameters.getNumber("relativeStart").intValue());
    assertEquals(2, parameters.getNumber("relativeEnd").intValue());
    assertTrue(parameters.getBoolean("sendNotifications").booleanValue());
    assertTrue(parameters.getBoolean("persistResults").booleanValue());
    assertTrue(parameters.getArray("validationRuleGroups").isEmpty());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 20 with JsonObject

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

the class SystemControllerTest method testGetTasksJson.

@Test
void testGetTasksJson() {
    JsonObject tasks = GET("/system/tasks").content(HttpStatus.OK);
    assertObjectMembers(tasks, "CONTINUOUS_ANALYTICS_TABLE", "DATA_SYNC", "TRACKER_PROGRAMS_DATA_SYNC", "EVENT_PROGRAMS_DATA_SYNC", "FILE_RESOURCE_CLEANUP", "IMAGE_PROCESSING", "META_DATA_SYNC", "SMS_SEND", "SEND_SCHEDULED_MESSAGE", "PROGRAM_NOTIFICATIONS", "VALIDATION_RESULTS_NOTIFICATION", "CREDENTIALS_EXPIRY_ALERT", "MONITORING", "PUSH_ANALYSIS", "PREDICTOR", "DATA_STATISTICS", "DATA_INTEGRITY", "RESOURCE_TABLE", "ANALYTICS_TABLE");
}
Also used : 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