use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataItemQueryTests method testFilterUsingInvalidDimensionTypeUsingDefaultPagination.
@Test
public void testFilterUsingInvalidDimensionTypeUsingDefaultPagination() {
// Given
final String anyInvalidDimensionType = "INVALID_TYPE";
final String theUrlParams = "?filter=dimensionItemType:in:[%s]";
// When
final ApiResponse response = dataItemActions.get(format(theUrlParams, anyInvalidDimensionType));
// Then
response.validate().statusCode(is(CONFLICT));
response.validate().body("pager", is(nullValue()));
response.validate().body("httpStatus", is("Conflict"));
response.validate().body("httpStatusCode", is(CONFLICT));
response.validate().body("status", is("ERROR"));
response.validate().body("errorCode", is("E2016"));
response.validate().body("message", containsString("Unable to parse element `" + anyInvalidDimensionType + "` on filter `dimensionItemType`. The values available are:"));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataItemQueryTests method testGetAllDataItemsUsingDefaultPaginationOrderedByCode.
@Test
public void testGetAllDataItemsUsingDefaultPaginationOrderedByCode() {
// When
final ApiResponse response = dataItemActions.get("?order=name:asc");
// Then
response.validate().statusCode(is(OK));
response.validate().body("pager", isA(Object.class));
response.validate().body("dataItems", is(not(empty())));
response.validate().body("dataItems.code", hasItem("AAAAAAA-1234"));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataItemQueryTests method testFilterByProgramUsingNonexistentAttributeAndDefaultPagination.
@Test
public void testFilterByProgramUsingNonexistentAttributeAndDefaultPagination() {
// Given
final String theDimensionType = "PROGRAM_INDICATOR";
final String theProgramId = Constants.EVENT_PROGRAM_ID;
final String aNonExistingAttr = "nonExistingAttr";
final String theUrlParams = "?filter=dimensionItemType:in:[%s]&filter=" + aNonExistingAttr + ":eq:%s&order=code:asc";
// When
final ApiResponse response = dataItemActions.get(format(theUrlParams, theDimensionType, theProgramId));
// Then
response.validate().statusCode(is(CONFLICT));
response.validate().body("pager", is(nullValue()));
response.validate().body("httpStatus", is("Conflict"));
response.validate().body("httpStatusCode", is(CONFLICT));
response.validate().body("status", is("ERROR"));
response.validate().body("errorCode", is("E2034"));
response.validate().body("message", containsString("Filter not supported: `" + aNonExistingAttr + "`"));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TestCleanUp method deleteEntity.
public boolean deleteEntity(String resource, String id) {
ApiResponse response = new RestApiActions(resource).delete(id + "?force=true");
if (response.statusCode() == 200 || response.statusCode() == 404) {
logger.info(String.format("Entity from resource %s with id %s deleted", resource, id));
if (response.containsImportSummaries()) {
return response.extract("response.importCount.deleted").equals(1);
}
return true;
}
logger.warning(String.format("Entity from resource %s with id %s was not deleted. Status code: %s", resource, id, response.statusCode()));
return false;
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TrackerActions method getJobReport.
public TrackerApiResponse getJobReport(String jobId, String reportMode) {
ApiResponse response = this.get(String.format("/jobs/%s/report?reportMode=%s", jobId, reportMode));
// add created entities
saveCreatedData(response);
return new TrackerApiResponse(response);
}
Aggregations