use of org.hisp.dhis.dto.TrackerApiResponse 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.dto.TrackerApiResponse 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")));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class RuleEngineTests method shouldAddErrorForEnrollmentsAndEventsWhenRuleHasNoStage.
@Test
public void shouldAddErrorForEnrollmentsAndEventsWhenRuleHasNoStage() {
JsonObject object = new TeiDataBuilder().buildWithEnrollmentAndEvent(Constants.TRACKED_ENTITY_TYPE, Constants.ORG_UNIT_IDS[0], trackerProgramId, "yKg8CY252Yk");
JsonObjectBuilder.jsonObject(object).addPropertyByJsonPath("trackedEntities[0].enrollments[0].enrolledAt", Instant.now().minus(1, ChronoUnit.DAYS).toString());
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(object);
response.validateWarningReport().body("", hasSize(greaterThanOrEqualTo(1))).body("trackerType", hasItems("ENROLLMENT")).body("warningCode", everyItem(equalTo("E1300")));
}
Aggregations