use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TrackedEntityInstanceAclReadTests method testUserDataAndOrgUnitScopeReadAccess.
@ParameterizedTest
@ValueSource(strings = { "O2PajOxjJSa", "aDy67f9ijOe", "CKrrGm5Be8O", "Lpa5INiC3Qf", "GTqb3WOZMop" })
public void testUserDataAndOrgUnitScopeReadAccess(String userUid) {
User user = users.stream().filter(_user -> _user.getUid().equals(userUid)).findFirst().orElseThrow(() -> new RuntimeException("User UID not found for test"));
new LoginActions().loginAsUser(user.getUsername(), user.getPassword());
QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
queryParamsBuilder.addAll("filter=pyNnf3UaOOg:NE:zz", "trackedEntityType=YDzXLdCvV4h", "ouMode=ACCESSIBLE", "fields=*");
ApiResponse response = teiActions.get("/", queryParamsBuilder);
response.validate().statusCode(200);
response.validate().body("trackedEntityInstances", Matchers.not(Matchers.emptyArray()));
JsonObject json = response.getBody();
json.getAsJsonArray("trackedEntityInstances").iterator().forEachRemaining((teiJson) -> assertTrackedEntityInstance(user, teiJson.getAsJsonObject()));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class EventImportTests method post.
private ApiResponse post(String fileName, boolean async) {
QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
queryParamsBuilder.addAll("dryRun=false", "eventIdScheme=UID", "orgUnitIdScheme=UID", "async=" + String.valueOf(async));
ApiResponse response = eventActions.postFile(new File("src/test/resources/tracker/events/" + fileName), queryParamsBuilder);
return response;
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserAssignmentFilterTests method eventsShouldBeFilteredByUnassigned.
@Test
public void eventsShouldBeFilteredByUnassigned() {
// arrange
loginActions.loginAsUser(userUsername, userPassword);
String eventId = eventActions.get("?orgUnit=" + orgUnit + "&assignedUserMode=CURRENT").extractString("events.event[0]");
assertNotNull(eventId, "Event was not found");
unassignEvent(eventId);
// act
ApiResponse currentUserEvents = eventActions.get("?orgUnit=" + orgUnit + "&assignedUserMode=CURRENT");
ApiResponse unassignedEvents = eventActions.get("?orgUnit=" + orgUnit + "&assignedUserMode=NONE");
// assert
currentUserEvents.validate().statusCode(200).body("events", notNullValue()).body("events.event", not(hasItem(eventId)));
unassignedEvents.validate().statusCode(200).body("events", notNullValue()).body("events.event", hasItem(eventId)).body("events.assignedUser", everyItem(is(emptyOrNullString())));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserAssignmentFilterTests method unassignEvent.
private ApiResponse unassignEvent(String eventId) {
JsonObject body = eventActions.get(eventId).getBody();
body.addProperty("assignedUser", "");
ApiResponse response = eventActions.update(eventId, body);
response.validate().statusCode(200);
return response;
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserAssignmentFilterTests method eventsShouldBeFilteredForAssignedUserByStatus.
@Test
public void eventsShouldBeFilteredForAssignedUserByStatus() {
// arrange
loginActions.loginAsUser(userUsername, userPassword);
String eventId = eventActions.get("?orgUnit=" + orgUnit + "&assignedUserMode=CURRENT").extractString("events.event[0]");
assertNotNull(eventId, "Event was not found");
String status = "SCHEDULE";
changeEventStatus(eventId, status);
// act
ApiResponse filteredEvents = eventActions.get("?orgUnit=" + orgUnit + "&assignedUserMode=CURRENT&status=" + status);
ApiResponse activeEvents = eventActions.get("?orgUnit=" + orgUnit + "&assignedUserMode=CURRENT&status=ACTIVE");
// assert
filteredEvents.validate().statusCode(200).body("events", hasSize(1)).body("events.assignedUser", everyItem(equalTo(userId))).body("events.status", everyItem(equalTo(status)));
activeEvents.validate().statusCode(200).body("events", hasSize(3)).body("events.assignedUser", everyItem(equalTo(userId))).body("events.status", everyItem(equalTo("ACTIVE")));
}
Aggregations