Search in sources :

Example 81 with ApiResponse

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

the class MetadataActions method importAndValidateMetadata.

public MetadataApiResponse importAndValidateMetadata(JsonObject object, String... queryParams) {
    ApiResponse response = importMetadata(object, queryParams);
    response.validate().body("response.stats.ignored", not(equalTo(response.extract("response.stats.total"))));
    return new MetadataApiResponse(response);
}
Also used : MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse) ApiResponse(org.hisp.dhis.dto.ApiResponse) MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse)

Example 82 with ApiResponse

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

the class MetadataActions method importAndValidateMetadata.

public MetadataApiResponse importAndValidateMetadata(File file, String... queryParams) {
    ApiResponse response = importMetadata(file, queryParams);
    response.validate().body("response.stats.ignored", not(equalTo(response.extract("response.stats.total"))));
    return new MetadataApiResponse(response);
}
Also used : MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse) ApiResponse(org.hisp.dhis.dto.ApiResponse) MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse)

Example 83 with ApiResponse

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

the class ProgramStageActions method enableUserAssignment.

public ApiResponse enableUserAssignment(String programStageId, boolean enabled) {
    JsonObject body = this.get(programStageId).getBody();
    body.addProperty("enableUserAssignment", enabled);
    ApiResponse response = this.update(programStageId, body);
    response.validate().statusCode(200);
    return response;
}
Also used : JsonObject(com.google.gson.JsonObject) ApiResponse(org.hisp.dhis.dto.ApiResponse)

Example 84 with ApiResponse

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

the class EventActions method softDelete.

public ApiResponse softDelete(String eventId) {
    ApiResponse response = super.delete(eventId);
    response.validate().statusCode(200);
    return response;
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse)

Example 85 with ApiResponse

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

the class LoginActions method loginAsUser.

/**
 * Makes sure user with given name is logged in. Will throw assertion
 * exception if authentication is not successful.
 *
 * @param username
 * @param password
 */
public void loginAsUser(final String username, final String password) {
    ApiResponse loggedInUser = getLoggedInUserInfo();
    if (loggedInUser.getContentType().contains("json") && loggedInUser.extract("username") != null && loggedInUser.extract("username").equals(username)) {
        return;
    }
    addAuthenticationHeader(username, password);
    getLoggedInUserInfo().validate().statusCode(200).body("username", equalTo(username));
}
Also used : ApiResponse(org.hisp.dhis.dto.ApiResponse)

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