use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataImportTest method dataValuesCanBeImportedAsync.
@Test
public void dataValuesCanBeImportedAsync() {
ApiResponse response = dataValueSetActions.postFile(new File("src/test/resources/aggregate/dataValues_bulk.json"), new QueryParamsBuilder().addAll("reportMode=DEBUG", "async=true")).validateStatus(200);
String taskId = response.extractString("response.id");
// Validate that job was successful
systemActions.waitUntilTaskCompleted("DATAVALUE_IMPORT", taskId).validate().body("message", Matchers.containsInAnyOrder("Process started", "Importing data values", "Import done"));
// validate task summaries were created
ApiResponse taskSummariesResponse = systemActions.waitForTaskSummaries("DATAVALUE_IMPORT", taskId);
taskSummariesResponse.validate().statusCode(200).body("status", equalTo("SUCCESS")).rootPath("importCount").body("deleted", equalTo(0)).body("ignored", equalTo(0));
ImportSummary importSummary = taskSummariesResponse.getImportSummaries().get(0);
assertThat(taskSummariesResponse.getAsString(), importSummary.getImportCount().getImported() + importSummary.getImportCount().getUpdated(), greaterThan(0));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataItemQueryTests method testFilterByDimensionTypeUsingDefaultPagination.
@Test
public void testFilterByDimensionTypeUsingDefaultPagination() {
// Given
final String theDimensionType = "PROGRAM_INDICATOR";
final String theUrlParams = "?filter=dimensionItemType:in:[%s]";
// When
final ApiResponse response = dataItemActions.get(format(theUrlParams, theDimensionType));
// 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", everyItem(is(theDimensionType)));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserActions method addRoleToUser.
public void addRoleToUser(String userId, String userRoleId) {
ApiResponse response = this.get(userId);
if (response.extractList("userRoles.id").contains(userRoleId)) {
return;
}
JsonObject object = response.getBody();
JsonObject userRole = new JsonObject();
userRole.addProperty("id", userRoleId);
object.get("userRoles").getAsJsonArray().add(userRole);
this.update(userId, object).validate().statusCode(200);
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserActions method addUser.
public String addUser(final String firstName, final String surname, final String username, final String password) {
String id = idGenerator.generateUniqueId();
JsonObject user = new JsonObjectBuilder().addProperty("id", id).addProperty("firstName", firstName).addProperty("surname", surname).addProperty("username", username).addProperty("password", password).build();
ApiResponse response = this.post(user);
response.validate().statusCode(201);
TestRunStorage.addCreatedEntity(endpoint, id);
return id;
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserActions method grantUserDataViewAccessToOrgUnit.
public void grantUserDataViewAccessToOrgUnit(String userId, String orgUnitId) {
JsonObject object = this.get(userId).getBodyAsJsonBuilder().addOrAppendToArray("dataViewOrganisationUnits", new JsonObjectBuilder().addProperty("id", orgUnitId).build()).build();
ApiResponse response = this.update(userId, object);
response.validate().statusCode(200).body("status", equalTo("OK"));
}
Aggregations