use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class SharingActions method setupSharingForUsers.
public void setupSharingForUsers(String type, String id, String... userIds) {
JsonObject jsonObject = this.get(new QueryParamsBuilder().add("type=" + type).add("id=" + id).build()).getBody();
for (String userId : userIds) {
JsonObjectBuilder.jsonObject(jsonObject.getAsJsonObject("object")).addOrAppendToArray("userAccesses", new JsonObjectBuilder().addProperty("id", userId).addProperty("access", "rw------").build());
}
this.post(jsonObject, new QueryParamsBuilder().add("type=" + type).add("id=" + id)).validate().statusCode(200);
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class ProgramActions method addAttribute.
public ApiResponse addAttribute(String programId, String teiAttributeId, boolean isMandatory) {
JsonObject object = this.get(programId, new QueryParamsBuilder().add("fields=*")).getBodyAsJsonBuilder().addOrAppendToArray("programTrackedEntityAttributes", new JsonObjectBuilder().addProperty("mandatory", String.valueOf(isMandatory)).addObject("trackedEntityAttribute", new JsonObjectBuilder().addProperty("id", teiAttributeId)).build()).build();
JsonObjectBuilder.jsonObject(object);
return this.update(programId, object).validateStatus(200);
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class MessageConversationsActions method waitForNotification.
public ApiResponse waitForNotification(int expectedCount) {
boolean isReceived = false;
int attemptCount = 20;
ApiResponse response = null;
while (!isReceived && attemptCount > 0) {
response = this.get("", new QueryParamsBuilder().add("fields=subject"));
isReceived = (response.extractList("messageConversations").size() == expectedCount);
attemptCount--;
}
return response;
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EventValidationTests method setupData.
private void setupData() {
eventProgramStageId = programActions.programStageActions.get("", new QueryParamsBuilder().add("filter=program.id:eq:" + eventProgramId)).extractString("programStages.id[0]");
assertNotNull(eventProgramStageId, "Failed to find a program stage");
trackerProgramStageId = programActions.programStageActions.get("", new QueryParamsBuilder().addAll("filter=program.id:eq:" + trackerProgramId, "filter=repeatable:eq:true")).extractString("programStages.id[0]");
ouIdWithoutAccess = new OrgUnitActions().createOrgUnit();
new UserActions().grantCurrentUserAccessToOrgUnit(ouIdWithoutAccess);
enrollment = trackerActions.postAndGetJobReport(new TeiDataBuilder().buildWithEnrollment(OU_ID, trackerProgramId)).validateSuccessfulImport().extractImportedEnrollments().get(0);
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EventsTests method shouldImportToRepeatableStage.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void shouldImportToRepeatableStage(Boolean repeatableStage) throws Exception {
// arrange
String program = Constants.TRACKER_PROGRAM_ID;
String programStage = new ProgramStageActions().get("", new QueryParamsBuilder().addAll("filter=program.id:eq:" + program, "filter=repeatable:eq:" + repeatableStage)).extractString("programStages.id[0]");
TrackerApiResponse response = importTeiWithEnrollment(program);
String teiId = response.extractImportedTeis().get(0);
String enrollmentId = response.extractImportedEnrollments().get(0);
JsonObject event = new EventDataBuilder().setEnrollment(enrollmentId).setTei(teiId).array(Constants.ORG_UNIT_IDS[0], program, programStage).getAsJsonArray("events").get(0).getAsJsonObject();
JsonObject payload = new JsonObjectBuilder().addArray("events", event, event).build();
// act
response = trackerActions.postAndGetJobReport(payload);
// assert
if (repeatableStage) {
response.validateSuccessfulImport().validate().body("stats.created", equalTo(2));
} else {
response.validateErrorReport().body("errorCode", hasItem("E1039"));
}
}
Aggregations