use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventIdSchemeTests method eventsShouldBeImportedWithProgramScheme.
@ParameterizedTest
@MethodSource("provideIdSchemeArguments")
public void eventsShouldBeImportedWithProgramScheme(String scheme, String property) throws Exception {
// arrange
String programPropertyValue = programActions.get(PROGRAM_ID).extractString(property);
assertNotNull(programPropertyValue, String.format("Program property %s was not present.", property));
JsonObject object = new FileReaderUtils().read(new File("src/test/resources/tracker/importer/events/event.json")).replacePropertyValuesWithIds("event").replacePropertyValuesWith("orgUnit", orgUnitId).replacePropertyValuesWith("program", programPropertyValue).replacePropertyValuesWith("programStage", PROGRAM_STAGE_ID).get(JsonObject.class);
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("programIdScheme=" + scheme));
// assert
String eventId = response.validateSuccessfulImport().extractImportedEvents().get(0);
assertNotNull("Event was not created", eventId);
trackerActions.get("/events/" + eventId).validate().statusCode(200).body("program", equalTo(PROGRAM_ID));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventIdSchemeTests method eventsShouldBeImportedWithOrgUnitScheme.
@ParameterizedTest
@MethodSource("provideIdSchemeArguments")
public void eventsShouldBeImportedWithOrgUnitScheme(String ouScheme, String ouProperty) throws Exception {
String ouPropertyValue = orgUnitActions.get(orgUnitId).extractString(ouProperty);
assertNotNull(ouPropertyValue, String.format("Org unit property %s was not present.", ouProperty));
JsonObject object = new FileReaderUtils().read(new File("src/test/resources/tracker/importer/events/event.json")).replacePropertyValuesWith("orgUnit", ouPropertyValue).replacePropertyValuesWithIds("event").get(JsonObject.class);
TrackerApiResponse response = trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("orgUnitIdScheme=" + ouScheme));
String eventId = response.validateSuccessfulImport().extractImportedEvents().get(0);
trackerActions.get("/events/" + eventId).validate().statusCode(200).body("orgUnit", equalTo(orgUnitId));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class TeiValidationTests method shouldReturnErrorReportsWhenTeiIncorrect.
@Test
public void shouldReturnErrorReportsWhenTeiIncorrect() {
// arrange
JsonObject trackedEntities = new TeiDataBuilder().array("", Constants.ORG_UNIT_IDS[0]);
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(trackedEntities);
// assert
response.validateErrorReport().body("errorCode", hasItem("E1121"));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventNotesTests method shouldUpdateEventWithANote.
@Test
public void shouldUpdateEventWithANote() {
// arrange
JsonObject ob = buildEventWithNote();
String eventId = trackerActions.postAndGetJobReport(ob).validateSuccessfulImport().extractImportedEvents().get(0);
JsonObjectBuilder.jsonObject(ob).addPropertyByJsonPath("events[0]", "event", eventId);
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(ob);
// assert
response.validateSuccessfulImport().validate().body("stats.updated", equalTo(1));
trackerActions.getEvent(eventId + "?fields=notes").validate().statusCode(200).body("notes", hasSize(2)).body("notes.storedBy", CoreMatchers.everyItem(equalTo("taadmin")));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventNotesTests method shouldNotAddAnotherNote.
@Test
public void shouldNotAddAnotherNote() {
// arrange
JsonObject ob = buildEventWithNote();
String eventId = trackerActions.postAndGetJobReport(ob).validateSuccessfulImport().extractImportedEvents().get(0);
ob = trackerActions.get("/events/" + eventId).getBody();
ob = JsonObjectBuilder.jsonObject(ob).wrapIntoArray("events");
// act
TrackerApiResponse response = trackerActions.postAndGetJobReport(ob);
// assert
response.validateSuccessfulImport().validateWarningReport().body("trackerType", everyItem(equalTo("EVENT"))).body("warningCode", hasItem("E1119"));
}
Aggregations