use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserLookupTests method shouldLookupUserByEmail.
@ParameterizedTest
@ValueSource(strings = { "taadmin@", "@dhis2.org", "tasuperuser@dhis2.org" })
public void shouldLookupUserByEmail(String query) {
ApiResponse response = lookupActions.get("?query=" + query);
response.validate().statusCode(200).body("users", hasSize(greaterThan(0)));
List<String> users = response.extractList("users.id");
users.forEach(user -> {
userActions.get(user).validate().statusCode(200).body("email", containsStringIgnoringCase(query));
});
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class EnrollmentsTests method shouldImportEnrollmentToExistingTei.
@Test
public void shouldImportEnrollmentToExistingTei() throws Exception {
String teiId = importTei();
JsonObject enrollmentPayload = new FileReaderUtils().read(new File("src/test/resources/tracker/importer/enrollments/enrollment.json")).replacePropertyValuesWith("trackedEntity", teiId).get(JsonObject.class);
TrackerApiResponse response = trackerActions.postAndGetJobReport(enrollmentPayload);
response.validateSuccessfulImport().validateEnrollments().body("stats.created", equalTo(1)).body("objectReports", notNullValue()).body("objectReports.uid", notNullValue());
String enrollmentId = response.extractImportedEnrollments().get(0);
ApiResponse enrollmentResponse = trackerActions.get("/enrollments/" + enrollmentId);
assertThat(enrollmentResponse.getBody(), matchesJSON(enrollmentPayload.get("enrollments").getAsJsonArray().get(0).getAsJsonObject()));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class EventExportTests method shouldReturnSingleEvent.
@ParameterizedTest(name = "[{0}]")
@MethodSource
public void shouldReturnSingleEvent(String description, String eventId, Boolean shouldGet) {
loginActions.loginAsUser(userName, password);
ApiResponse response = eventActions.get(eventId);
if (shouldGet) {
response.validate().statusCode(200);
return;
}
response.validate().statusCode(409);
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class EventExportTests method shouldSkipRelationshipsForEventId.
@ValueSource(strings = { "?event=eventId", "?event=eventId&fields=*,!relationships", "?program=programId&fields=*,!relationships" })
@ParameterizedTest
public void shouldSkipRelationshipsForEventId(String queryParams) {
ApiResponse response = eventActions.get(queryParams.replace("eventId", events.get(captureOu)).replace("programId", withoutRegistrationProgram));
String body = "relationships";
if (response.extractList("events") != null) {
body = "events[0].relationships";
}
response.validate().body(body, anyOf(nullValue(), hasSize(0)));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TEIimportTest method teisShouldBeUpdatedAndDeletedInBulk.
@Test
public void teisShouldBeUpdatedAndDeletedInBulk() {
// arrange
JsonArray teis = object.getAsJsonArray("trackedEntityInstances");
JsonObject tei1event = teis.get(0).getAsJsonObject().getAsJsonArray("enrollments").get(0).getAsJsonObject().getAsJsonArray("events").get(0).getAsJsonObject();
JsonObject tei2enrollment = teis.get(1).getAsJsonObject().getAsJsonArray("enrollments").get(0).getAsJsonObject();
tei1event.addProperty("deleted", true);
tei2enrollment.addProperty("status", "COMPLETED");
// act
ApiResponse response = teiActions.post(object, new QueryParamsBuilder().addAll("strategy=SYNC"));
// assert
String eventId = response.validate().statusCode(200).body("response", notNullValue()).rootPath("response").body("updated", Matchers.greaterThanOrEqualTo(2)).appendRootPath("importSummaries[0]").body("importCount.updated", greaterThanOrEqualTo(1)).appendRootPath("enrollments.importSummaries[0].events.importSummaries[0]").body("status", Matchers.equalTo("SUCCESS"), "reference", notNullValue(), "importCount.deleted", Matchers.equalTo(1), "description", Matchers.stringContainsInOrder("Deletion of event", "was successful")).extract().path("response.importSummaries[0].enrollments.importSummaries[0].events.importSummaries[0].reference");
String enrollmentId = response.validate().rootPath("response.importSummaries[1].enrollments.importSummaries[0]").body("status", Matchers.equalTo("SUCCESS"), "reference", notNullValue(), "importCount.updated", Matchers.equalTo(1)).extract().path("response.importSummaries[1].enrollments.importSummaries[0].reference");
// check if updates on event and enrollment were done.
response = enrollmentActions.get(enrollmentId);
response.validate().statusCode(200).body("status", Matchers.equalTo("COMPLETED"));
response = eventActions.get(eventId);
response.validate().statusCode(404);
}
Aggregations