use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class MetadataActions method importMetadata.
public MetadataApiResponse importMetadata(File file, String... queryParams) {
QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
queryParamsBuilder.addAll(queryParams);
queryParamsBuilder.addAll("importReportMode=FULL");
ApiResponse response = postFile(file, queryParamsBuilder);
response.validate().statusCode(200);
return new MetadataApiResponse(response);
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class RestApiActions method get.
/**
* Sends get request with provided path and queryParams appended to URL.
*
* @param resourceId Id of resource
* @param queryParamsBuilder Query params to append to url
*/
public ApiResponse get(String resourceId, QueryParamsBuilder queryParamsBuilder) {
String path = queryParamsBuilder == null ? "" : queryParamsBuilder.build();
Response response = this.given().contentType(ContentType.TEXT).when().get(resourceId + path);
return new ApiResponse(response);
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class RestApiActions method postFile.
public ApiResponse postFile(File file, QueryParamsBuilder queryParamsBuilder) {
String url = queryParamsBuilder == null ? "" : queryParamsBuilder.build();
ApiResponse response = new ApiResponse(this.given().body(file).when().post(url));
saveCreatedObjects(response);
return response;
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserAssignmentTests method shouldBeEnabledOnProgramStage.
@ParameterizedTest
@ValueSource(strings = { "WITHOUT_REGISTRATION", "WITH_REGISTRATION" })
public void shouldBeEnabledOnProgramStage(String programType) {
// arrange
String programId = programActions.get("?filter=programStages:ge:1&filter=programType:eq:" + programType).extractString("programs.id[0]");
String programStageId = programActions.get(programId).extractString("programStages.id[0]");
// act - enabling user assignment
ApiResponse response = programActions.programStageActions.enableUserAssignment(programStageId, true);
// assert
ResponseValidationHelper.validateObjectUpdate(response, 200);
response = programActions.programStageActions.get(programStageId);
response.validate().statusCode(200).body(userAssignmentProperty, equalTo(true));
// act - disabling user assignment
response = programActions.programStageActions.enableUserAssignment(programStageId, false);
// assert
ResponseValidationHelper.validateObjectUpdate(response, 200);
response = programActions.programStageActions.get(programStageId);
response.validate().statusCode(200).body(userAssignmentProperty, equalTo(false));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class ImportStrategyTests method shouldDeleteWithDeleteStrategy.
@ParameterizedTest
@ValueSource(strings = { "src/test/resources/tracker/importer/teis/teisWithEnrollmentsAndEvents.json", "src/test/resources/tracker/importer/teis/teiAndEnrollment.json", "src/test/resources/tracker/importer/teis/teis.json", "src/test/resources/tracker/importer/events/events.json" })
public void shouldDeleteWithDeleteStrategy(String fileName) throws Exception {
// arrange
JsonObject teiBody = new FileReaderUtils().readJsonAndGenerateData(new File(fileName));
trackerActions.postAndGetJobReport(teiBody).validateSuccessfulImport();
teiBody = new FileReaderUtils().readJsonAndGenerateData(new File(fileName));
// act
ApiResponse response = trackerActions.postAndGetJobReport(teiBody, new QueryParamsBuilder().add("importStrategy=DELETE"));
// assert
response.validate().statusCode(200).body("status", equalTo("OK")).body("stats.deleted", Matchers.greaterThanOrEqualTo(1));
}
Aggregations