use of org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder in project dhis2-core by dhis2.
the class EnrollmentsTests method shouldAddNote.
@Test
public void shouldAddNote() {
String enrollmentId = trackerActions.postAndGetJobReport(new TeiDataBuilder().buildWithEnrollment(Constants.ORG_UNIT_IDS[0], Constants.TRACKER_PROGRAM_ID)).extractImportedEnrollments().get(0);
JsonObject payload = trackerActions.getEnrollment(enrollmentId).getBodyAsJsonBuilder().addOrAppendToArray("notes", new JsonObjectBuilder().addProperty("value", DataGenerator.randomString()).build()).wrapIntoArray("enrollments");
trackerActions.postAndGetJobReport(payload).validateSuccessfulImport().validate().body("stats.updated", equalTo(1));
trackerActions.getEnrollment(enrollmentId + "?fields=notes").validate().statusCode(200).rootPath("notes").body("note", notNullValue()).body("storedAt", notNullValue()).body("updatedAt", notNullValue()).body("value", notNullValue()).body("storedBy", CoreMatchers.everyItem(equalTo("taadmin")));
}
use of org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder in project dhis2-core by dhis2.
the class TeiValidationTests method shouldReturnErrorReportsWhenTeiIncorrect.
@Test
public void shouldReturnErrorReportsWhenTeiIncorrect() {
// arrange
JsonObject trackedEntities = new TeiDataBuilder().array("", Constants.ORG_UNIT_IDS[0]);
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(trackedEntities);
// assert
response.validateErrorReport().body("errorCode", hasItem("E1121"));
}
use of org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder in project dhis2-core by dhis2.
the class EventValidationTests method setupData.
private void setupData() {
eventProgramStageId = programActions.programStageActions.get("", new QueryParamsBuilder().add("filter=program.id:eq:" + eventProgramId)).extractString("programStages.id[0]");
assertNotNull(eventProgramStageId, "Failed to find a program stage");
trackerProgramStageId = programActions.programStageActions.get("", new QueryParamsBuilder().addAll("filter=program.id:eq:" + trackerProgramId, "filter=repeatable:eq:true")).extractString("programStages.id[0]");
ouIdWithoutAccess = new OrgUnitActions().createOrgUnit();
new UserActions().grantCurrentUserAccessToOrgUnit(ouIdWithoutAccess);
enrollment = trackerActions.postAndGetJobReport(new TeiDataBuilder().buildWithEnrollment(OU_ID, trackerProgramId)).validateSuccessfulImport().extractImportedEnrollments().get(0);
}
use of org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder in project dhis2-core by dhis2.
the class TeiValidationTests method shouldReturnErrorWhenMandatoryAttributesMissing.
@Test
public void shouldReturnErrorWhenMandatoryAttributesMissing() {
// arrange
JsonObject trackedEntities = new TeiDataBuilder().array(trackedEntityType, Constants.ORG_UNIT_IDS[0]);
// assert
TrackerApiResponse response = trackerActions.postAndGetJobReport(trackedEntities);
response.validateErrorReport().body("errorCode", hasItem("E1090"));
}
use of org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder in project dhis2-core by dhis2.
the class TeiValidationTests method shouldReturnErrorWhenMandatoryProgramAttributeMissing.
@Test
public void shouldReturnErrorWhenMandatoryProgramAttributeMissing() {
// arrange
JsonObject trackedEntities = new TeiDataBuilder().buildWithEnrollment(trackedEntityType, Constants.ORG_UNIT_IDS[0], program);
// assert
TrackerApiResponse response = trackerActions.postAndGetJobReport(trackedEntities);
response.validateErrorReport().body("trackerType", hasItem("ENROLLMENT")).body("errorCode", hasItem("E1018"));
}
Aggregations