Search in sources :

Example 86 with ApiResponse

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

the class MessageConversationsActions method waitForNotification.

public ApiResponse waitForNotification(int expectedCount) {
    boolean isReceived = false;
    int attemptCount = 20;
    ApiResponse response = null;
    while (!isReceived && attemptCount > 0) {
        response = this.get("", new QueryParamsBuilder().add("fields=subject"));
        isReceived = (response.extractList("messageConversations").size() == expectedCount);
        attemptCount--;
    }
    return response;
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse)

Example 87 with ApiResponse

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

the class DataItemQueryTests method testWhenFilteringByNonExistingNameWithoutPagination.

@Test
public void testWhenFilteringByNonExistingNameWithoutPagination() {
    // Given
    final String theDimensionType = "PROGRAM_INDICATOR";
    final String aNonExistingName = "non-existing-name";
    final String theUrlParams = "?filter=dimensionItemType:in:[%s]&filter=name:ilike:%s&paging=false";
    // When
    final ApiResponse response = dataItemActions.get(format(theUrlParams, theDimensionType, aNonExistingName));
    // Then
    response.validate().statusCode(is(OK));
    response.validate().body("pager", is(nullValue()));
    response.validate().body("dataItems", is(empty()));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 88 with ApiResponse

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

the class DataItemQueryTests method testGetAllDataItemsUsingDefaultPagination.

@Test
public void testGetAllDataItemsUsingDefaultPagination() {
    // When
    final ApiResponse response = dataItemActions.get();
    // Then
    response.validate().statusCode(is(OK));
    response.validate().body("pager", isA(Object.class));
    response.validate().body("dataItems", is(not(empty())));
    response.validate().body("dataItems.dimensionItemType", (anyOf(hasItem("PROGRAM_INDICATOR"), hasItem("DATA_ELEMENT"))));
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 89 with ApiResponse

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

the class DataItemQueryTests method testWhenDataIsNotFoundUsingDefaultPagination.

@Test
public void testWhenDataIsNotFoundUsingDefaultPagination() {
    // Given
    final String theDimensionType = "PROGRAM_INDICATOR";
    final String aNonExistingName = "non-existing-Name";
    final String aValidFilteringAttribute = "name";
    final String theUrlParams = "?filter=dimensionItemType:in:[%s]&filter=" + aValidFilteringAttribute + ":ilike:%s";
    // When
    final ApiResponse response = dataItemActions.get(format(theUrlParams, theDimensionType, aNonExistingName));
    // Then
    response.validate().statusCode(is(OK));
    response.validate().body("dataItems", is(empty()));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 90 with ApiResponse

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

the class DataItemQueryTests method testGetAllDataItemsWithoutPagination.

@Test
public void testGetAllDataItemsWithoutPagination() {
    // Given
    final String noPagination = "?paging=false";
    // When
    final ApiResponse response = dataItemActions.get(noPagination);
    // Then
    response.validate().statusCode(is(OK));
    response.validate().body("pager", is(nullValue()));
    response.validate().body("dataItems", is(not(empty())));
    response.validate().body("dataItems.dimensionItemType", hasItem("PROGRAM_INDICATOR"));
    response.validate().body("dataItems.dimensionItemType", hasItem("DATA_ELEMENT"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) 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