use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserAssignmentFilterTests method eventsShouldBeFilteredForAssignedUser.
@Test
public void eventsShouldBeFilteredForAssignedUser() {
// arrange
loginActions.loginAsUser(userUsername, userPassword);
// act
ApiResponse response = eventActions.get("?orgUnit=" + orgUnit + "&assignedUserMode=CURRENT");
// assert
response.validate().statusCode(200).body("events", hasSize(4)).body("events.assignedUser", everyItem(equalTo(userId)));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class UserAssignmentFilterTests method changeEventStatus.
private ApiResponse changeEventStatus(String eventId, String eventStatus) {
JsonObject body = eventActions.get(eventId).getBody();
body.addProperty("status", eventStatus);
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 createEvents.
private ApiResponse createEvents(Object body) throws Exception {
ApiResponse eventResponse = eventActions.post(body, new QueryParamsBuilder().add("skipCache=true"));
eventResponse.validate().statusCode(200);
return eventResponse;
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class SideEffectsTests method shouldSendNotificationIfNotSkipSideEffects.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void shouldSendNotificationIfNotSkipSideEffects(Boolean shouldSkipSideEffects) {
JsonObject object = new TeiDataBuilder().buildWithEnrollmentAndEvent(Constants.TRACKED_ENTITY_TYPE, Constants.ORG_UNIT_IDS[0], trackerProgramId, trackerProgramStageId, "COMPLETED");
ApiResponse response = new RestApiActions("/messageConversations").get("", new QueryParamsBuilder().add("fields=*"));
int size = response.getBody().getAsJsonArray("messageConversations").size();
trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("skipSideEffects=" + shouldSkipSideEffects)).validateSuccessfulImport();
int expectedCount = (shouldSkipSideEffects) ? size : size + 1;
response = messageConversationsActions.waitForNotification(expectedCount);
response.validate().statusCode(200).body("messageConversations", hasSize(expectedCount));
if (shouldSkipSideEffects) {
return;
}
response.validate().body("messageConversations.subject", hasItem("TA program stage completion"));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataElementsTest method shouldCreate.
@ParameterizedTest
@MethodSource("getDataElementCombinations")
public void shouldCreate(String domainType, String valueType, String aggregationType, boolean withCategoryCombo, String categoryComboDimensionType) {
// arrange
JsonObject body = dataElementActions.body(aggregationType, domainType, valueType);
if (withCategoryCombo) {
String categoryComboId = createCategoryCombo(categoryComboDimensionType);
JsonObject categoryCombo = new JsonObject();
categoryCombo.addProperty("id", categoryComboId);
body.add("categoryCombo", categoryCombo);
}
// act
ApiResponse response = dataElementActions.post(body);
// assert
ResponseValidationHelper.validateObjectCreation(response);
}
Aggregations