Search in sources :

Example 11 with MessageThreadEnvelope

use of com.kickstarter.services.apiresponses.MessageThreadEnvelope in project android-oss by kickstarter.

the class MessagesViewModelTest method testNoMessages.

@Test
public void testNoMessages() {
    final Backing backing = BackingFactory.backing();
    final Project project = ProjectFactory.project();
    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(UserFactory.user())).build());
    // Start the view model with a backing and a project.
    this.vm.intent(backerModalContextIntent(backing, project));
    // All data except for messages should emit.
    this.messageList.assertNoValues();
    this.creatorNameTextViewText.assertValues(project.creator().name());
    this.backingAndProject.assertValues(Pair.create(backing, project));
}
Also used : Project(com.kickstarter.models.Project) MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) Backing(com.kickstarter.models.Backing) MessageThreadEnvelope(com.kickstarter.services.apiresponses.MessageThreadEnvelope) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 12 with MessageThreadEnvelope

use of com.kickstarter.services.apiresponses.MessageThreadEnvelope in project android-oss by kickstarter.

the class MessagesViewModelTest method testMessageEditTextHint.

@Test
public void testMessageEditTextHint() {
    final MessageThread messageThread = MessageThreadFactory.messageThread();
    final MockApiClient apiClient = new MockApiClient() {

        @Override
        @NonNull
        public Observable<MessageThreadEnvelope> fetchMessagesForThread(@NonNull final MessageThread thread) {
            return Observable.just(MessageThreadEnvelopeFactory.messageThreadEnvelope());
        }
    };
    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.messageEditTextHint.assertValues(messageThread.project().creator().name());
}
Also used : MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) MessageThread(com.kickstarter.models.MessageThread) MessageThreadEnvelope(com.kickstarter.services.apiresponses.MessageThreadEnvelope) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

NonNull (androidx.annotation.NonNull)12 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)12 MockApiClient (com.kickstarter.mock.services.MockApiClient)12 MessageThreadEnvelope (com.kickstarter.services.apiresponses.MessageThreadEnvelope)12 Test (org.junit.Test)12 Backing (com.kickstarter.models.Backing)8 MessageThread (com.kickstarter.models.MessageThread)7 Project (com.kickstarter.models.Project)5 User (com.kickstarter.models.User)5 BackingWrapper (com.kickstarter.models.BackingWrapper)3 CurrentUserType (com.kickstarter.libs.CurrentUserType)1