{"action":"created","comment":{"url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/comments/63559507","id":63559507,"diff_hunk":"@@ -0,0 +1,227 @@\n+package net.pubnative.library.banner;\n+\n+import android.app.Activity;\n+import android.content.Context;\n+import android.os.Handler;\n+import android.os.HandlerThread;\n+import android.os.Looper;\n+\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.mockito.Mock;\n+import org.mockito.invocation.InvocationOnMock;\n+import org.mockito.stubbing.Answer;\n+import org.robolectric.RobolectricGradleTestRunner;\n+import org.robolectric.annotation.Config;\n+import org.robolectric.internal.ShadowExtractor;\n+import org.robolectric.shadows.ShadowLooper;\n+\n+import static org.mockito.Matchers.any;\n+import static org.mockito.Matchers.eq;\n+import static org.mockito.Mockito.doAnswer;\n+import static org.mockito.Mockito.mock;\n+import static org.mockito.Mockito.spy;\n+import static org.mockito.Mockito.verify;\n+import static org.mockito.Mockito.when;\n+\n+@Config(constants = BuildConfig.class, sdk = 16)\n+@RunWith(RobolectricGradleTestRunner.class)\n+public class PubnativeBannerTest {\n+\n+    public static final String FAKE_APP_TOKEN = \"1234567890\";\n+\n+    @Mock Context mMockContext;\n+\n+    protected Handler serviceHandler;\n+    protected Looper serviceLooper;\n+\n+    @Test\n+    public void invokeLoadFail_shouldCallOnLoadFail() {\n+\n+        PubnativeBanner banner = spy(PubnativeBanner.class);\n+        PubnativeBanner.Listener listener = mock(PubnativeBanner.Listener.class);\n+        HandlerThread serviceThread = new HandlerThread(\"[\" + PubnativeBanner.class.getSimpleName() + \"Thread]\");\n+        serviceThread.start();\n+        serviceLooper = serviceThread.getLooper();\n+        serviceHandler = new Handler(serviceLooper);\n+\n+        banner.mHandler = serviceHandler;\n+        banner.mListener = listener;\n+        Exception ex = new Exception();\n+        banner.invokeLoadFail(ex);\n+        ((ShadowLooper) ShadowExtractor.extract(serviceThread.getLooper())).idle();\n+\n+        verify(listener).onPubnativeBannerLoadFail(eq(banner), eq(ex));\n+    }\n+\n+    @Test\n+    public void invokeLoadFinish_shouldCallOnLoadFinish() {\n+\n+        PubnativeBanner banner = spy(PubnativeBanner.class);\n+        PubnativeBanner.Listener listener = mock(PubnativeBanner.Listener.class);\n+        HandlerThread serviceThread = new HandlerThread(\"[\" + PubnativeBanner.class.getSimpleName() + \"Thread]\");\n+        serviceThread.start();\n+        serviceLooper = serviceThread.getLooper();\n+        serviceHandler = new Handler(serviceLooper);\n+\n+        banner.mHandler = serviceHandler;\n+        banner.mListener = listener;\n+        banner.invokeLoadFinish();\n+        ((ShadowLooper) ShadowExtractor.extract(serviceThread.getLooper())).idle();","path":"library.banner/src/test/java/net/pubnative/library/banner/PubnativeBannerTest.java","position":70,"original_position":70,"commit_id":"cd89467bfb4715082da62de5f5e4eccaabb8d048","original_commit_id":"cd89467bfb4715082da62de5f5e4eccaabb8d048","user":{"login":"RagnarR","id":897618,"avatar_url":"https://avatars.githubusercontent.com/u/897618?v=3","gravatar_id":"","url":"https://api.github.com/users/RagnarR","html_url":"https://github.com/RagnarR","followers_url":"https://api.github.com/users/RagnarR/followers","following_url":"https://api.github.com/users/RagnarR/following{/other_user}","gists_url":"https://api.github.com/users/RagnarR/gists{/gist_id}","starred_url":"https://api.github.com/users/RagnarR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RagnarR/subscriptions","organizations_url":"https://api.github.com/users/RagnarR/orgs","repos_url":"https://api.github.com/users/RagnarR/repos","events_url":"https://api.github.com/users/RagnarR/events{/privacy}","received_events_url":"https://api.github.com/users/RagnarR/received_events","type":"User","site_admin":false},"body":"We need to cast it because we ant to use the method from ShadowLooper - idle(). It allows use shorter style during the coding.","created_at":"2016-05-17T16:47:36Z","updated_at":"2016-05-17T16:47:36Z","html_url":"https://github.com/pubnative/pubnative-android-library/pull/97#discussion_r63559507","pull_request_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/97","_links":{"self":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/comments/63559507"},"html":{"href":"https://github.com/pubnative/pubnative-android-library/pull/97#discussion_r63559507"},"pull_request":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/97"}}},"pull_request":{"url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/97","id":69316675,"html_url":"https://github.com/pubnative/pubnative-android-library/pull/97","diff_url":"https://github.com/pubnative/pubnative-android-library/pull/97.diff","patch_url":"https://github.com/pubnative/pubnative-android-library/pull/97.patch","issue_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/97","number":97,"state":"open","locked":false,"title":"Banner implementation","user":{"login":"RagnarR","id":897618,"avatar_url":"https://avatars.githubusercontent.com/u/897618?v=3","gravatar_id":"","url":"https://api.github.com/users/RagnarR","html_url":"https://github.com/RagnarR","followers_url":"https://api.github.com/users/RagnarR/followers","following_url":"https://api.github.com/users/RagnarR/following{/other_user}","gists_url":"https://api.github.com/users/RagnarR/gists{/gist_id}","starred_url":"https://api.github.com/users/RagnarR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RagnarR/subscriptions","organizations_url":"https://api.github.com/users/RagnarR/orgs","repos_url":"https://api.github.com/users/RagnarR/repos","events_url":"https://api.github.com/users/RagnarR/events{/privacy}","received_events_url":"https://api.github.com/users/RagnarR/received_events","type":"User","site_admin":false},"body":"Implemented Banner module. Added example of using in library demo app.","created_at":"2016-05-09T09:21:55Z","updated_at":"2016-05-17T16:47:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f907d770131e03586eb1968eaa2cc201fb5a0df7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/97/commits","review_comments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/97/comments","review_comment_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/97/comments","statuses_url":"https://api.github.com/repos/pubnative/pubnative-android-library/statuses/cd89467bfb4715082da62de5f5e4eccaabb8d048","head":{"label":"pubnative:banner_implementation","ref":"banner_implementation","sha":"cd89467bfb4715082da62de5f5e4eccaabb8d048","user":{"login":"pubnative","id":7806659,"avatar_url":"https://avatars.githubusercontent.com/u/7806659?v=3","gravatar_id":"","url":"https://api.github.com/users/pubnative","html_url":"https://github.com/pubnative","followers_url":"https://api.github.com/users/pubnative/followers","following_url":"https://api.github.com/users/pubnative/following{/other_user}","gists_url":"https://api.github.com/users/pubnative/gists{/gist_id}","starred_url":"https://api.github.com/users/pubnative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubnative/subscriptions","organizations_url":"https://api.github.com/users/pubnative/orgs","repos_url":"https://api.github.com/users/pubnative/repos","events_url":"https://api.github.com/users/pubnative/events{/privacy}","received_events_url":"https://api.github.com/users/pubnative/received_events","type":"Organization","site_admin":false},"repo":{"id":28917789,"name":"pubnative-android-library","full_name":"pubnative/pubnative-android-library","owner":{"login":"pubnative","id":7806659,"avatar_url":"https://avatars.githubusercontent.com/u/7806659?v=3","gravatar_id":"","url":"https://api.github.com/users/pubnative","html_url":"https://github.com/pubnative","followers_url":"https://api.github.com/users/pubnative/followers","following_url":"https://api.github.com/users/pubnative/following{/other_user}","gists_url":"https://api.github.com/users/pubnative/gists{/gist_id}","starred_url":"https://api.github.com/users/pubnative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubnative/subscriptions","organizations_url":"https://api.github.com/users/pubnative/orgs","repos_url":"https://api.github.com/users/pubnative/repos","events_url":"https://api.github.com/users/pubnative/events{/privacy}","received_events_url":"https://api.github.com/users/pubnative/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pubnative/pubnative-android-library","description":"","fork":false,"url":"https://api.github.com/repos/pubnative/pubnative-android-library","forks_url":"https://api.github.com/repos/pubnative/pubnative-android-library/forks","keys_url":"https://api.github.com/repos/pubnative/pubnative-android-library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pubnative/pubnative-android-library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pubnative/pubnative-android-library/teams","hooks_url":"https://api.github.com/repos/pubnative/pubnative-android-library/hooks","issue_events_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/events{/number}","events_url":"https://api.github.com/repos/pubnative/pubnative-android-library/events","assignees_url":"https://api.github.com/repos/pubnative/pubnative-android-library/assignees{/user}","branches_url":"https://api.github.com/repos/pubnative/pubnative-android-library/branches{/branch}","tags_url":"https://api.github.com/repos/pubnative/pubnative-android-library/tags","blobs_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/refs{/sha}","trees_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pubnative/pubnative-android-library/statuses/{sha}","languages_url":"https://api.github.com/repos/pubnative/pubnative-android-library/languages","stargazers_url":"https://api.github.com/repos/pubnative/pubnative-android-library/stargazers","contributors_url":"https://api.github.com/repos/pubnative/pubnative-android-library/contributors","subscribers_url":"https://api.github.com/repos/pubnative/pubnative-android-library/subscribers","subscription_url":"https://api.github.com/repos/pubnative/pubnative-android-library/subscription","commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/commits{/sha}","git_commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/commits{/sha}","comments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/comments{/number}","issue_comment_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/comments{/number}","contents_url":"https://api.github.com/repos/pubnative/pubnative-android-library/contents/{+path}","compare_url":"https://api.github.com/repos/pubnative/pubnative-android-library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pubnative/pubnative-android-library/merges","archive_url":"https://api.github.com/repos/pubnative/pubnative-android-library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pubnative/pubnative-android-library/downloads","issues_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues{/number}","pulls_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls{/number}","milestones_url":"https://api.github.com/repos/pubnative/pubnative-android-library/milestones{/number}","notifications_url":"https://api.github.com/repos/pubnative/pubnative-android-library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pubnative/pubnative-android-library/labels{/name}","releases_url":"https://api.github.com/repos/pubnative/pubnative-android-library/releases{/id}","deployments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/deployments","created_at":"2015-01-07T14:26:18Z","updated_at":"2016-01-29T10:58:51Z","pushed_at":"2016-05-17T16:35:18Z","git_url":"git://github.com/pubnative/pubnative-android-library.git","ssh_url":"git@github.com:pubnative/pubnative-android-library.git","clone_url":"https://github.com/pubnative/pubnative-android-library.git","svn_url":"https://github.com/pubnative/pubnative-android-library","homepage":null,"size":3785,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":2,"forks":6,"open_issues":2,"watchers":6,"default_branch":"master"}},"base":{"label":"pubnative:development","ref":"development","sha":"cc85ddfd2b0d41c3e43a54f17dc076be743c887f","user":{"login":"pubnative","id":7806659,"avatar_url":"https://avatars.githubusercontent.com/u/7806659?v=3","gravatar_id":"","url":"https://api.github.com/users/pubnative","html_url":"https://github.com/pubnative","followers_url":"https://api.github.com/users/pubnative/followers","following_url":"https://api.github.com/users/pubnative/following{/other_user}","gists_url":"https://api.github.com/users/pubnative/gists{/gist_id}","starred_url":"https://api.github.com/users/pubnative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubnative/subscriptions","organizations_url":"https://api.github.com/users/pubnative/orgs","repos_url":"https://api.github.com/users/pubnative/repos","events_url":"https://api.github.com/users/pubnative/events{/privacy}","received_events_url":"https://api.github.com/users/pubnative/received_events","type":"Organization","site_admin":false},"repo":{"id":28917789,"name":"pubnative-android-library","full_name":"pubnative/pubnative-android-library","owner":{"login":"pubnative","id":7806659,"avatar_url":"https://avatars.githubusercontent.com/u/7806659?v=3","gravatar_id":"","url":"https://api.github.com/users/pubnative","html_url":"https://github.com/pubnative","followers_url":"https://api.github.com/users/pubnative/followers","following_url":"https://api.github.com/users/pubnative/following{/other_user}","gists_url":"https://api.github.com/users/pubnative/gists{/gist_id}","starred_url":"https://api.github.com/users/pubnative/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pubnative/subscriptions","organizations_url":"https://api.github.com/users/pubnative/orgs","repos_url":"https://api.github.com/users/pubnative/repos","events_url":"https://api.github.com/users/pubnative/events{/privacy}","received_events_url":"https://api.github.com/users/pubnative/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pubnative/pubnative-android-library","description":"","fork":false,"url":"https://api.github.com/repos/pubnative/pubnative-android-library","forks_url":"https://api.github.com/repos/pubnative/pubnative-android-library/forks","keys_url":"https://api.github.com/repos/pubnative/pubnative-android-library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pubnative/pubnative-android-library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pubnative/pubnative-android-library/teams","hooks_url":"https://api.github.com/repos/pubnative/pubnative-android-library/hooks","issue_events_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/events{/number}","events_url":"https://api.github.com/repos/pubnative/pubnative-android-library/events","assignees_url":"https://api.github.com/repos/pubnative/pubnative-android-library/assignees{/user}","branches_url":"https://api.github.com/repos/pubnative/pubnative-android-library/branches{/branch}","tags_url":"https://api.github.com/repos/pubnative/pubnative-android-library/tags","blobs_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/refs{/sha}","trees_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pubnative/pubnative-android-library/statuses/{sha}","languages_url":"https://api.github.com/repos/pubnative/pubnative-android-library/languages","stargazers_url":"https://api.github.com/repos/pubnative/pubnative-android-library/stargazers","contributors_url":"https://api.github.com/repos/pubnative/pubnative-android-library/contributors","subscribers_url":"https://api.github.com/repos/pubnative/pubnative-android-library/subscribers","subscription_url":"https://api.github.com/repos/pubnative/pubnative-android-library/subscription","commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/commits{/sha}","git_commits_url":"https://api.github.com/repos/pubnative/pubnative-android-library/git/commits{/sha}","comments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/comments{/number}","issue_comment_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/comments{/number}","contents_url":"https://api.github.com/repos/pubnative/pubnative-android-library/contents/{+path}","compare_url":"https://api.github.com/repos/pubnative/pubnative-android-library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pubnative/pubnative-android-library/merges","archive_url":"https://api.github.com/repos/pubnative/pubnative-android-library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pubnative/pubnative-android-library/downloads","issues_url":"https://api.github.com/repos/pubnative/pubnative-android-library/issues{/number}","pulls_url":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls{/number}","milestones_url":"https://api.github.com/repos/pubnative/pubnative-android-library/milestones{/number}","notifications_url":"https://api.github.com/repos/pubnative/pubnative-android-library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pubnative/pubnative-android-library/labels{/name}","releases_url":"https://api.github.com/repos/pubnative/pubnative-android-library/releases{/id}","deployments_url":"https://api.github.com/repos/pubnative/pubnative-android-library/deployments","created_at":"2015-01-07T14:26:18Z","updated_at":"2016-01-29T10:58:51Z","pushed_at":"2016-05-17T16:35:18Z","git_url":"git://github.com/pubnative/pubnative-android-library.git","ssh_url":"git@github.com:pubnative/pubnative-android-library.git","clone_url":"https://github.com/pubnative/pubnative-android-library.git","svn_url":"https://github.com/pubnative/pubnative-android-library","homepage":null,"size":3785,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":2,"forks":6,"open_issues":2,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/97"},"html":{"href":"https://github.com/pubnative/pubnative-android-library/pull/97"},"issue":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/97"},"comments":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/issues/97/comments"},"review_comments":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/97/comments"},"review_comment":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/pulls/97/commits"},"statuses":{"href":"https://api.github.com/repos/pubnative/pubnative-android-library/statuses/cd89467bfb4715082da62de5f5e4eccaabb8d048"}}}}