use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class RelationshipsTests method shouldDeleteRelationshipWithDeleteStrategy.
@Test
public void shouldDeleteRelationshipWithDeleteStrategy() {
// arrage
TrackerApiResponse response = trackerActions.postAndGetJobReport(new File("src/test/resources/tracker/importer/teis/teisAndRelationship.json")).validateSuccessfulImport();
List<String> teis = response.extractImportedTeis();
String relationship = response.extractImportedRelationships().get(0);
JsonObject obj = new JsonObjectBuilder().addObject("from", JsonObjectBuilder.jsonObject().addProperty("trackedEntity", teis.get(0))).addObject("to", JsonObjectBuilder.jsonObject().addProperty("trackedEntity", teis.get(1))).addProperty("relationshipType", relationshipType).addProperty("relationship", relationship).wrapIntoArray("relationships");
// act
response = trackerActions.postAndGetJobReport(obj, new QueryParamsBuilder().add("importStrategy=DELETE"));
// assert
response.validate().body("status", equalTo("OK")).body("stats.deleted", equalTo(1));
trackerActions.get("/relationships/" + relationship).validate().statusCode(404);
trackerActions.getTrackedEntity(teis.get(0) + "?fields=relationships").validate().body("relationships", Matchers.empty());
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventValidationTests method shouldValidateEventProperties.
@CsvSource({ "ACTIVE,,OccurredAt date is missing.", "SCHEDULE,,ScheduledAt date is missing." })
@ParameterizedTest
public void shouldValidateEventProperties(String status, String occurredAt, String error) {
JsonObject object = new EventDataBuilder().setStatus(status).setEventDate(occurredAt).setEnrollment(enrollment).array(OU_ID, trackerProgramId, trackerProgramStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(object);
response.validateErrorReport().body("message[0]", containsStringIgnoringCase(error));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventValidationTests method eventImportShouldPassValidationWhenOnlyEventProgramIsDefined.
@Test
public void eventImportShouldPassValidationWhenOnlyEventProgramIsDefined() {
JsonObject jsonObject = new EventDataBuilder().array(OU_ID, eventProgramId, null);
TrackerApiResponse response = trackerActions.postAndGetJobReport(jsonObject);
response.validateSuccessfulImport();
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventValidationTests method eventImportShouldValidateProgramFromProgramStage.
@Test
public void eventImportShouldValidateProgramFromProgramStage() {
JsonObject jsonObject = new EventDataBuilder().setEnrollment(enrollment).array(OU_ID, anotherTrackerProgramId, trackerProgramStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(jsonObject);
response.validateErrorReport().body("errorCode", hasItem(equalTo("E1079")));
}
use of org.hisp.dhis.dto.TrackerApiResponse in project dhis2-core by dhis2.
the class EventValidationTests method shouldSetDueDate.
@Test
public void shouldSetDueDate() {
JsonObject eventBody = new EventDataBuilder().setEnrollment(enrollment).array(OU_ID, trackerProgramId, trackerProgramStageId);
TrackerApiResponse response = trackerActions.postAndGetJobReport(eventBody);
String eventId = response.validateSuccessfulImport().extractImportedEvents().get(0);
JsonObject event = trackerActions.get("/events/" + eventId).getBody();
assertEquals(event.get("eventDate"), event.get("dueDate"));
}
Aggregations