Search in sources :

Example 1 with LanguageProficiency

use of org.edx.mobile.user.LanguageProficiency in project edx-app-android by edx.

the class UserProfileInteractorTest method whenProfileObserved_withInvalidLanguageCode_emitsProfileWithNoLanguage.

@Test
public void whenProfileObserved_withInvalidLanguageCode_emitsProfileWithNoLanguage() {
    final Account account = configureBareMockAccount();
    when(account.getLanguageProficiencies()).thenReturn(Collections.singletonList(new LanguageProficiency(ProfileValues.INVALID_LANGUAGE_CODE)));
    createAndObserveInteractor();
    verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.NO_ABOUT_ME, null))));
}
Also used : LanguageProficiency(org.edx.mobile.user.LanguageProficiency) Account(org.edx.mobile.user.Account) BaseTest(org.edx.mobile.test.BaseTest) Test(org.junit.Test)

Example 2 with LanguageProficiency

use of org.edx.mobile.user.LanguageProficiency in project edx-app-android by edx.

the class UserProfileInteractorTest method whenProfileObserved_withFullProfile_emitsLanguageAndLocationAndAboutMe.

@Test
public void whenProfileObserved_withFullProfile_emitsLanguageAndLocationAndAboutMe() {
    final Account account = configureBareMockAccount();
    when(account.getBio()).thenReturn(ProfileValues.ABOUT_ME);
    when(account.getCountry()).thenReturn(ProfileValues.COUNTRY_CODE);
    when(account.getLanguageProficiencies()).thenReturn(Collections.singletonList(new LanguageProficiency(ProfileValues.LANGUAGE_CODE)));
    createAndObserveInteractor();
    verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, ProfileValues.LANGUAGE_NAME, ProfileValues.COUNTRY_NAME, new UserProfileBioModel(UserProfileBioModel.ContentType.ABOUT_ME, ProfileValues.ABOUT_ME))));
}
Also used : LanguageProficiency(org.edx.mobile.user.LanguageProficiency) Account(org.edx.mobile.user.Account) BaseTest(org.edx.mobile.test.BaseTest) Test(org.junit.Test)

Example 3 with LanguageProficiency

use of org.edx.mobile.user.LanguageProficiency in project edx-app-android by edx.

the class EditUserProfileFragment method executeUpdate.

private void executeUpdate(FormField field, String fieldValue) {
    final Object valueObject;
    if (field.getDataType() == DataType.LANGUAGE) {
        if (TextUtils.isEmpty(fieldValue)) {
            valueObject = Collections.emptyList();
        } else {
            valueObject = Collections.singletonList(new LanguageProficiency(fieldValue));
        }
    } else {
        valueObject = fieldValue;
    }
    userService.updateAccount(username, Collections.singletonMap(field.getName(), valueObject)).enqueue(new AccountDataUpdatedCallback(getActivity(), username, new DialogErrorNotification(this)) {

        @Override
        protected void onResponse(@NonNull final Account account) {
            super.onResponse(account);
            EditUserProfileFragment.this.account = account;
            setData(account, formDescription);
        }
    });
}
Also used : LanguageProficiency(org.edx.mobile.user.LanguageProficiency) AccountDataUpdatedCallback(org.edx.mobile.user.UserAPI.AccountDataUpdatedCallback) Account(org.edx.mobile.user.Account) JsonObject(com.google.gson.JsonObject) DialogErrorNotification(org.edx.mobile.http.notifications.DialogErrorNotification)

Aggregations

Account (org.edx.mobile.user.Account)3 LanguageProficiency (org.edx.mobile.user.LanguageProficiency)3 BaseTest (org.edx.mobile.test.BaseTest)2 Test (org.junit.Test)2 JsonObject (com.google.gson.JsonObject)1 DialogErrorNotification (org.edx.mobile.http.notifications.DialogErrorNotification)1 AccountDataUpdatedCallback (org.edx.mobile.user.UserAPI.AccountDataUpdatedCallback)1