{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/comments/63935712","id":63935712,"diff_hunk":"@@ -0,0 +1,204 @@\n+package com.shopify.buy.dataprovider;\n+\n+import android.support.test.runner.AndroidJUnit4;\n+\n+import com.shopify.buy.extensions.ShopifyAndroidTestCase;\n+import com.shopify.buy.model.Checkout;\n+import com.shopify.buy.model.PaymentToken;\n+import com.shopify.buy.model.internal.CheckoutWrapper;\n+\n+import org.apache.http.HttpStatus;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.mockito.Mockito;\n+\n+import java.lang.reflect.Field;\n+import java.util.concurrent.CountDownLatch;\n+\n+import okhttp3.HttpUrl;\n+import okhttp3.Protocol;\n+import retrofit2.Response;\n+import rx.Observable;\n+import rx.Subscriber;\n+\n+import static junit.framework.Assert.assertEquals;\n+import static junit.framework.Assert.assertNotNull;\n+import static junit.framework.Assert.fail;\n+\n+/**\n+ * The integration level test for the Mobile Buy SDK\n+ */\n+@RunWith(AndroidJUnit4.class)\n+public class CompleteCheckoutTest extends ShopifyAndroidTestCase {\n+\n+    Checkout checkout;\n+    CheckoutWrapper checkoutWrapper;\n+\n+    CheckoutRetrofitService checkoutRetrofitService;\n+\n+    PaymentToken paymentToken;\n+\n+    int callCount;\n+\n+    @Override\n+    public void setUp() throws Exception {\n+        super.setUp();\n+\n+        checkout = Checkout.fromJson(\"{\\\"id\\\":100, \\\"channel\\\":\\\"mobile_app\\\",\\\"payment_due\\\":\\\"payment_due\\\",\\\"token\\\":\\\"checkout_token\\\"}\");\n+        checkoutWrapper = new CheckoutWrapper(checkout);\n+\n+        checkoutRetrofitService = Mockito.mock(CheckoutRetrofitService.class);\n+\n+        paymentToken = PaymentToken.createCreditCardPaymentToken(\"paymenttoken\");\n+\n+        final Field retrofitServiceField = CheckoutServiceDefault.class.getDeclaredField(\"retrofitService\");\n+        retrofitServiceField.setAccessible(true);\n+        retrofitServiceField.set((((BuyClientDefault) buyClient).checkoutService), checkoutRetrofitService);\n+    }\n+\n+    @Test\n+    public void testCompletingCheckoutWithNullCheckoutToken() throws InterruptedException {\n+        final CountDownLatch latch = new CountDownLatch(1);\n+\n+        try {\n+            buyClient.completeCheckout(paymentToken, null);\n+        } catch (IllegalArgumentException e) {\n+            latch.countDown();\n+            return;\n+        }\n+\n+        latch.await();\n+\n+        fail(\"Expected an IllegalArgumentException\");\n+    }\n+\n+    @Test\n+    public void testCompletingCheckoutWithEmptyCheckoutToken() throws InterruptedException {\n+        final CountDownLatch latch = new CountDownLatch(1);\n+\n+        try {\n+            buyClient.completeCheckout(paymentToken, \"\");\n+        } catch (IllegalArgumentException e) {\n+            latch.countDown();\n+            return;\n+        }\n+\n+        latch.await();\n+\n+        fail(\"Expected an IllegalArgumentException\");\n+    }\n+\n+    @Test\n+    public void testCompletingCheckoutWithNullPaymentToken() throws InterruptedException {\n+        final CountDownLatch latch = new CountDownLatch(1);\n+\n+        try {\n+            buyClient.completeCheckout(null, checkout.getToken());\n+        } catch (NullPointerException e) {\n+            latch.countDown();\n+            return;\n+        }\n+\n+        latch.await();\n+\n+        fail(\"Expected an NullPointerException\");\n+    }\n+\n+\n+    @Test\n+    public void testCompleteCheckoutWithNonIOError() throws InterruptedException{\n+        final Observable<Response<CheckoutWrapper>> response = Observable.error(new RetrofitError(HttpStatus.SC_PRECONDITION_FAILED, \"precondition failed\"));","path":"MobileBuy/buy/src/androidTest/java/com/shopify/buy/dataprovider/CompleteCheckoutTest.java","position":110,"original_position":110,"commit_id":"956c1fec8b91abf91617809a2d825d9bf934a5cd","original_commit_id":"956c1fec8b91abf91617809a2d825d9bf934a5cd","user":{"login":"sav007","id":902816,"avatar_url":"https://avatars.githubusercontent.com/u/902816?v=3","gravatar_id":"","url":"https://api.github.com/users/sav007","html_url":"https://github.com/sav007","followers_url":"https://api.github.com/users/sav007/followers","following_url":"https://api.github.com/users/sav007/following{/other_user}","gists_url":"https://api.github.com/users/sav007/gists{/gist_id}","starred_url":"https://api.github.com/users/sav007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sav007/subscriptions","organizations_url":"https://api.github.com/users/sav007/orgs","repos_url":"https://api.github.com/users/sav007/repos","events_url":"https://api.github.com/users/sav007/events{/privacy}","received_events_url":"https://api.github.com/users/sav007/received_events","type":"User","site_admin":false},"body":"I believe we have deleted retrofit error","created_at":"2016-05-19T19:00:05Z","updated_at":"2016-05-19T19:00:05Z","html_url":"https://github.com/Shopify/mobile-buy-sdk-android/pull/130#discussion_r63935712","pull_request_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/130","_links":{"self":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/comments/63935712"},"html":{"href":"https://github.com/Shopify/mobile-buy-sdk-android/pull/130#discussion_r63935712"},"pull_request":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/130"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/130","id":70416833,"html_url":"https://github.com/Shopify/mobile-buy-sdk-android/pull/130","diff_url":"https://github.com/Shopify/mobile-buy-sdk-android/pull/130.diff","patch_url":"https://github.com/Shopify/mobile-buy-sdk-android/pull/130.patch","issue_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues/130","number":130,"state":"open","locked":false,"title":"Task/test polling endpoints","user":{"login":"krisorr","id":1737920,"avatar_url":"https://avatars.githubusercontent.com/u/1737920?v=3","gravatar_id":"","url":"https://api.github.com/users/krisorr","html_url":"https://github.com/krisorr","followers_url":"https://api.github.com/users/krisorr/followers","following_url":"https://api.github.com/users/krisorr/following{/other_user}","gists_url":"https://api.github.com/users/krisorr/gists{/gist_id}","starred_url":"https://api.github.com/users/krisorr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krisorr/subscriptions","organizations_url":"https://api.github.com/users/krisorr/orgs","repos_url":"https://api.github.com/users/krisorr/repos","events_url":"https://api.github.com/users/krisorr/events{/privacy}","received_events_url":"https://api.github.com/users/krisorr/received_events","type":"User","site_admin":false},"body":"# What this does\r\nAdds some tests that exercise the retry and polling in buyClient.getShippingRates().\r\n\r\nAddresses #123 \r\n\r\n@yervantk @sav007 please review","created_at":"2016-05-17T19:36:45Z","updated_at":"2016-05-19T19:00:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b208d3e9b7b953f345f27eb48a1b1405977a65d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/130/commits","review_comments_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/130/comments","review_comment_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues/130/comments","statuses_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/statuses/956c1fec8b91abf91617809a2d825d9bf934a5cd","head":{"label":"Shopify:task/test_polling_endpoints","ref":"task/test_polling_endpoints","sha":"956c1fec8b91abf91617809a2d825d9bf934a5cd","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":43315252,"name":"mobile-buy-sdk-android","full_name":"Shopify/mobile-buy-sdk-android","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/mobile-buy-sdk-android","description":"Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.","fork":false,"url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android","forks_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/forks","keys_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/teams","hooks_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/hooks","issue_events_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/events","assignees_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/tags","blobs_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/languages","stargazers_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/stargazers","contributors_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/contributors","subscribers_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/subscribers","subscription_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/subscription","commits_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/merges","archive_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/downloads","issues_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/deployments","created_at":"2015-09-28T17:19:37Z","updated_at":"2016-05-16T02:38:32Z","pushed_at":"2016-05-19T18:54:30Z","git_url":"git://github.com/Shopify/mobile-buy-sdk-android.git","ssh_url":"git@github.com:Shopify/mobile-buy-sdk-android.git","clone_url":"https://github.com/Shopify/mobile-buy-sdk-android.git","svn_url":"https://github.com/Shopify/mobile-buy-sdk-android","homepage":"","size":1804,"stargazers_count":19,"watchers_count":19,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":11,"mirror_url":null,"open_issues_count":28,"forks":11,"open_issues":28,"watchers":19,"default_branch":"master"}},"base":{"label":"Shopify:version-2","ref":"version-2","sha":"6519e01e8ecf0d59a1b59a5330b2c5bf2b23278d","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":43315252,"name":"mobile-buy-sdk-android","full_name":"Shopify/mobile-buy-sdk-android","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/mobile-buy-sdk-android","description":"Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.","fork":false,"url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android","forks_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/forks","keys_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/teams","hooks_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/hooks","issue_events_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/events","assignees_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/tags","blobs_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/languages","stargazers_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/stargazers","contributors_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/contributors","subscribers_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/subscribers","subscription_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/subscription","commits_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/merges","archive_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/downloads","issues_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/deployments","created_at":"2015-09-28T17:19:37Z","updated_at":"2016-05-16T02:38:32Z","pushed_at":"2016-05-19T18:54:30Z","git_url":"git://github.com/Shopify/mobile-buy-sdk-android.git","ssh_url":"git@github.com:Shopify/mobile-buy-sdk-android.git","clone_url":"https://github.com/Shopify/mobile-buy-sdk-android.git","svn_url":"https://github.com/Shopify/mobile-buy-sdk-android","homepage":"","size":1804,"stargazers_count":19,"watchers_count":19,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":11,"mirror_url":null,"open_issues_count":28,"forks":11,"open_issues":28,"watchers":19,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/130"},"html":{"href":"https://github.com/Shopify/mobile-buy-sdk-android/pull/130"},"issue":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues/130"},"comments":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/issues/130/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/130/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/pulls/130/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/mobile-buy-sdk-android/statuses/956c1fec8b91abf91617809a2d825d9bf934a5cd"}}}}