use of org.junit.jupiter.params.provider.ValueSource 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.junit.jupiter.params.provider.ValueSource in project dhis2-core by dhis2.
the class EnrollmentsTests method shouldOnlyEnrollOnce.
@ValueSource(strings = { "true", "false" })
@ParameterizedTest
public void shouldOnlyEnrollOnce(String shouldEnrollOnce) throws Exception {
// arrange
String program = programActions.createTrackerProgram(Constants.TRACKED_ENTITY_TYPE, Constants.ORG_UNIT_IDS).extractUid();
JsonObject object = programActions.get(program).getBodyAsJsonBuilder().addProperty("onlyEnrollOnce", shouldEnrollOnce).addProperty("publicAccess", "rwrw----").build();
programActions.update(program, object).validateStatus(200);
String tei = super.importTei();
JsonObject enrollment = new EnrollmentDataBuilder().setId(new IdGenerator().generateUniqueId()).array(program, Constants.ORG_UNIT_IDS[2], tei, "COMPLETED");
trackerActions.postAndGetJobReport(enrollment).validateSuccessfulImport();
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(new EnrollmentDataBuilder().array(program, Constants.ORG_UNIT_IDS[2], tei, "ACTIVE"));
// assert
if (Boolean.parseBoolean(shouldEnrollOnce)) {
response.validateErrorReport().body("errorCode", hasItems("E1016"));
return;
}
response.validateSuccessfulImport();
trackerActions.getTrackedEntity(tei + "?fields=enrollments").validate().body("enrollments", hasSize(2));
}
use of org.junit.jupiter.params.provider.ValueSource in project dhis2-core by dhis2.
the class EnrollmentsTests method shouldImportTeisWithEnrollments.
@ParameterizedTest
@ValueSource(strings = { "src/test/resources/tracker/importer/teis/teiWithEnrollments.json", "src/test/resources/tracker/importer/teis/teiAndEnrollment.json" })
public void shouldImportTeisWithEnrollments(String file) {
TrackerApiResponse response = trackerActions.postAndGetJobReport(new File(file));
response.validateSuccessfulImport().validate().body("status", Matchers.equalTo("OK")).body("stats.created", equalTo(2));
response.validateTeis().body("stats.created", Matchers.equalTo(1));
response.validateEnrollments().body("stats.created", Matchers.equalTo(1));
// assert that the tei was imported
String teiId = response.extractImportedTeis().get(0);
String enrollmentId = response.extractImportedEnrollments().get(0);
trackerActions.get("/enrollments/" + enrollmentId).validate().statusCode(200).body("trackedEntity", equalTo(teiId));
}
use of org.junit.jupiter.params.provider.ValueSource in project dhis2-core by dhis2.
the class EnrollmentsTests method shouldAllowFutureEnrollments.
@ParameterizedTest
@ValueSource(strings = { "true", "false " })
public void shouldAllowFutureEnrollments(String shouldAddFutureDays) throws Exception {
// arrange
JsonObject object = programActions.get(multipleEnrollmentsProgram).getBodyAsJsonBuilder().addProperty("selectEnrollmentDatesInFuture", shouldAddFutureDays).build();
programActions.update(multipleEnrollmentsProgram, object).validateStatus(200);
String teiId = importTei();
// act
JsonObject enrollment = new EnrollmentDataBuilder().setTei(teiId).setEnrollmentDate(Instant.now().plus(2, ChronoUnit.DAYS).toString()).addEvent(new EventDataBuilder().setProgram(multipleEnrollmentsProgram).setOu(Constants.ORG_UNIT_IDS[0]).setProgramStage(multipleEnrollmentsProgramStage)).array(multipleEnrollmentsProgram, Constants.ORG_UNIT_IDS[0]);
// assert
TrackerApiResponse response = trackerActions.postAndGetJobReport(enrollment, new QueryParamsBuilder().add("async", "false"));
if (Boolean.parseBoolean(shouldAddFutureDays)) {
response.validateSuccessfulImport();
return;
}
response.validateErrorReport().body("errorCode", hasSize(1)).body("errorCode", hasItems("E1020"));
}
use of org.junit.jupiter.params.provider.ValueSource 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)));
}
Aggregations