use of org.hisp.dhis.dto.TrackerApiResponse 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"));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventsDataValueValidationTests method shouldImportEventsWithCompulsoryDataValues.
@Test
public void shouldImportEventsWithCompulsoryDataValues() {
JsonObject events = new EventDataBuilder().addDataValue(mandatoryDataElementId, "TEXT value").array(OU_ID, programId, programStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(events);
response.validateSuccessfulImport().validateEvents().body("stats.created", Matchers.equalTo(1)).body("objectReports", notNullValue()).body("objectReports[0].errorReports", empty());
String eventId = response.extractImportedEvents().get(0);
trackerActions.get("/events/" + eventId).validate().statusCode(200).body("dataValues", not(Matchers.emptyArray()));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventsDataValueValidationTests method shouldValidateWhenNoDataValue.
@ParameterizedTest
@CsvSource({ "ON_COMPLETE,COMPLETED", "ON_UPDATE_AND_INSERT,ACTIVE", "ON_UPDATE_AND_INSERT,COMPLETED" })
public void shouldValidateWhenNoDataValue(String validationStrategy, String eventStatus) {
programActions.programStageActions.setValidationStrategy(programStageId, validationStrategy);
JsonObject event = createEventBodyWithStatus(eventStatus);
TrackerApiResponse response = trackerActions.postAndGetJobReport(event);
response.validate().body("status", equalTo("ERROR")).body("bundleReport.typeReportMap.EVENT", nullValue());
response.validateErrorReport().body("errorCode", hasItem("E1303"));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class UserAssignmentTests method createEvents.
private TrackerApiResponse createEvents(String programId, String programStageId, String assignedUserId) {
JsonObject jsonObject = new EventDataBuilder().setAssignedUser(assignedUserId).array(Constants.ORG_UNIT_IDS[0], programId, programStageId);
TrackerApiResponse eventResponse = trackerActions.postAndGetJobReport(jsonObject);
eventResponse.validateSuccessfulImport();
return eventResponse;
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class TeiImportTests method shouldImportTeiWithAttributes.
@Test
public void shouldImportTeiWithAttributes() throws Exception {
JsonObject teiBody = new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/tracker/importer/teis/tei.json"));
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(teiBody);
// assert
response.validateSuccessfulImport().validateTeis().body("stats.created", equalTo(1)).body("objectReports", notNullValue()).body("objectReports[0].errorReports", empty());
// assert that the TEI was imported
String teiId = response.extractImportedTeis().get(0);
ApiResponse teiResponse = trackerActions.getTrackedEntity(teiId);
teiResponse.validate().statusCode(200);
assertThat(teiResponse.getBody(), matchesJSON(teiBody.get("trackedEntities").getAsJsonArray().get(0)));
}
Aggregations