Search in sources :

Example 1 with ApiResponse

use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.

the class MetadataPaginationTest method checkPaginationResultsForcingInMemoryPagination.

@Test
public void checkPaginationResultsForcingInMemoryPagination() {
    // this test forces the metadata query engine to execute an "in memory"
    // sorting and pagination
    // since the sort ("order") value is set to 'displayName' that is a
    // "virtual" field (that is, not a database column)
    // The metadata query engine can not execute a sql query using this
    // field, since it does not exist
    // on the table. Therefore, the engine loads the entire content of the
    // table in memory and
    // executes a sort + pagination "in memory"
    ApiResponse response = paginationActions.getPaginated(startPage, pageSize);
    response.validate().statusCode(200);
    paginationActions.assertPagination(response, 100, 100 / pageSize, pageSize, startPage);
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 2 with ApiResponse

use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.

the class MetadataPaginationTest method checkPaginationResultsForcingDatabaseOnlyPagination.

@Test
public void checkPaginationResultsForcingDatabaseOnlyPagination() {
    // this test forces the metadata query engine to execute the query
    // (including pagination) on the database only.
    // The sort ("order") value is set to 'id' that is mapped to a DB
    // column.
    ApiResponse response = paginationActions.getPaginated(Arrays.asList(DEFAULT_METADATA_FILTER.split(",")), Arrays.asList(DEFAULT_METADATA_FIELDS.split(",")), Collections.singletonList("id:ASC"), startPage, pageSize);
    response.validate().statusCode(200);
    paginationActions.assertPagination(response, 100, 100 / pageSize, pageSize, startPage);
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 3 with ApiResponse

use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.

the class OptionSetTests method shouldBeAbleToReferenceWithOption.

@Test
public void shouldBeAbleToReferenceWithOption() {
    // arrange
    String optionId = createOption(createdOptionSet);
    // act
    ApiResponse response = optionActions.optionSetActions.get(createdOptionSet);
    // assert
    response.validate().statusCode(200).body("options.id[0]", equalTo(optionId));
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 4 with ApiResponse

use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.

the class OptionSetTests method shouldAddOptions.

@Test
public void shouldAddOptions() {
    String option1 = createOption(createdOptionSet);
    String option2 = createOption(createdOptionSet);
    ApiResponse response = optionActions.optionSetActions.get(createdOptionSet);
    response.validate().statusCode(200).body("options", not(emptyArray())).body("options.id", not(emptyArray())).rootPath("options").body("id[0]", equalTo(option1)).body("id[1]", equalTo(option2));
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 5 with ApiResponse

use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.

the class OptionSetTests method shouldNotBeRemovedWithAssociatedData.

@Test
public void shouldNotBeRemovedWithAssociatedData() {
    // arrange
    createOption(createdOptionSet);
    // act
    ApiResponse response = optionActions.optionSetActions.delete(createdOptionSet);
    // assert
    ResponseValidationHelper.validateObjectRemoval(response, "Option set was not deleted");
    optionActions.optionSetActions.get(createdOptionSet).validate().statusCode(404);
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Aggregations

ApiResponse (org.hisp.dhis.dto.ApiResponse)145 Test (org.junit.jupiter.api.Test)75 JsonObject (com.google.gson.JsonObject)63 ApiTest (org.hisp.dhis.ApiTest)63 QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)49 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)48 File (java.io.File)25 TrackerApiResponse (org.hisp.dhis.dto.TrackerApiResponse)18 FileReaderUtils (org.hisp.dhis.helpers.file.FileReaderUtils)18 ValueSource (org.junit.jupiter.params.provider.ValueSource)16 MethodSource (org.junit.jupiter.params.provider.MethodSource)14 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)11 TrackerNtiApiTest (org.hisp.dhis.tracker.TrackerNtiApiTest)11 RestApiActions (org.hisp.dhis.actions.RestApiActions)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 JsonArray (com.google.gson.JsonArray)5 ImportSummary (org.hisp.dhis.dto.ImportSummary)5 LoginActions (org.hisp.dhis.actions.LoginActions)4 MetadataApiResponse (org.hisp.dhis.dto.MetadataApiResponse)4 ArrayList (java.util.ArrayList)3