Search in sources :

Example 6 with TeiDataBuilder

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")));
}
Also used : TeiDataBuilder(org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder) JsonObject(com.google.gson.JsonObject) JsonObjectBuilder(org.hisp.dhis.helpers.JsonObjectBuilder) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with TeiDataBuilder

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"));
}
Also used : TeiDataBuilder(org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder) JsonObject(com.google.gson.JsonObject) TrackerApiResponse(org.hisp.dhis.dto.TrackerApiResponse) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest)

Example 8 with TeiDataBuilder

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);
}
Also used : OrgUnitActions(org.hisp.dhis.actions.metadata.OrgUnitActions) TeiDataBuilder(org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) UserActions(org.hisp.dhis.actions.UserActions)

Example 9 with TeiDataBuilder

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"));
}
Also used : TeiDataBuilder(org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder) JsonObject(com.google.gson.JsonObject) TrackerApiResponse(org.hisp.dhis.dto.TrackerApiResponse) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest)

Example 10 with TeiDataBuilder

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"));
}
Also used : TeiDataBuilder(org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder) JsonObject(com.google.gson.JsonObject) TrackerApiResponse(org.hisp.dhis.dto.TrackerApiResponse) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest)

Aggregations

TeiDataBuilder (org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder)13 JsonObject (com.google.gson.JsonObject)11 Test (org.junit.jupiter.api.Test)9 TrackerApiResponse (org.hisp.dhis.dto.TrackerApiResponse)8 TrackerNtiApiTest (org.hisp.dhis.tracker.TrackerNtiApiTest)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)5 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1 RestApiActions (org.hisp.dhis.actions.RestApiActions)1 UserActions (org.hisp.dhis.actions.UserActions)1 OrgUnitActions (org.hisp.dhis.actions.metadata.OrgUnitActions)1 ProgramStageActions (org.hisp.dhis.actions.metadata.ProgramStageActions)1 TrackerActions (org.hisp.dhis.actions.tracker.importer.TrackerActions)1 ApiResponse (org.hisp.dhis.dto.ApiResponse)1 PotentialDuplicatesApiTest (org.hisp.dhis.tracker.deduplication.PotentialDuplicatesApiTest)1 CsvSource (org.junit.jupiter.params.provider.CsvSource)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1