use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessageHolderViewModelTest method testParticipantAvatarImage_CurrentUserIsSender.
@Test
public void testParticipantAvatarImage_CurrentUserIsSender() {
final User recipient = UserFactory.user().toBuilder().name("Ima Creator").id(123L).build();
final User sender = UserFactory.user().toBuilder().name("Ima Backer").id(456L).build();
final Message message = MessageFactory.message().toBuilder().recipient(recipient).sender(sender).build();
final MockCurrentUser currentUser = new MockCurrentUser(sender);
setUpEnvironment(environment().toBuilder().currentUser(currentUser).build());
this.vm.inputs.configureWith(message);
// Avatar hidden for sender who is the backer.
this.participantAvatarImageHidden.assertValues(true);
this.participantAvatarImageUrl.assertNoValues();
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class MessageThreadsViewModelTest method testMessageThreadsEmit_WithProjectIntent.
@Test
public void testMessageThreadsEmit_WithProjectIntent() {
final CurrentUserType currentUser = new MockCurrentUser();
currentUser.login(UserFactory.user().toBuilder().unreadMessagesCount(0).build(), "beefbod5");
final MessageThreadsEnvelope inboxEnvelope = MessageThreadsEnvelopeFactory.messageThreadsEnvelope().toBuilder().messageThreads(Collections.singletonList(MessageThreadFactory.messageThread())).build();
final MessageThreadsEnvelope sentEnvelope = MessageThreadsEnvelopeFactory.messageThreadsEnvelope().toBuilder().messageThreads(Arrays.asList(MessageThreadFactory.messageThread(), MessageThreadFactory.messageThread())).build();
final Project project = ProjectFactory.project().toBuilder().unreadMessagesCount(5).build();
final ApiClientType apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadsEnvelope> fetchMessageThreads(@Nullable final Project project, @NonNull final Mailbox mailbox) {
return Observable.just(mailbox == Mailbox.INBOX ? inboxEnvelope : sentEnvelope);
}
@Override
@NonNull
public Observable<Project> fetchProject(@NonNull final String param) {
return Observable.just(project);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(currentUser).build());
final Intent intent = new Intent().putExtra(IntentKey.PROJECT, project);
this.vm.intent(intent);
this.messageThreadList.assertValueCount(2);
this.messageThreadListCount.assertValues(0, 1);
// Same message threads should not emit again.
this.vm.inputs.onResume();
this.messageThreadList.assertValueCount(2);
this.messageThreadListCount.assertValues(0, 1);
this.vm.inputs.mailbox(Mailbox.SENT);
this.messageThreadList.assertValueCount(4);
this.messageThreadListCount.assertValues(0, 1, 0, 2);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class ActivityFeedViewModelTest method testSurveys_LoggedOut.
@Test
public void testSurveys_LoggedOut() {
final List<SurveyResponse> surveyResponses = Arrays.asList(SurveyResponseFactory.surveyResponse(), SurveyResponseFactory.surveyResponse());
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<List<SurveyResponse>> fetchUnansweredSurveys() {
return Observable.just(surveyResponses);
}
};
final CurrentUserType currentUser = new MockCurrentUser();
currentUser.logout();
final Environment environment = this.environment().toBuilder().apiClient(apiClient).currentUser(currentUser).build();
setUpEnvironment(environment);
this.vm.inputs.resume();
this.surveys.assertNoValues();
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class CreatorDashboardHeaderHolderViewModelTest method testOtherProjectsButtonIsGone_whenCurrentUserIsMemberOfManyProjects_viewingAllProjects.
@Test
public void testOtherProjectsButtonIsGone_whenCurrentUserIsMemberOfManyProjects_viewingAllProjects() {
final CurrentUserType collaborator = new MockCurrentUser(UserFactory.collaborator());
setUpEnvironment(environment().toBuilder().currentUser(collaborator).build());
this.vm.inputs.configureWith(new ProjectDashboardData(ProjectFactory.project(), ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false));
this.otherProjectsButtonIsGone.assertValue(false);
}
use of com.kickstarter.libs.MockCurrentUser in project android-oss by kickstarter.
the class CreatorDashboardHeaderHolderViewModelTest method testMessagesButtonIsGone_whenCurrentUserIsProjectCreator.
@Test
public void testMessagesButtonIsGone_whenCurrentUserIsProjectCreator() {
final User creator = UserFactory.creator();
final CurrentUserType currentUser = new MockCurrentUser(creator);
final Project project = ProjectFactory.project().toBuilder().creator(creator).build();
setUpEnvironment(environment().toBuilder().currentUser(currentUser).build());
this.vm.inputs.configureWith(new ProjectDashboardData(project, ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false));
// Messages button is shown to project creator.
this.messagesButtonIsGone.assertValues(false);
}
Aggregations