use of org.hisp.dhis.tracker.importer.databuilder.EnrollmentDataBuilder in project dhis2-core by dhis2.
the class EnrollmentAttributeTests method shouldAddAttributeValue.
@Test
public void shouldAddAttributeValue() throws Exception {
String tei = importTei();
JsonObject payload = new EnrollmentDataBuilder().setTei(tei).addAttribute(optionSetAttributeId, "TA_YES").array(programId, Constants.ORG_UNIT_IDS[1]);
trackerActions.postAndGetJobReport(payload, new QueryParamsBuilder().add("async=false")).validateSuccessfulImport();
trackerActions.getTrackedEntity(tei + "?program=" + programId).validateStatus(200).validate().statusCode(200).body("attributes", hasSize(greaterThanOrEqualTo(1))).body("attributes.attribute", hasItem(optionSetAttributeId)).body("attributes.value", hasItem("TA_YES"));
}
use of org.hisp.dhis.tracker.importer.databuilder.EnrollmentDataBuilder 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));
}
Aggregations