use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class RuleEngineTests method shouldSendProgramRuleNotification.
@Test
public void shouldSendProgramRuleNotification() {
JsonObject payload = new EventDataBuilder().addDataValue("ILRgzHhzFkg", "true").addDataValue("z3Z4TD3oBCP", "true").addDataValue("BuZ5LGNfGEU", "40").array(Constants.ORG_UNIT_IDS[0], eventProgramId, "Mt6Ac5brjoK");
loginActions.loginAsAdmin();
ApiResponse response = new RestApiActions("/messageConversations").get("", new QueryParamsBuilder().add("fields=*"));
int size = response.getBody().getAsJsonArray("messageConversations").size();
loginActions.loginAsSuperUser();
trackerActions.postAndGetJobReport(payload).validateSuccessfulImport();
loginActions.loginAsAdmin();
messageConversationsActions.waitForNotification(size + 1);
messageConversationsActions.get("", new QueryParamsBuilder().add("fields=*")).validate().statusCode(200).body("messageConversations", hasSize(size + 1)).body("messageConversations.subject", hasItem("Program rule triggered"));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TrackerExportTests method shouldReturnRequestedFields.
@MethodSource()
@ParameterizedTest
public void shouldReturnRequestedFields(String endpoint, String fields, String fieldsToValidate) {
ApiResponse response = trackerActions.get(endpoint + "?fields=" + fields);
response.validate().statusCode(200);
List<String> fieldList = fieldsToValidate == null ? splitFields(fields) : splitFields(fieldsToValidate);
fieldList.forEach(p -> {
response.validate().body(p, allOf(not(nullValue()), not(contains(nullValue())), not(emptyIterable())));
});
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class SystemSettingsTests method returnTranslationForUsersLocale.
@Test
public void returnTranslationForUsersLocale() {
prepareData();
ApiResponse response = systemSettingActions.get(APPLICATION_INTRO_KEY, ContentType.TEXT.toString(), ContentType.TEXT.toString(), new QueryParamsBuilder());
response.validate().log().all().statusCode(200).body(containsString(ENGLISH_INTRO));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class SystemSettingsTests method returnDefaultValueWhenUserIsNotLoggedIn.
@Test
@Disabled("This test is broken and will only return 200 OK because the servlet redirects to the login page. //TODO: Remove")
public void returnDefaultValueWhenUserIsNotLoggedIn() {
prepareData();
// I need to log out
loginActions.removeAuthenticationHeader();
ApiResponse response = systemSettingActions.get(APPLICATION_INTRO_KEY, ContentType.TEXT.toString(), ContentType.TEXT.toString(), new QueryParamsBuilder());
response.validate().statusCode(200);
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class TrackedEntityInstanceAclReadTests method setupUser.
/**
* Takes a User object and retrieves information about the users from the
* api. Updates the password of the user to allow access.
*
* @param user to setup
*/
private void setupUser(User user) {
userActions.updateUserPassword(user.getUid(), user.getPassword());
new LoginActions().loginAsUser(user.getUsername(), user.getPassword());
// Get User information from /me
ApiResponse apiResponse = new RestApiActions("/me").get();
String asString = apiResponse.getAsString();
Me me = apiResponse.as(Me.class);
// Add userGroups
user.setGroups(me.getUserGroups().stream().map(UserGroup::getId).collect(Collectors.toList()));
// Add search-scope ous
user.setSearchScope(me.getTeiSearchOrganisationUnits().stream().map(OrgUnit::getId).collect(Collectors.toList()));
// Add capture-scope ous
user.setCaptureScope(me.getOrganisationUnits().stream().map(OrgUnit::getId).collect(Collectors.toList()));
// Add hasAllAuthority if user has ALL authority
user.setAllAuthority(me.getAuthorities().contains("ALL"));
// Setup map to decide what data can and cannot be read.
setupAccessMap(user);
}
Aggregations