Search in sources :

Example 1 with EventDataBuilder

use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.

the class RuleEngineTests method shouldShowErrorOnCompleteOnEvents.

@Test
public void shouldShowErrorOnCompleteOnEvents() {
    JsonObject payload = new EventDataBuilder().setStatus("COMPLETED").array(Constants.ORG_UNIT_IDS[0], eventProgramId, "Mt6Ac5brjoK");
    TrackerApiResponse response = trackerActions.postAndGetJobReport(payload);
    response.validateErrorReport().body("trackerType", hasItem("EVENT")).body("message", hasItem(stringContainsInOrder("ERROR ON COMPLETE ")));
}
Also used : EventDataBuilder(org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder) 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 2 with EventDataBuilder

use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder in project dhis2-core by dhis2.

the class RuleEngineTests method shouldSendProgramRuleNotification.

@Test
public void shouldSendProgramRuleNotification() {
    JsonObject payload = new EventDataBuilder().addDataValue("ILRgzHhzFkg", "true").addDataValue("z3Z4TD3oBCP", "true").addDataValue("BuZ5LGNfGEU", "40").array(Constants.ORG_UNIT_IDS[0], eventProgramId, "Mt6Ac5brjoK");
    loginActions.loginAsAdmin();
    ApiResponse response = new RestApiActions("/messageConversations").get("", new QueryParamsBuilder().add("fields=*"));
    int size = response.getBody().getAsJsonArray("messageConversations").size();
    loginActions.loginAsSuperUser();
    trackerActions.postAndGetJobReport(payload).validateSuccessfulImport();
    loginActions.loginAsAdmin();
    messageConversationsActions.waitForNotification(size + 1);
    messageConversationsActions.get("", new QueryParamsBuilder().add("fields=*")).validate().statusCode(200).body("messageConversations", hasSize(size + 1)).body("messageConversations.subject", hasItem("Program rule triggered"));
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) EventDataBuilder(org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) ApiResponse(org.hisp.dhis.dto.ApiResponse) 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 3 with EventDataBuilder

use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder 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 4 with EventDataBuilder

use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder 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 5 with EventDataBuilder

use of org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder 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)

Aggregations

JsonObject (com.google.gson.JsonObject)17 EventDataBuilder (org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder)17 TrackerApiResponse (org.hisp.dhis.dto.TrackerApiResponse)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)16 TrackerNtiApiTest (org.hisp.dhis.tracker.TrackerNtiApiTest)11 Test (org.junit.jupiter.api.Test)11 QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)6 EnrollmentDataBuilder (org.hisp.dhis.tracker.importer.databuilder.EnrollmentDataBuilder)3 CsvSource (org.junit.jupiter.params.provider.CsvSource)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)2 RestApiActions (org.hisp.dhis.actions.RestApiActions)1 ProgramStageActions (org.hisp.dhis.actions.metadata.ProgramStageActions)1 ApiResponse (org.hisp.dhis.dto.ApiResponse)1 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1