Search in sources :

Example 6 with JsonArray

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

the class GistFieldsControllerTest method testField_Access.

@Test
void testField_Access() {
    JsonArray groups = GET("/users/{uid}/userGroups/gist?fields=id,access&headless=true", getSuperuserUid()).content();
    assertEquals(1, groups.size());
    JsonObject group = groups.getObject(0);
    JsonObject access = group.getObject("access");
    assertTrue(access.has("manage", "externalize", "write", "read", "update", "delete"));
    assertTrue(access.getBoolean("manage").booleanValue());
    assertTrue(access.getBoolean("externalize").booleanValue());
    assertTrue(access.getBoolean("write").booleanValue());
    assertTrue(access.getBoolean("read").booleanValue());
    assertTrue(access.getBoolean("update").booleanValue());
    assertTrue(access.getBoolean("delete").booleanValue());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 7 with JsonArray

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

the class SystemControllerTest method testGetTaskJsonByUid.

@Test
void testGetTaskJsonByUid() {
    JsonArray task = GET("/system/tasks/{jobType}/{jobId}", "META_DATA_SYNC", "xyz").content(HttpStatus.OK);
    assertTrue(task.isArray());
    assertEquals(0, task.size());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 8 with JsonArray

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

the class MeControllerTest method testGetCurrentUserDataApprovalWorkflows.

@Test
void testGetCurrentUserDataApprovalWorkflows() {
    JsonArray workflows = GET("/me/dataApprovalWorkflows").content().getArray("dataApprovalWorkflows");
    assertTrue(workflows.isArray());
    assertTrue(workflows.isEmpty());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 9 with JsonArray

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

the class OrganisationUnitLocationControllerTest method testGetParentByLocation.

@Test
void testGetParentByLocation() {
    JsonArray parents = GET("/organisationUnitLocations/orgUnitByLocation?longitude=23.1&latitude=56.2").content(HttpStatus.OK);
    assertTrue(parents.isArray());
    assertTrue(parents.isEmpty());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) Test(org.junit.jupiter.api.Test) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest)

Example 10 with JsonArray

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

the class AbstractCrudControllerTest method replaceTranslationsForNotTranslatableObject.

@Test
void replaceTranslationsForNotTranslatableObject() {
    String id = getCurrentUser().getUid();
    JsonArray translations = GET("/users/{id}/translations", id).content().getArray("translations");
    assertTrue(translations.isEmpty());
    JsonWebMessage message = assertWebMessage("Conflict", 409, "WARNING", "One more more errors occurred, please see full details in import report.", PUT("/users/" + id + "/translations", "{'translations': [{'locale':'sv', 'property':'name', 'value':'namn'}]}").content(HttpStatus.CONFLICT));
    JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E1107);
    assertEquals("Object type `User` is not translatable.", error.getMessage());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) JsonWebMessage(org.hisp.dhis.webapi.json.domain.JsonWebMessage) JsonErrorReport(org.hisp.dhis.webapi.json.domain.JsonErrorReport) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Aggregations

JsonArray (org.hisp.dhis.jsontree.JsonArray)29 Test (org.junit.jupiter.api.Test)26 JsonObject (org.hisp.dhis.jsontree.JsonObject)16 DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)16 JsonErrorReport (org.hisp.dhis.webapi.json.domain.JsonErrorReport)2 JsonWebMessage (org.hisp.dhis.webapi.json.domain.JsonWebMessage)2 JsonResponse (org.hisp.dhis.jsontree.JsonResponse)1 JsonString (org.hisp.dhis.jsontree.JsonString)1 User (org.hisp.dhis.user.User)1 JsonTranslation (org.hisp.dhis.webapi.json.domain.JsonTranslation)1 JsonUser (org.hisp.dhis.webapi.json.domain.JsonUser)1 AfterEach (org.junit.jupiter.api.AfterEach)1