Search in sources :

Example 21 with ApiResponse

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

the class DataImportTest method cleanUp.

@AfterAll
public void cleanUp() {
    QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
    queryParamsBuilder.addAll("importReportMode=FULL", "importStrategy=DELETE");
    ApiResponse response = dataValueSetActions.postFile(new File("src/test/resources/aggregate/dataValues_bulk.json"), queryParamsBuilder);
    response.validate().statusCode(200);
    response = dataValueSetActions.postFile(new File("src/test/resources/aggregate/dataValues_single_dataset.json"), queryParamsBuilder);
    response.validate().statusCode(200);
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) File(java.io.File) ApiResponse(org.hisp.dhis.dto.ApiResponse) AfterAll(org.junit.jupiter.api.AfterAll)

Example 22 with ApiResponse

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

the class ProgramActions method createEventProgram.

public ApiResponse createEventProgram(String... orgUnitsIds) {
    JsonObject body = new JsonObjectBuilder(buildProgram("WITHOUT_REGISTRATION", null, orgUnitsIds)).build();
    ApiResponse response = post(body);
    createProgramStage(response.extractUid(), "DEFAULT STAGE");
    return response;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonObjectBuilder(org.hisp.dhis.helpers.JsonObjectBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse)

Example 23 with ApiResponse

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

the class ProgramActions method createProgramStage.

/**
 * Creates a program stage and links it to the program.
 *
 * @param programId
 * @param programStageName
 * @return program stage id
 */
public String createProgramStage(String programId, String programStageName) {
    ApiResponse response = programStageActions.post(new JsonObjectBuilder().addProperty("name", programStageName).addObject("program", new JsonObjectBuilder().addProperty("id", programId)).addProperty("publicAccess", "rwrw----").build());
    response.validate().statusCode(Matchers.is(Matchers.oneOf(201, 200)));
    return response.extractUid();
}
Also used : JsonObjectBuilder(org.hisp.dhis.helpers.JsonObjectBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse)

Example 24 with ApiResponse

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

the class EventActions method delete.

/**
 * Hard deletes event.
 *
 * @param eventId
 * @return
 */
@Override
public ApiResponse delete(String eventId) {
    ApiResponse response = super.delete(eventId);
    new MaintenanceActions().removeSoftDeletedEvents();
    return response;
}
Also used : MaintenanceActions(org.hisp.dhis.actions.MaintenanceActions) ApiResponse(org.hisp.dhis.dto.ApiResponse)

Example 25 with ApiResponse

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

the class OrgUnitActions method create.

public String create(final OrgUnit orgUnit) {
    ApiResponse response = post(orgUnit);
    response.validate().statusCode(201);
    return response.extractString("response.uid");
}
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