Search in sources :

Example 1 with BackingWrapper

use of com.kickstarter.models.BackingWrapper 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));
}
Also used : Project(com.kickstarter.models.Project) User(com.kickstarter.models.User) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) BackingWrapper(com.kickstarter.models.BackingWrapper) Backing(com.kickstarter.models.Backing) MessageThreadEnvelope(com.kickstarter.services.apiresponses.MessageThreadEnvelope) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 2 with BackingWrapper

use of com.kickstarter.models.BackingWrapper 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));
}
Also used : Project(com.kickstarter.models.Project) User(com.kickstarter.models.User) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) BackingWrapper(com.kickstarter.models.BackingWrapper) MessageThread(com.kickstarter.models.MessageThread) Backing(com.kickstarter.models.Backing) MessageThreadEnvelope(com.kickstarter.services.apiresponses.MessageThreadEnvelope) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 3 with BackingWrapper

use of com.kickstarter.models.BackingWrapper 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));
}
Also used : Project(com.kickstarter.models.Project) User(com.kickstarter.models.User) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) BackingWrapper(com.kickstarter.models.BackingWrapper) MessageThread(com.kickstarter.models.MessageThread) Backing(com.kickstarter.models.Backing) MessageThreadEnvelope(com.kickstarter.services.apiresponses.MessageThreadEnvelope) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Example 4 with BackingWrapper

use of com.kickstarter.models.BackingWrapper in project android-oss by kickstarter.

the class BackingViewModelTest method testShowBackingFragmentFacing.

@Test
public void testShowBackingFragmentFacing() {
    final User creatorUser = UserFactory.user().toBuilder().name("Kawhi Leonard").build();
    final User backerUser = UserFactory.user().toBuilder().name("random backer").build();
    final Backing backing = BackingFactory.backing(backerUser);
    final Project project = ProjectFactory.project();
    final BackingWrapper wrapper = new BackingWrapper(backing, backerUser, project);
    setUpEnvironment(envWithBacking(backing).toBuilder().currentUser(new MockCurrentUser(creatorUser)).build());
    this.vm.outputs.showBackingFragment().subscribe(it -> {
        assertNotNull(it);
        assertEquals(backing, it);
    });
}
Also used : Project(com.kickstarter.models.Project) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) User(com.kickstarter.models.User) BackingWrapper(com.kickstarter.models.BackingWrapper) Backing(com.kickstarter.models.Backing) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) Test(org.junit.Test)

Aggregations

MockCurrentUser (com.kickstarter.libs.MockCurrentUser)4 Backing (com.kickstarter.models.Backing)4 BackingWrapper (com.kickstarter.models.BackingWrapper)4 Project (com.kickstarter.models.Project)4 User (com.kickstarter.models.User)4 Test (org.junit.Test)4 NonNull (androidx.annotation.NonNull)3 MockApiClient (com.kickstarter.mock.services.MockApiClient)3 MessageThreadEnvelope (com.kickstarter.services.apiresponses.MessageThreadEnvelope)3 MessageThread (com.kickstarter.models.MessageThread)2