Search in sources :

Example 6 with Account

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

the class UserProfileInteractorTest method onAccountUpdatedEvent_withUnrelatedUsername_emitsUpdatedProfileContent.

@Test
public void onAccountUpdatedEvent_withUnrelatedUsername_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.getUsername()).thenReturn(ProfileValues.ALTERNATE_USERNAME);
    when(account.getBio()).thenReturn(ProfileValues.ABOUT_ME);
    eventBus.post(new AccountDataLoadedEvent(account));
    verifyNoMoreInteractions(profileObserver);
}
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 7 with Account

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

the class UserProfileInteractorTest method whenProfileObserved_withParentalConsentRequired_asUserBeingViewed_emitsParentalConsentRequired.

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

Example 8 with Account

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

the class UserProfileInteractorTest method whenProfileObserved_withInvalidCountryCode_emitsProfileWithNoCountry.

@Test
public void whenProfileObserved_withInvalidCountryCode_emitsProfileWithNoCountry() {
    final Account account = configureBareMockAccount();
    when(account.getCountry()).thenReturn(ProfileValues.INVALID_COUNTRY_CODE);
    createAndObserveInteractor();
    verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, 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 9 with Account

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

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

the class UserProfileInteractorTest method whenProfileObserved_withNoAboutMe_withPrivateAccount_asUserBeingViewed_emitsIncompleteProfileMessageAndContent.

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

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