use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RefTagUtilsTest method testBuildCookieForRefTagAndProject_WithMalformedUrl.
@Test
public void testBuildCookieForRefTagAndProject_WithMalformedUrl() {
final Project.Urls.Web webUrls = ProjectFactory.project().urls().web().toBuilder().project("such:\\bad^<data").build();
final Project.Urls urls = ProjectFactory.project().urls().toBuilder().web(webUrls).build();
final Project project = ProjectFactory.project().toBuilder().urls(urls).build();
final RefTag refTag = RefTag.category();
final HttpCookie cookie = RefTagUtils.buildCookieWithRefTagAndProject(refTag, project);
assertNull(cookie);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RefTagUtilsTest method testFindRefTagCookieForProject_WhenCookieExists.
@Test
public void testFindRefTagCookieForProject_WhenCookieExists() {
final CookieManager cookieManager = new CookieManager();
final CookieStore cookieStore = cookieManager.getCookieStore();
final Project project = ProjectFactory.project();
final RefTag refTag = RefTag.recommended();
// set and retrieve the cookie
cookieStore.add(null, new HttpCookie("ref_" + project.id(), refTag.tag() + "%3F" + SystemUtils.secondsSinceEpoch()));
final HttpCookie cookie = RefTagUtils.findRefTagCookieForProject(project, cookieManager, sharedPreferences);
assertNotNull(cookie);
assertEquals(RefTagUtils.cookieNameForProject(project), cookie.getName());
assertEquals(RefTagUtils.cookieValueForRefTag(refTag), cookie.getValue());
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class RefTagUtilsTest method testBuildCookieForRefTagAndProject_WithWellFormedUrl.
@Test
public void testBuildCookieForRefTagAndProject_WithWellFormedUrl() {
final Project project = ProjectFactory.project();
final RefTag refTag = RefTag.category();
final HttpCookie cookie = RefTagUtils.buildCookieWithRefTagAndProject(refTag, project);
assertNotNull(cookie);
assertEquals(ProjectUtils.timeInSecondsUntilDeadline(project).longValue(), cookie.getMaxAge());
assertEquals("www.kickstarter.com", cookie.getDomain());
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ProfileViewModelTest method testProfileViewModel_StartProjectActivity.
@Test
public void testProfileViewModel_StartProjectActivity() {
final ProfileViewModel.ViewModel vm = new ProfileViewModel.ViewModel(environment());
final Project project = ProjectFactory.backedProject();
final TestSubscriber<Project> startProjectActivity = new TestSubscriber<>();
vm.outputs.startProjectActivity().subscribe(startProjectActivity);
vm.inputs.projectCardClicked(project);
startProjectActivity.assertValues(project);
}
use of com.kickstarter.models.Project in project android-oss by kickstarter.
the class ThanksViewModelTest method testThanksViewModel_dontShowGamesNewsletterDialogIfUserHasAlreadySignedUp.
@Test
public void testThanksViewModel_dontShowGamesNewsletterDialogIfUserHasAlreadySignedUp() {
final MockBooleanPreference hasSeenGamesNewsletterPreference = new MockBooleanPreference(false);
final User user = UserFactory.user().toBuilder().gamesNewsletter(true).build();
final CurrentUserType currentUser = new MockCurrentUser(user);
final Environment environment = environment().toBuilder().currentUser(currentUser).hasSeenGamesNewsletterPreference(hasSeenGamesNewsletterPreference).build();
final ThanksViewModel vm = new ThanksViewModel(environment);
final TestSubscriber<Void> showGamesNewsletterDialogTest = new TestSubscriber<>();
vm.outputs.showGamesNewsletterDialog().subscribe(showGamesNewsletterDialogTest);
final Project project = ProjectFactory.project().toBuilder().category(CategoryFactory.tabletopGamesCategory()).build();
vm.intent(new Intent().putExtra(IntentKey.PROJECT, project));
showGamesNewsletterDialogTest.assertValueCount(0);
}
Aggregations