Search in sources :

Example 6 with RefTag

use of com.kickstarter.libs.RefTag 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());
}
Also used : CookieStore(java.net.CookieStore) Project(com.kickstarter.models.Project) RefTag(com.kickstarter.libs.RefTag) HttpCookie(java.net.HttpCookie) CookieManager(java.net.CookieManager) Test(org.junit.Test)

Example 7 with RefTag

use of com.kickstarter.libs.RefTag 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());
}
Also used : Project(com.kickstarter.models.Project) RefTag(com.kickstarter.libs.RefTag) HttpCookie(java.net.HttpCookie) Test(org.junit.Test)

Aggregations

RefTag (com.kickstarter.libs.RefTag)7 Test (org.junit.Test)7 Project (com.kickstarter.models.Project)4 HttpCookie (java.net.HttpCookie)4 Intent (android.content.Intent)2 CookieManager (java.net.CookieManager)2 CookieStore (java.net.CookieStore)2