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))));
}
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))));
}
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);
}
});
}
Aggregations