Search in sources :

Example 16 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.

the class RuleEngineTests method shouldBeSkippedWhenSkipRuleEngineFlag.

@Test
public void shouldBeSkippedWhenSkipRuleEngineFlag() {
    JsonObject payload = new EventDataBuilder().setStatus("COMPLETED").array(Constants.ORG_UNIT_IDS[0], eventProgramId, "Mt6Ac5brjoK");
    TrackerApiResponse response = trackerActions.postAndGetJobReport(payload, new QueryParamsBuilder().add("skipRuleEngine=true"));
    response.validateSuccessfulImport();
}
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 17 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.

the class RuleEngineTests method shouldShowErrorOnCompleteInTrackerEvents.

@Test
public void shouldShowErrorOnCompleteInTrackerEvents() throws Exception {
    String tei = importTei();
    JsonObject enrollment = new EnrollmentDataBuilder().setTei(tei).setEnrollmentDate(Instant.now().plus(1, ChronoUnit.DAYS).toString()).array(trackerProgramId, Constants.ORG_UNIT_IDS[0]);
    String enrollmentId = trackerActions.postAndGetJobReport(enrollment).validateSuccessfulImport().extractImportedEnrollments().get(0);
    JsonObject payload = new EventDataBuilder().setEnrollment(enrollmentId).setStatus("COMPLETED").array(Constants.ORG_UNIT_IDS[0], trackerProgramId, "nH8zfPSUSN1");
    trackerActions.postAndGetJobReport(payload, new QueryParamsBuilder().add("async=false")).validateErrorReport().body("trackerType", hasItem("EVENT")).body("message", hasItem(stringContainsInOrder("ERROR ON COMPLETE ")));
}
Also used : EventDataBuilder(org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) EnrollmentDataBuilder(org.hisp.dhis.tracker.importer.databuilder.EnrollmentDataBuilder) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder 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 19 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder 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 20 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.

the class TrackerExportTests method shouldReturnTeisMatchingAttributeCriteria.

@MethodSource()
@ParameterizedTest
public void shouldReturnTeisMatchingAttributeCriteria(String operator, String searchCriteria, Matcher everyItemMatcher) {
    QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder().add("orgUnit", "O6uvpzGd5pu").add("program", Constants.TRACKER_PROGRAM_ID).add("attribute", String.format("kZeSYCgaHTk:%s:%s", operator, searchCriteria));
    trackerActions.getTrackedEntities(queryParamsBuilder).validate().statusCode(200).body("instances", hasSize(greaterThanOrEqualTo(1))).body("instances.attributes.flatten().findAll { it.attribute == 'kZeSYCgaHTk' }.value", everyItem(everyItemMatcher));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)90 JsonObject (com.google.gson.JsonObject)54 Test (org.junit.jupiter.api.Test)51 ApiResponse (org.hisp.dhis.dto.ApiResponse)49 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 ApiTest (org.hisp.dhis.ApiTest)27 TrackerApiResponse (org.hisp.dhis.dto.TrackerApiResponse)21 File (java.io.File)20 TrackerNtiApiTest (org.hisp.dhis.tracker.TrackerNtiApiTest)20 FileReaderUtils (org.hisp.dhis.helpers.file.FileReaderUtils)14 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 ValueSource (org.junit.jupiter.params.provider.ValueSource)9 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)8 EventDataBuilder (org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder)6 TeiDataBuilder (org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder)5 ProgramActions (org.hisp.dhis.actions.metadata.ProgramActions)4 JsonArray (com.google.gson.JsonArray)3 HashMap (java.util.HashMap)3 ProgramStageActions (org.hisp.dhis.actions.metadata.ProgramStageActions)3 ImportSummary (org.hisp.dhis.dto.ImportSummary)3