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);
});
}
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();
}
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();
}
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()));
}
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);
}
Aggregations