Search in sources :

Example 1 with Account

use of org.edx.mobile.user.Account 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 Account

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

the class UserProfileInteractorTest method whenProfileObserved_withNoAboutMe_withPrivateAccount_asAnonymousUser_emitsLimitedProfileMessageAndEmptyContent.

@Test
public void whenProfileObserved_withNoAboutMe_withPrivateAccount_asAnonymousUser_emitsLimitedProfileMessageAndEmptyContent() throws Exception {
    final Account account = configureBareMockAccount();
    when(account.getAccountPrivacy()).thenReturn(Account.Privacy.PRIVATE);
    createAndObserveInteractor();
    verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.OTHER_USERS_PROFILE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.EMPTY, null))));
}
Also used : Account(org.edx.mobile.user.Account) BaseTest(org.edx.mobile.test.BaseTest) Test(org.junit.Test)

Example 3 with Account

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

the class UserProfileInteractorTest method onAccountUpdatedEvent_withMatchingUsername_emitsUpdatedProfileContent.

@Test
public void onAccountUpdatedEvent_withMatchingUsername_emitsUpdatedProfileContent() throws Exception {
    final Account account = configureBareMockAccount();
    createAndObserveInteractor();
    verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.NO_ABOUT_ME, null))));
    when(account.getBio()).thenReturn(ProfileValues.ABOUT_ME);
    eventBus.post(new AccountDataLoadedEvent(account));
    verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.ABOUT_ME, ProfileValues.ABOUT_ME))));
}
Also used : Account(org.edx.mobile.user.Account) AccountDataLoadedEvent(org.edx.mobile.event.AccountDataLoadedEvent) BaseTest(org.edx.mobile.test.BaseTest) Test(org.junit.Test)

Example 4 with Account

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

the class UserProfileInteractorTest method whenProfileObserved_withParentalConsentRequired_asAnonymousUser_showsNoAboutMe.

@Test
public void whenProfileObserved_withParentalConsentRequired_asAnonymousUser_showsNoAboutMe() {
    final Account account = configureBareMockAccount();
    when(account.requiresParentalConsent()).thenReturn(true);
    createAndObserveInteractor();
    verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.OTHER_USERS_PROFILE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.NO_ABOUT_ME, null))));
}
Also used : Account(org.edx.mobile.user.Account) BaseTest(org.edx.mobile.test.BaseTest) Test(org.junit.Test)

Example 5 with Account

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

the class UserProfileInteractorTest method configureBareMockAccount.

@NonNull
private Account configureBareMockAccount() {
    final Account account = mock(Account.class);
    when(account.getUsername()).thenReturn(ProfileValues.USERNAME);
    when(account.getProfileImage()).thenReturn(mock(ProfileImage.class));
    when(userService.getAccount(ProfileValues.USERNAME)).thenReturn(Calls.response(account));
    return account;
}
Also used : Account(org.edx.mobile.user.Account) ProfileImage(org.edx.mobile.user.ProfileImage) NonNull(android.support.annotation.NonNull)

Aggregations

Account (org.edx.mobile.user.Account)14 Test (org.junit.Test)11 BaseTest (org.edx.mobile.test.BaseTest)10 AccountDataLoadedEvent (org.edx.mobile.event.AccountDataLoadedEvent)3 LanguageProficiency (org.edx.mobile.user.LanguageProficiency)3 ProfileImage (org.edx.mobile.user.ProfileImage)3 NonNull (android.support.annotation.NonNull)2 Drawable (android.graphics.drawable.Drawable)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 JsonObject (com.google.gson.JsonObject)1 DialogErrorNotification (org.edx.mobile.http.notifications.DialogErrorNotification)1 UserPrefs (org.edx.mobile.module.prefs.UserPrefs)1 AccountDataUpdatedCallback (org.edx.mobile.user.UserAPI.AccountDataUpdatedCallback)1