Search in sources :

Example 16 with Backing

use of com.kickstarter.models.Backing 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)

Example 17 with Backing

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

the class BackingUtils method isBacked.

public static boolean isBacked(@NonNull final Project project, @NonNull final Reward reward) {
    final Backing backing = project.backing();
    if (backing == null) {
        return false;
    }
    final Long rewardId = backing.rewardId();
    if (rewardId == null) {
        return false;
    }
    return rewardId == reward.id();
}
Also used : Backing(com.kickstarter.models.Backing)

Example 18 with Backing

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

the class ProjectFactory method backedProjectWithRewardLimitReached.

@NonNull
public static Project backedProjectWithRewardLimitReached() {
    final Project project = project();
    final Reward reward = RewardFactory.limitReached();
    final Backing backing = Backing.builder().amount(10.0f).backerId(IdFactory.id()).id(IdFactory.id()).sequence(1).reward(reward).rewardId(reward.id()).pledgedAt(DateTime.now()).projectCountry(project.country()).projectId(project.id()).shippingAmount(0.0f).status(Backing.STATUS_PLEDGED).build();
    return project.toBuilder().backing(backing).isBacking(true).build();
}
Also used : Project(com.kickstarter.models.Project) Reward(com.kickstarter.models.Reward) Backing(com.kickstarter.models.Backing) NonNull(android.support.annotation.NonNull)

Example 19 with Backing

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

the class BackingUtilsTest method testIsShippable.

@Test
public void testIsShippable() {
    final Backing backingWithShipping = BackingFactory.backing().toBuilder().reward(RewardFactory.rewardWithShipping()).build();
    assertTrue(BackingUtils.isShippable(backingWithShipping));
    assertFalse(BackingUtils.isShippable(BackingFactory.backing()));
}
Also used : Backing(com.kickstarter.models.Backing) Test(org.junit.Test)

Example 20 with Backing

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

the class ViewPledgeViewModelTest method testShipping_withoutShippingLocation.

@Test
public void testShipping_withoutShippingLocation() {
    final Backing backing = BackingFactory.backing();
    final ViewPledgeViewModel vm = vm(backing);
    final TestSubscriber<String> shippingLocationTextViewTextTest = TestSubscriber.create();
    vm.outputs.shippingLocationTextViewText().subscribe(shippingLocationTextViewTextTest);
    final TestSubscriber<String> shippingAmountTextViewTextTest = TestSubscriber.create();
    vm.outputs.shippingAmountTextViewText().subscribe(shippingAmountTextViewTextTest);
    final TestSubscriber<Boolean> shippingSectionIsHiddenTest = TestSubscriber.create();
    vm.outputs.shippingSectionIsHidden().subscribe(shippingSectionIsHiddenTest);
    vm.intent(intent(backing));
    shippingLocationTextViewTextTest.assertNoValues();
    shippingAmountTextViewTextTest.assertNoValues();
    shippingSectionIsHiddenTest.assertValues(true);
}
Also used : Backing(com.kickstarter.models.Backing) Test(org.junit.Test)

Aggregations

Backing (com.kickstarter.models.Backing)30 Test (org.junit.Test)26 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)11 Project (com.kickstarter.models.Project)11 NonNull (androidx.annotation.NonNull)9 MockApiClient (com.kickstarter.mock.services.MockApiClient)9 MessageThreadEnvelope (com.kickstarter.services.apiresponses.MessageThreadEnvelope)8 Reward (com.kickstarter.models.Reward)7 User (com.kickstarter.models.User)6 BackingWrapper (com.kickstarter.models.BackingWrapper)4 MessageThread (com.kickstarter.models.MessageThread)4 NonNull (android.support.annotation.NonNull)3 Pair (android.util.Pair)2 Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2 Location (com.kickstarter.models.Location)1