Search in sources :

Example 66 with QueryParamsBuilder

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

the class EventImportTests method eventsImportNewEventsFromFile.

@ParameterizedTest
@MethodSource("provideEventFilesTestArguments")
public void eventsImportNewEventsFromFile(String fileName, String contentType) throws Exception {
    Object obj = new FileReaderUtils().read(new File("src/test/resources/tracker/events/" + fileName)).replacePropertyValuesWithIds("event").get();
    ApiResponse response = eventActions.post("", contentType, obj, new QueryParamsBuilder().addAll("dryRun=false", "eventIdScheme=UID", "orgUnitIdScheme=UID", "skipFirst=true", "async=true"));
    response.validate().statusCode(200);
    String taskId = response.extractString("response.id");
    assertNotNull(taskId, "Task id was not returned");
    systemActions.waitUntilTaskCompleted("EVENT_IMPORT", taskId);
    List<ImportSummary> importSummaries = systemActions.getTaskSummaries("EVENT_IMPORT", taskId);
    assertThat("Wrong import summaries size", importSummaries.size(), Matchers.greaterThan(0));
    createdEvents.addAll(importSummaries.stream().map(ImportSummary::getReference).collect(toList()));
    assertThat(importSummaries, Matchers.everyItem(hasProperty("status", Matchers.equalTo("SUCCESS"))));
}
Also used : FileReaderUtils(org.hisp.dhis.helpers.file.FileReaderUtils) ImportSummary(org.hisp.dhis.dto.ImportSummary) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) File(java.io.File) ApiResponse(org.hisp.dhis.dto.ApiResponse) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 67 with QueryParamsBuilder

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

the class TrackerImporterImportModeTests method shouldNotCommitWhenImportModeIsValidate.

@Test
public void shouldNotCommitWhenImportModeIsValidate() {
    ApiResponse response = trackerActions.postAndGetJobReport(new File("src/test/resources/tracker/importer/teis/tei.json"), new QueryParamsBuilder().add("importMode=VALIDATE"));
    response.validate().statusCode(200).body("status", equalTo("OK")).body("stats.created", equalTo(0)).body("stats.total", equalTo(0)).body("validationReport", notNullValue()).body("validationReport.errorReports", empty()).body("validationReport.warningReports", empty());
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) File(java.io.File) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) TrackerNtiApiTest(org.hisp.dhis.tracker.TrackerNtiApiTest)

Example 68 with QueryParamsBuilder

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

the class PotentialDuplicatesAttributeMergeTests method beforeEach.

@BeforeEach
public void beforeEach() {
    loginActions.loginAsAdmin();
    attributes = new ProgramActions().get(program, new QueryParamsBuilder().addAll("filter=programTrackedEntityAttributes.valueType:eq:TEXT")).extractList("programTrackedEntityAttributes.trackedEntityAttribute.id", String.class);
}
Also used : ProgramActions(org.hisp.dhis.actions.metadata.ProgramActions) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 69 with QueryParamsBuilder

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

the class EventExportTests method shouldUseCorrectScopeWhenOuModeIsProvided.

@ParameterizedTest
@MethodSource
public void shouldUseCorrectScopeWhenOuModeIsProvided(String description, String ouMode, String programId, List<String> expectedOrgUnits) {
    loginActions.loginAsUser(userName, password);
    QueryParamsBuilder builder = new QueryParamsBuilder().add("ouMode", ouMode);
    if (!Strings.isNullOrEmpty(programId)) {
        builder.add("program", programId);
    }
    eventActions.get(builder.build()).validate().statusCode(200).body("events.orgUnit", everyItem(in(expectedOrgUnits)));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 70 with QueryParamsBuilder

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

the class EventExportTests method setupTrackerEvents.

private void setupTrackerEvents() {
    Arrays.asList(captureOu, dataReadOu, searchOu, rootOu).forEach(ou -> {
        JsonObject object = new TeiDataBuilder().buildWithEnrollmentAndEvent(Constants.TRACKED_ENTITY_TYPE, ou, withRegistrationProgram, withRegistrationProgramStage);
        String eventId = new TrackerActions().postAndGetJobReport(object).validateSuccessfulImport().extractImportedEvents().get(0);
        trackerEvents.put(ou, eventId);
        // closed program events
        object = new TeiDataBuilder().buildWithEnrollmentAndEvent(Constants.TRACKED_ENTITY_TYPE, ou, closedProgramId, closedProgramProgramStageId);
        eventId = new TrackerActions().postAndGetJobReport(object, new QueryParamsBuilder().add("async", "false")).validateSuccessfulImport().extractImportedEvents().get(0);
        closedProgramEvents.put(ou, eventId);
    });
}
Also used : TeiDataBuilder(org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder) TrackerActions(org.hisp.dhis.actions.tracker.importer.TrackerActions) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) Matchers.containsString(org.hamcrest.Matchers.containsString)

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