use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EventsDataValueValidationTests method setupData.
private void setupData() {
ApiResponse response = programActions.createEventProgram(OU_ID);
programId = response.extractUid();
assertNotNull(programId, "Failed to create a program");
sharingActions.setupSharingForConfiguredUserGroup("program", programId);
programStageId = programActions.get(programId, new QueryParamsBuilder().add("fields=*")).extractString("programStages.id[0]");
assertNotNull(programStageId, "Failed to create a programStage");
ApiResponse dataelements = dataElementActions.get("?fields=id&filter=domainType:eq:TRACKER&filter=valueType:in:[TEXT,LONG_TEXT]&pageSize=2");
dataelements.validate().body("dataElements", hasSize(2));
mandatoryDataElementId = dataelements.extractString("dataElements.id[0]");
notMandatoryDataElementId = dataelements.extractString("dataElements.id[1]");
programActions.addDataElement(programStageId, mandatoryDataElementId, true).validate().statusCode(200);
programActions.addDataElement(programStageId, notMandatoryDataElementId, false).validate().statusCode(200);
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class UserAssignmentTests method shouldRemoveUserAssignment.
@Test
public void shouldRemoveUserAssignment() throws Exception {
// arrange
String loggedInUser = loginActions.getLoggedInUserId();
programActions.programStageActions.enableUserAssignment(programStageId, true);
createEvents(programId, programStageId, loggedInUser);
JsonObject eventBody = trackerActions.get("/events?program=" + programId + "&assignedUserMode=CURRENT&ouMode=ACCESSIBLE").validateStatus(200).extractJsonObject("instances[0]");
assertNotNull(eventBody, "no events matching the query.");
String eventId = eventBody.get("event").getAsString();
// act
eventBody.add("assignedUser", null);
trackerActions.postAndGetJobReport(new JsonObjectBuilder(eventBody).wrapIntoArray("events"), new QueryParamsBuilder().addAll("importStrategy=UPDATE")).validateSuccessfulImport();
// assert
trackerActions.getEvent(eventId).validate().body("assignedUser", nullValue());
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class TeiValidationTests method shouldReturnErrorWhenAttributeWithOptionSetInvalid.
@Test
public void shouldReturnErrorWhenAttributeWithOptionSetInvalid() {
JsonObject trackedEntities = buildTeiWithMandatoryAttribute().addAttribute(attributeWithOptionSet, DataGenerator.randomString()).array();
trackerActions.postAndGetJobReport(trackedEntities, new QueryParamsBuilder().add("async=false")).validateErrorReport().body("errorCode", hasItem("E1125")).body("trackerType", hasItem("TRACKED_ENTITY"));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class TeiValidationTests method shouldReturnErrorWhenRemovingMandatoryAttributes.
@Test
public void shouldReturnErrorWhenRemovingMandatoryAttributes() {
JsonObject object = buildTeiWithEnrollmentAndMandatoryAttributes().array();
TrackerApiResponse response = trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("async=false"));
String teiId = response.validateSuccessfulImport().extractImportedTeis().get(0);
String enrollmentId = response.extractImportedEnrollments().get(0);
JsonObjectBuilder.jsonObject(object).addPropertyByJsonPath("trackedEntities[0].trackedEntity", teiId).addPropertyByJsonPath("trackedEntities[0].attributes[0].value", null).addPropertyByJsonPath("trackedEntities[0].enrollments[0].enrollment", enrollmentId).addPropertyByJsonPath("trackedEntities[0].enrollments[0].attributes[0].value", null);
trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("async=false")).validateErrorReport().body("", hasSize(2)).body("trackerType", hasItems("TRACKED_ENTITY", "ENROLLMENT")).body("errorCode", hasItems("E1076", "E1076")).body("message", hasItem(allOf(containsStringIgnoringCase("TrackedEntityAttribute"), containsStringIgnoringCase(mandatoryTetAttribute)))).body("message", hasItem(allOf(containsStringIgnoringCase("TrackedEntityAttribute"), containsStringIgnoringCase(mandatoryProgramAttribute))));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class TeiValidationTests method shouldNotReturnErrorWhenRemovingNotMandatoryAttributes.
@Test
public void shouldNotReturnErrorWhenRemovingNotMandatoryAttributes() {
JsonObject payload = buildTeiWithMandatoryAndOptionSetAttribute().array();
String teiId = trackerActions.postAndGetJobReport(payload, new QueryParamsBuilder().add("async=false")).validateSuccessfulImport().extractImportedTeis().get(0);
JsonObjectBuilder.jsonObject(payload).addPropertyByJsonPath("trackedEntities[0]", "trackedEntity", teiId).addPropertyByJsonPath("trackedEntities[0].attributes[1]", "value", null);
trackerActions.postAndGetJobReport(payload, new QueryParamsBuilder().add("async=false")).validateSuccessfulImport();
trackerActions.getTrackedEntity(teiId).validate().body("attributes", hasSize(1));
}
Aggregations