use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EventImportDataValueValidationTests method shouldValidateDataValuesOnUpdate.
@Test
public void shouldValidateDataValuesOnUpdate() {
programActions.programStageActions.setValidationStrategy(programStageId, "ON_UPDATE_AND_INSERT");
JsonObject events = eventActions.createEventBody(OU_ID, programId, programStageId);
ApiResponse response = eventActions.post(events, new QueryParamsBuilder().add("skipCache=true"));
response.validate().statusCode(409).body("status", equalTo("ERROR")).rootPath("response").body("ignored", equalTo(1)).body("imported", equalTo(0)).body("importSummaries[0].conflicts[0].value", equalTo("value_required_but_not_provided"));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder 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.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EventIdSchemeTests method eventsShouldBeImportedWithProgramScheme.
@ParameterizedTest
@MethodSource("provideIdSchemeArguments")
public void eventsShouldBeImportedWithProgramScheme(String scheme, String property) throws Exception {
// arrange
String programPropertyValue = programActions.get(PROGRAM_ID).extractString(property);
assertNotNull(programPropertyValue, String.format("Program property %s was not present.", property));
JsonObject object = new FileReaderUtils().read(new File("src/test/resources/tracker/importer/events/event.json")).replacePropertyValuesWithIds("event").replacePropertyValuesWith("orgUnit", orgUnitId).replacePropertyValuesWith("program", programPropertyValue).replacePropertyValuesWith("programStage", PROGRAM_STAGE_ID).get(JsonObject.class);
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("programIdScheme=" + scheme));
// assert
String eventId = response.validateSuccessfulImport().extractImportedEvents().get(0);
assertNotNull("Event was not created", eventId);
trackerActions.get("/events/" + eventId).validate().statusCode(200).body("program", equalTo(PROGRAM_ID));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EventIdSchemeTests method eventsShouldBeImportedWithOrgUnitScheme.
@ParameterizedTest
@MethodSource("provideIdSchemeArguments")
public void eventsShouldBeImportedWithOrgUnitScheme(String ouScheme, String ouProperty) throws Exception {
String ouPropertyValue = orgUnitActions.get(orgUnitId).extractString(ouProperty);
assertNotNull(ouPropertyValue, String.format("Org unit property %s was not present.", ouProperty));
JsonObject object = new FileReaderUtils().read(new File("src/test/resources/tracker/importer/events/event.json")).replacePropertyValuesWith("orgUnit", ouPropertyValue).replacePropertyValuesWithIds("event").get(JsonObject.class);
TrackerApiResponse response = trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("orgUnitIdScheme=" + ouScheme));
String eventId = response.validateSuccessfulImport().extractImportedEvents().get(0);
trackerActions.get("/events/" + eventId).validate().statusCode(200).body("orgUnit", equalTo(orgUnitId));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EventExportTests method shouldUseCorrectScopeWhenNoOu.
@ParameterizedTest(name = "{0}")
@MethodSource
public void shouldUseCorrectScopeWhenNoOu(String description, String program, List<String> expectedOrgUnits) {
loginActions.loginAsUser(userName, password);
QueryParamsBuilder builder = new QueryParamsBuilder();
if (program != null) {
builder.add("program", program);
}
eventActions.get(builder.build()).validate().statusCode(200).body("events.orgUnit", everyItem(in(expectedOrgUnits)));
}
Aggregations