Search in sources :

Example 26 with QueryParamsBuilder

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

Example 27 with QueryParamsBuilder

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

the class AtomicModeTests method shouldNotImportWhenErrorsWithoutAtomicMode.

@Test
public void shouldNotImportWhenErrorsWithoutAtomicMode() throws Exception {
    TrackerApiResponse response = trackerActions.postAndGetJobReport(createWrongPayload(), new QueryParamsBuilder().add("atomicMode=ALL"));
    response.validate().body("status", equalTo("ERROR")).body("stats.ignored", equalTo(3));
    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)

Example 28 with QueryParamsBuilder

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

the class OwnershipTests method beforeAll.

@BeforeAll
public void beforeAll() throws Exception {
    userActions = new UserActions();
    programActions = new ProgramActions();
    loginActions.loginAsSuperUser();
    username = createUserWithAccessToOu();
    protectedProgram = programActions.createProgramWithAccessLevel("PROTECTED", captureOu, searchOu);
    openProgram = programActions.createProgramWithAccessLevel("OPEN", captureOu, searchOu);
    String protectedProgramStageId = programActions.get(protectedProgram, new QueryParamsBuilder().add("fields=programStages")).validateStatus(200).extractString("programStages.id[0]");
    teiInCaptureScope = super.importTeiWithEnrollmentAndEvent(captureOu, protectedProgram, protectedProgramStageId).extractImportedTeis().get(0);
    teiInSearchScope = super.importTeiWithEnrollmentAndEvent(searchOu, protectedProgram, protectedProgramStageId).extractImportedTeis().get(0);
    enrollment = trackerActions.getTrackedEntity(teiInSearchScope + "?fields=enrollments").validateStatus(200).getBody();
    trackerActions.update(String.format("/ownership/transfer?trackedEntityInstance=%s&program=%s&ou=%s", teiInCaptureScope, protectedProgram, searchOu), new JsonObject()).validateStatus(200);
}
Also used : ProgramActions(org.hisp.dhis.actions.metadata.ProgramActions) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) UserActions(org.hisp.dhis.actions.UserActions) JsonObject(com.google.gson.JsonObject) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 29 with QueryParamsBuilder

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

the class SideEffectsTests method shouldSendNotificationIfNotSkipSideEffects.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void shouldSendNotificationIfNotSkipSideEffects(Boolean shouldSkipSideEffects) {
    JsonObject object = new TeiDataBuilder().buildWithEnrollmentAndEvent(Constants.TRACKED_ENTITY_TYPE, Constants.ORG_UNIT_IDS[0], trackerProgramId, trackerProgramStageId, "COMPLETED");
    ApiResponse response = new RestApiActions("/messageConversations").get("", new QueryParamsBuilder().add("fields=*"));
    int size = response.getBody().getAsJsonArray("messageConversations").size();
    trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("skipSideEffects=" + shouldSkipSideEffects)).validateSuccessfulImport();
    int expectedCount = (shouldSkipSideEffects) ? size : size + 1;
    response = messageConversationsActions.waitForNotification(expectedCount);
    response.validate().statusCode(200).body("messageConversations", hasSize(expectedCount));
    if (shouldSkipSideEffects) {
        return;
    }
    response.validate().body("messageConversations.subject", hasItem("TA program stage completion"));
}
Also used : TeiDataBuilder(org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder) RestApiActions(org.hisp.dhis.actions.RestApiActions) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) ApiResponse(org.hisp.dhis.dto.ApiResponse) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with QueryParamsBuilder

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

the class MetadataPatchTests method shouldReturnErrors.

@Disabled("DHIS2-11434")
@Test
public void shouldReturnErrors() {
    JsonObject object = JsonObjectBuilder.jsonObject().addProperty("op", "remove").addProperty("path", "/dataElementGroups").build();
    dataElementActions.patch(dataElementId, Arrays.asList(object), new QueryParamsBuilder().add("importReportMode", "ERRORS_NOT_OWNER")).validate().statusCode(200).body("response.errorReports", hasSize(1));
    dataElementActions.get(dataElementId).validate().body("dataElementGroups", hasSize(0));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest) Disabled(org.junit.jupiter.api.Disabled)

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