use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class EventsDataValueValidationTests method shouldImportEventsWithCompulsoryDataValues.
@Test
public void shouldImportEventsWithCompulsoryDataValues() {
JsonObject events = new EventDataBuilder().addDataValue(mandatoryDataElementId, "TEXT value").array(OU_ID, programId, programStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(events);
response.validateSuccessfulImport().validateEvents().body("stats.created", Matchers.equalTo(1)).body("objectReports", notNullValue()).body("objectReports[0].errorReports", empty());
String eventId = response.extractImportedEvents().get(0);
trackerActions.get("/events/" + eventId).validate().statusCode(200).body("dataValues", not(Matchers.emptyArray()));
}
use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class UserAssignmentTests method createEvents.
private TrackerApiResponse createEvents(String programId, String programStageId, String assignedUserId) {
JsonObject jsonObject = new EventDataBuilder().setAssignedUser(assignedUserId).array(Constants.ORG_UNIT_IDS[0], programId, programStageId);
TrackerApiResponse eventResponse = trackerActions.postAndGetJobReport(jsonObject);
eventResponse.validateSuccessfulImport();
return eventResponse;
}
use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder 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.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class EventValidationTests method eventImportShouldValidateReferences.
@ParameterizedTest
@MethodSource("provideValidationArguments")
public void eventImportShouldValidateReferences(String ouId, String programId, String programStageId, String errorCode) {
JsonObject jsonObject = new EventDataBuilder().array(ouId, programId, programStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(jsonObject);
response.validateErrorReport().body("errorCode", hasItem(equalTo(errorCode)));
}
use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class EventsTests method shouldAddEventsToExistingTei.
@Test
public void shouldAddEventsToExistingTei() throws Exception {
String programId = Constants.TRACKER_PROGRAM_ID;
String programStageId = "nlXNK4b7LVr";
TrackerApiResponse response = importTeiWithEnrollment(programId);
String enrollmentId = response.extractImportedEnrollments().get(0);
JsonObject event = new EventDataBuilder().setEnrollment(enrollmentId).array(Constants.ORG_UNIT_IDS[1], programId, programStageId);
response = trackerActions.postAndGetJobReport(event).validateSuccessfulImport();
String eventId = response.extractImportedEvents().get(0);
trackerActions.get("/events/" + eventId + "?fields=*").validate().statusCode(200).body("enrollment", equalTo(enrollmentId));
}
Aggregations