Search in sources :

Example 71 with JsonObject

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

the class GistValidationControllerTest method testValidation_Access_CollectionOwnerSharing.

@Test
void testValidation_Access_CollectionOwnerSharing() {
    JsonObject group = GET("/userGroups/{id}", userGroupId).content();
    String sharing = group.getObject("sharing").node().extract().members().get("public").replaceWith("\"--------\"").toString();
    assertStatus(HttpStatus.NO_CONTENT, PUT("/userGroups/" + userGroupId + "/sharing", sharing));
    switchToGuestUser();
    assertEquals("User not allowed to view UserGroup " + userGroupId, GET("/userGroups/{id}/users/gist", userGroupId).error(HttpStatus.FORBIDDEN).getMessage());
    switchToSuperuser();
    assertStatus(HttpStatus.OK, GET("/userGroups/{id}/users/gist", userGroupId));
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 72 with JsonObject

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

the class JobConfigurationControllerTest method testCONTINUOUS_ANALYTICS_TABLE.

@Test
void testCONTINUOUS_ANALYTICS_TABLE() {
    String jobId = assertStatus(HttpStatus.CREATED, POST("/jobConfigurations", "{'name':'test','jobType':'CONTINUOUS_ANALYTICS_TABLE','delay':'1'," + "'jobParameters':{'fullUpdateHourOfDay':'1','lastYears':'2'," + "'skipTableTypes':['DATA_VALUE','COMPLETENESS','COMPLETENESS_TARGET','ORG_UNIT_TARGET','EVENT','ENROLLMENT','VALIDATION_RESULT']}}"));
    JsonObject parameters = assertJobConfigurationExists(jobId, "CONTINUOUS_ANALYTICS_TABLE");
    assertEquals(1, parameters.getNumber("fullUpdateHourOfDay").intValue());
    assertEquals(2, parameters.getNumber("lastYears").intValue());
    assertContainsOnly(parameters.getArray("skipTableTypes").stringValues(), "ENROLLMENT", "VALIDATION_RESULT", "DATA_VALUE", "COMPLETENESS", "EVENT", "ORG_UNIT_TARGET", "COMPLETENESS_TARGET");
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 73 with JsonObject

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

the class JobConfigurationControllerTest method assertJobConfigurationExists.

private JsonObject assertJobConfigurationExists(String jobId, String expectedJobType) {
    JsonObject jobConfiguration = GET("/jobConfigurations/{id}", jobId).content();
    assertEquals(jobId, jobConfiguration.getString("id").string());
    assertEquals("test", jobConfiguration.getString("name").string());
    assertEquals("SCHEDULED", jobConfiguration.getString("jobStatus").string());
    assertTrue(jobConfiguration.getBoolean("enabled").booleanValue());
    assertEquals(expectedJobType, jobConfiguration.getString("jobType").string());
    return jobConfiguration.getObject("jobParameters");
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject)

Example 74 with JsonObject

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

the class JobConfigurationControllerTest method testGetJobTypesExtended.

@Test
void testGetJobTypesExtended() {
    JsonObject types = GET("/jobConfigurations/jobTypesExtended").content();
    JsonObject param = types.getObject("ANALYTICS_TABLE").getObject("skipTableTypes");
    assertEquals(List.of("DATA_VALUE", "COMPLETENESS", "COMPLETENESS_TARGET", "ORG_UNIT_TARGET", "EVENT", "ENROLLMENT", "VALIDATION_RESULT"), param.getArray("constants").stringValues());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 75 with JsonObject

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

the class JobConfigurationControllerTest method testDISABLE_INACTIVE_USERS.

@Test
void testDISABLE_INACTIVE_USERS() {
    String jobId = assertStatus(HttpStatus.CREATED, POST("/jobConfigurations", "{'name':'test','jobType':'DISABLE_INACTIVE_USERS','cronExpression':'0 0 1 ? * *','jobParameters':{'inactiveMonths':'3'}}"));
    JsonObject parameters = assertJobConfigurationExists(jobId, "DISABLE_INACTIVE_USERS");
    assertEquals(3, parameters.getNumber("inactiveMonths").intValue());
}
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