use of com.kickstarter.services.apiresponses.MessageThreadEnvelope in project android-oss by kickstarter.
the class MessagesViewModelTest method testBackingAndProject_Participant.
@Test
public void testBackingAndProject_Participant() {
final Project project = ProjectFactory.project().toBuilder().isBacking(false).build();
final Backing backing = BackingFactory.backing().toBuilder().project(project).build();
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().project(project).backing(backing).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread messageThread) {
return Observable.just(MessageThreadEnvelopeFactory.messageThreadEnvelope());
}
@Override
@NonNull
public Observable<Backing> fetchProjectBacking(@NonNull final Project project, @NonNull final User user) {
return Observable.just(backing);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(UserFactory.user())).build());
// Start the view model with a message thread.
this.vm.intent(messagesContextIntent(messageThread));
this.backingAndProject.assertValues(Pair.create(backing, backing.project()));
this.backingInfoViewIsGone.assertValues(false);
}
use of com.kickstarter.services.apiresponses.MessageThreadEnvelope in project android-oss by kickstarter.
the class MessagesViewModelTest method testStartBackingActivity_AsBacker_EmptyThread.
@Test
public void testStartBackingActivity_AsBacker_EmptyThread() {
final User user = UserFactory.user();
final Project project = ProjectFactory.project().toBuilder().isBacking(true).build();
final Backing backing = BackingFactory.backing();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForBacking(@NonNull final Backing backing) {
return Observable.just(MessageThreadEnvelopeFactory.empty());
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(user)).build());
this.vm.intent(creatorBioModalContextIntent(backing, project));
this.vm.inputs.viewPledgeButtonClicked();
this.startBackingActivity.assertValues(new BackingWrapper(backing, user, project));
}
use of com.kickstarter.services.apiresponses.MessageThreadEnvelope in project android-oss by kickstarter.
the class MessagesViewModelTest method testStartBackingActivity_AsBacker.
@Test
public void testStartBackingActivity_AsBacker() {
final User user = UserFactory.user();
final Project project = ProjectFactory.project().toBuilder().isBacking(true).build();
final Backing backing = BackingFactory.backing();
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().project(project).build();
final MessageThreadEnvelope messageThreadEnvelope = MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messageThread(messageThread).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForBacking(@NonNull final Backing backing) {
return Observable.just(messageThreadEnvelope);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(user)).build());
this.vm.intent(backerModalContextIntent(backing, project));
this.vm.inputs.viewPledgeButtonClicked();
this.startBackingActivity.assertValues(new BackingWrapper(backing, user, project));
}
use of com.kickstarter.services.apiresponses.MessageThreadEnvelope in project android-oss by kickstarter.
the class MessagesViewModelTest method testStartBackingActivity_AsCreator.
@Test
public void testStartBackingActivity_AsCreator() {
final User backer = UserFactory.user().toBuilder().name("Vanessa").build();
final User creator = UserFactory.user().toBuilder().name("Jessica").build();
final Backing backing = BackingFactory.backing();
final Project project = ProjectFactory.project().toBuilder().creator(creator).build();
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().backing(backing).participant(backer).project(project).build();
final MessageThreadEnvelope messageThreadEnvelope = MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messageThread(messageThread).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread messageThread) {
return Observable.just(messageThreadEnvelope);
}
@NonNull
@Override
public Observable<Backing> fetchProjectBacking(@NonNull final Project project, @NonNull final User user) {
return Observable.just(backing);
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(new MockCurrentUser(creator)).build());
this.vm.intent(messagesContextIntent(messageThread));
this.vm.inputs.viewPledgeButtonClicked();
this.startBackingActivity.assertValues(new BackingWrapper(messageThread.backing(), backer, project));
}
use of com.kickstarter.services.apiresponses.MessageThreadEnvelope in project android-oss by kickstarter.
the class MessagesViewModelTest method testCreatorViewingProjectMessages.
@Test
public void testCreatorViewingProjectMessages() {
final User creator = UserFactory.creator().toBuilder().name("Sharon").build();
final User participant = UserFactory.user().toBuilder().name("Timothy").build();
final CurrentUserType currentUser = new MockCurrentUser(creator);
final MessageThread messageThread = MessageThreadFactory.messageThread().toBuilder().project(ProjectFactory.project().toBuilder().creator(creator).build()).participant(participant).build();
final MockApiClient apiClient = new MockApiClient() {
@Override
@NonNull
public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread thread) {
return Observable.just(MessageThreadEnvelopeFactory.messageThreadEnvelope().toBuilder().messageThread(messageThread).build());
}
};
setUpEnvironment(environment().toBuilder().apiClient(apiClient).currentUser(currentUser).build());
// Start the view model with a message thread.
this.vm.intent(messagesContextIntent(messageThread));
// Creator name is the project creator, edit text hint is always the participant.
this.creatorNameTextViewText.assertValues(creator.name());
this.messageEditTextHint.assertValues(participant.name());
}
Aggregations