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"))));
}
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());
}
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);
}
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)));
}
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);
});
}
Aggregations