use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class EventValidationTests method shouldValidateEventProperties.
@CsvSource({ "ACTIVE,,OccurredAt date is missing.", "SCHEDULE,,ScheduledAt date is missing." })
@ParameterizedTest
public void shouldValidateEventProperties(String status, String occurredAt, String error) {
JsonObject object = new EventDataBuilder().setStatus(status).setEventDate(occurredAt).setEnrollment(enrollment).array(OU_ID, trackerProgramId, trackerProgramStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(object);
response.validateErrorReport().body("message[0]", containsStringIgnoringCase(error));
}
use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class EventValidationTests method eventImportShouldPassValidationWhenOnlyEventProgramIsDefined.
@Test
public void eventImportShouldPassValidationWhenOnlyEventProgramIsDefined() {
JsonObject jsonObject = new EventDataBuilder().array(OU_ID, eventProgramId, null);
TrackerApiResponse response = trackerActions.postAndGetJobReport(jsonObject);
response.validateSuccessfulImport();
}
use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class EventValidationTests method eventImportShouldValidateProgramFromProgramStage.
@Test
public void eventImportShouldValidateProgramFromProgramStage() {
JsonObject jsonObject = new EventDataBuilder().setEnrollment(enrollment).array(OU_ID, anotherTrackerProgramId, trackerProgramStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(jsonObject);
response.validateErrorReport().body("errorCode", hasItem(equalTo("E1079")));
}
use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class EventValidationTests method shouldSetDueDate.
@Test
public void shouldSetDueDate() {
JsonObject eventBody = new EventDataBuilder().setEnrollment(enrollment).array(OU_ID, trackerProgramId, trackerProgramStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(eventBody);
String eventId = response.validateSuccessfulImport().extractImportedEvents().get(0);
JsonObject event = trackerActions.get("/events/" + eventId).getBody();
assertEquals(event.get("eventDate"), event.get("dueDate"));
}
use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class EventsTests method shouldImportToRepeatableStage.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void shouldImportToRepeatableStage(Boolean repeatableStage) throws Exception {
// arrange
String program = Constants.TRACKER_PROGRAM_ID;
String programStage = new ProgramStageActions().get("", new QueryParamsBuilder().addAll("filter=program.id:eq:" + program, "filter=repeatable:eq:" + repeatableStage)).extractString("programStages.id[0]");
TrackerApiResponse response = importTeiWithEnrollment(program);
String teiId = response.extractImportedTeis().get(0);
String enrollmentId = response.extractImportedEnrollments().get(0);
JsonObject event = new EventDataBuilder().setEnrollment(enrollmentId).setTei(teiId).array(Constants.ORG_UNIT_IDS[0], program, programStage).getAsJsonArray("events").get(0).getAsJsonObject();
JsonObject payload = new JsonObjectBuilder().addArray("events", event, event).build();
// act
response = trackerActions.postAndGetJobReport(payload);
// assert
if (repeatableStage) {
response.validateSuccessfulImport().validate().body("stats.created", equalTo(2));
} else {
response.validateErrorReport().body("errorCode", hasItem("E1039"));
}
}
Aggregations