use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class RuleEngineTests method shouldShowErrorOnEventWhenProgramRuleStageMatches.
@ParameterizedTest
@CsvSource({ "nH8zfPSUSN1,true", "yKg8CY252Yk,false" })
public void shouldShowErrorOnEventWhenProgramRuleStageMatches(String programStage, boolean shouldReturnError) throws Exception {
// arrange
String tei = importTei();
String enrollment = trackerActions.postAndGetJobReport(new EnrollmentDataBuilder().setTei(tei).setEnrollmentDate(Instant.now().plus(1, ChronoUnit.DAYS).toString()).array(trackerProgramId, Constants.ORG_UNIT_IDS[0])).extractImportedEnrollments().get(0);
JsonObject payload = new EventDataBuilder().setEnrollment(enrollment).array(Constants.ORG_UNIT_IDS[0], trackerProgramId, programStage);
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(payload);
if (!shouldReturnError) {
response.validateSuccessfulImport();
return;
}
response.validateErrorReport().body("trackerType", Matchers.everyItem(equalTo("EVENT"))).body("message", Matchers.contains(containsString("TA on stage error")));
response.validate().body("stats.created", equalTo(0));
}
use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.
the class RuleEngineTests method shouldSetMandatoryField.
@Test
public void shouldSetMandatoryField() {
JsonObject payload = new EventDataBuilder().addDataValue("ILRgzHhzFkg", "true").array(Constants.ORG_UNIT_IDS[0], eventProgramId, "Mt6Ac5brjoK");
TrackerApiResponse response = trackerActions.postAndGetJobReport(payload);
response.validateErrorReport().body("errorCode", hasItem("E1301")).body("message", hasItem(stringContainsInOrder("Mandatory DataElement", "is not present")));
}
Aggregations