Search in sources :

Example 6 with TrackerApiResponse

use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.

the class RuleEngineTests method shouldAssignValue.

@Test
public void shouldAssignValue() {
    JsonObject payload = new EventDataBuilder().array(Constants.ORG_UNIT_IDS[0], eventProgramId, "Mt6Ac5brjoK");
    TrackerApiResponse response = trackerActions.postAndGetJobReport(payload, new QueryParamsBuilder().addAll("skipSideEffects=true"));
    response.validateSuccessfulImport().validateWarningReport().body("warningCode", contains("E1308"));
    String eventId = response.extractImportedEvents().get(0);
    trackerActions.get("/events/" + eventId).validate().body("dataValues", hasSize(1)).body("dataValues.value", contains("AUTO_ASSIGNED_COMMENT"));
}
Also used : EventDataBuilder(org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) TrackerApiResponse(org.hisp.dhis.dto.TrackerApiResponse) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with TrackerApiResponse

use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.

the class RuleEngineTests method shouldImportWhenWarnings.

@Test
public void shouldImportWhenWarnings() {
    // arrange
    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("message[0]", containsString("TA warning")).body("warningCode", everyItem(equalTo("E1300")));
    response.validateSuccessfulImport();
}
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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with TrackerApiResponse

use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.

the class TrackerExportTests method singleTeiAndCollectionTeiShouldReturnSameResult.

@Test
public void singleTeiAndCollectionTeiShouldReturnSameResult() throws JSONException {
    TrackerApiResponse trackedEntity = trackerActions.getTrackedEntity("Kj6vYde4LHh", new QueryParamsBuilder().add("fields", "*").add("includeAllAttributes", "true"));
    TrackerApiResponse trackedEntities = trackerActions.getTrackedEntities(new QueryParamsBuilder().add("fields", "*").add("includeAllAttributes", "true").add("trackedEntity", "Kj6vYde4LHh").add("orgUnit", "O6uvpzGd5pu"));
    JSONAssert.assertEquals(trackedEntity.getBody().toString(), trackedEntities.extractJsonObject("instances[0]").toString(), false);
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) TrackerApiResponse(org.hisp.dhis.dto.TrackerApiResponse) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with TrackerApiResponse

use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.

the class TrackerExportTests method beforeAll.

@BeforeAll
public void beforeAll() throws Exception {
    loginActions.loginAsSuperUser();
    TrackerApiResponse response = importTeiWithEnrollmentAndEvent();
    teiId = response.validateSuccessfulImport().extractImportedTeis().get(0);
    enrollmentId = response.extractImportedEnrollments().get(0);
    relationshipId = response.extractImportedRelationships().get(0);
    eventId = response.extractImportedEvents().get(0);
}
Also used : TrackerApiResponse(org.hisp.dhis.dto.TrackerApiResponse) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 10 with TrackerApiResponse

use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.

the class AtomicModeTests method shouldImportWhenErrorsWithAtomicMode.

@Test
public void shouldImportWhenErrorsWithAtomicMode() throws Exception {
    TrackerApiResponse response = trackerActions.postAndGetJobReport(createWrongPayload(), new QueryParamsBuilder().addAll("atomicMode=OBJECT"));
    response.validate().body("status", equalTo("OK")).body("stats.ignored", equalTo(2)).body("stats.created", equalTo(1));
    response.validateErrorReport().body("", hasSize(2)).body("trackerType", contains("TRACKED_ENTITY", "RELATIONSHIP"));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) TrackerApiResponse(org.hisp.dhis.dto.TrackerApiResponse) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest)

Aggregations

TrackerApiResponse (org.hisp.dhis.dto.TrackerApiResponse)53 JsonObject (com.google.gson.JsonObject)44 Test (org.junit.jupiter.api.Test)35 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 TrackerNtiApiTest (org.hisp.dhis.tracker.TrackerNtiApiTest)32 QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)17 EventDataBuilder (org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder)15 File (java.io.File)14 FileReaderUtils (org.hisp.dhis.helpers.file.FileReaderUtils)11 ApiResponse (org.hisp.dhis.dto.ApiResponse)9 TeiDataBuilder (org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder)8 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)5 CsvSource (org.junit.jupiter.params.provider.CsvSource)5 ValueSource (org.junit.jupiter.params.provider.ValueSource)5 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 PotentialDuplicatesApiTest (org.hisp.dhis.tracker.deduplication.PotentialDuplicatesApiTest)3 EnrollmentDataBuilder (org.hisp.dhis.tracker.importer.databuilder.EnrollmentDataBuilder)3 IdGenerator (org.hisp.dhis.actions.IdGenerator)2 ProgramStageActions (org.hisp.dhis.actions.metadata.ProgramStageActions)2 JsonFileReader (org.hisp.dhis.helpers.file.JsonFileReader)1