use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class TrackerActions method getJobReport.
public TrackerApiResponse getJobReport(String jobId, String reportMode) {
ApiResponse response = this.get(String.format("/jobs/%s/report?reportMode=%s", jobId, reportMode));
// add created entities
saveCreatedData(response);
return new TrackerApiResponse(response);
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class ImportStrategyTests method shouldDeleteReferencingDataWhenTeiIsDeleted.
@Test
public void shouldDeleteReferencingDataWhenTeiIsDeleted() throws Exception {
// arrange
JsonObject body = new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/tracker/importer/teis/teiAndEnrollment.json"));
TrackerApiResponse response = trackerActions.postAndGetJobReport(body).validateSuccessfulImport();
String teiId = response.extractImportedTeis().get(0);
String enrollmentId = response.extractImportedEnrollments().get(0);
body.remove("enrollments");
// act
response = trackerActions.postAndGetJobReport(body, new QueryParamsBuilder().add("importStrategy=DELETE")).validateSuccessfulImport();
// assert
response.validateSuccessfulImport().validate().body("stats.deleted", Matchers.equalTo(1));
trackerActions.getTrackedEntity(teiId).validate().statusCode(404);
trackerActions.get("/enrollments/" + enrollmentId).validate().statusCode(404);
}
use of org.hisp.dhis.dto.TrackerApiResponse 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 ")));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class RuleEngineTests method shouldShowErrorsBasedOnValidationStrategy.
@ParameterizedTest
@CsvSource({ "ON_COMPLETE,COMPLETED,true", "ON_COMPLETE,ACTIVE,false", "ON_UPDATE_AND_INSERT,ACTIVE,true" })
public void shouldShowErrorsBasedOnValidationStrategy(String validationStrategy, String eventStatus, boolean shouldFail) {
String programStage = new ProgramStageActions().get("", new QueryParamsBuilder().addAll("filter=program.id:eq:" + trackerProgramId, "filter=validationStrategy:eq:" + validationStrategy)).extractString("programStages.id[0]");
JsonObject payload = new TeiDataBuilder().buildWithEnrollmentAndEvent(Constants.TRACKED_ENTITY_TYPE, Constants.ORG_UNIT_IDS[0], trackerProgramId, programStage);
// program rule is triggered for events with date earlier than today
new JsonObjectBuilder(payload).addPropertyByJsonPath("trackedEntities[0].enrollments[0].events[0].occurredAt", Instant.now().minus(1, ChronoUnit.DAYS).toString()).addPropertyByJsonPath("trackedEntities[0].enrollments[0].events[0].status", eventStatus);
TrackerApiResponse response = trackerActions.postAndGetJobReport(payload);
if (shouldFail) {
response.validateErrorReport();
return;
}
response.validateSuccessfulImport();
}
use of org.hisp.dhis.dto.TrackerApiResponse 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();
}
Aggregations