{"action":"created","comment":{"url":"https://api.github.com/repos/nickbutcher/plaid/pulls/comments/196722760","pull_request_review_id":130326708,"id":196722760,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NjcyMjc2MA==","diff_hunk":"@@ -0,0 +1,100 @@\n+package io.plaidapp.designernews.login.data\n+\n+import android.content.Context\n+import android.support.test.InstrumentationRegistry\n+import io.plaidapp.base.designernews.data.api.DesignerNewsAuthTokenLocalDataSource\n+import io.plaidapp.base.designernews.data.api.DesignerNewsService\n+import io.plaidapp.base.designernews.data.api.model.AccessToken\n+import io.plaidapp.base.designernews.data.api.model.User\n+import io.plaidapp.base.designernews.login.data.DesignerNewsLoginRemoteDataSource\n+import org.junit.After\n+import org.junit.Assert\n+import org.junit.Assert.assertNull\n+import org.junit.Test\n+import org.mockito.Mockito\n+import retrofit2.mock.Calls\n+import java.io.IOException\n+\n+/**\n+ * Tests for [DesignerNewsLoginRemoteDataSource].\n+ */\n+class DesignerNewsLoginRemoteDataSourceTest {\n+\n+    private val user = User.Builder()\n+            .setId(1)\n+            .setDisplayName(\"Name\")\n+            .setPortraitUrl(\"www\")\n+            .build()\n+\n+    private val accessToken = AccessToken(\"token\", \"type\", \"scope\")\n+    private var sharedPreferences = InstrumentationRegistry.getInstrumentation().context\n+            .getSharedPreferences(\"test\", Context.MODE_PRIVATE)\n+\n+    private val service = Mockito.mock(DesignerNewsService::class.java)\n+    private val authHolder = DesignerNewsAuthTokenLocalDataSource(sharedPreferences)\n+    private val dataSource = DesignerNewsLoginRemoteDataSource(authHolder, service)\n+\n+    @After\n+    fun tearDown() {\n+        // cleanup the shared preferences after every test\n+        sharedPreferences.edit().clear().commit()\n+    }\n+\n+    @Test\n+    fun logout_clearsToken() {\n+        dataSource.logout()\n+\n+        assertNull(authHolder.authToken)\n+    }\n+\n+    @Test\n+    fun login_successful_when_AccessTokenAndGetUserSuccessful() {\n+        // Given that all API calls are successful\n+        Mockito.`when`(service.login(Mockito.anyMap())).thenReturn(Calls.response(accessToken))\n+        Mockito.`when`(service.getAuthedUser()).thenReturn(Calls.response(arrayListOf(user)))\n+\n+        // Login is successful\n+        dataSource.login(\n+                \"test\",\n+                \"test\",\n+                { it -> assert(user == it) },","path":"base/src/androidTest/java/io/plaidapp/designernews/login/data/DesignerNewsLoginRemoteDataSourceTest.kt","position":60,"original_position":60,"commit_id":"20a3890355373df22a8cd40e62efacd47ecfd458","original_commit_id":"20a3890355373df22a8cd40e62efacd47ecfd458","user":{"login":"nickbutcher","id":352556,"node_id":"MDQ6VXNlcjM1MjU1Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/352556?v=4","gravatar_id":"","url":"https://api.github.com/users/nickbutcher","html_url":"https://github.com/nickbutcher","followers_url":"https://api.github.com/users/nickbutcher/followers","following_url":"https://api.github.com/users/nickbutcher/following{/other_user}","gists_url":"https://api.github.com/users/nickbutcher/gists{/gist_id}","starred_url":"https://api.github.com/users/nickbutcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickbutcher/subscriptions","organizations_url":"https://api.github.com/users/nickbutcher/orgs","repos_url":"https://api.github.com/users/nickbutcher/repos","events_url":"https://api.github.com/users/nickbutcher/events{/privacy}","received_events_url":"https://api.github.com/users/nickbutcher/received_events","type":"User","site_admin":false},"body":"We should also assert that the `onSuccess` callback is called.","created_at":"2018-06-20T10:20:29Z","updated_at":"2018-06-20T10:59:41Z","html_url":"https://github.com/nickbutcher/plaid/pull/300#discussion_r196722760","pull_request_url":"https://api.github.com/repos/nickbutcher/plaid/pulls/300","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/nickbutcher/plaid/pulls/comments/196722760"},"html":{"href":"https://github.com/nickbutcher/plaid/pull/300#discussion_r196722760"},"pull_request":{"href":"https://api.github.com/repos/nickbutcher/plaid/pulls/300"}}},"pull_request":{"url":"https://api.github.com/repos/nickbutcher/plaid/pulls/300","id":194903027,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0OTAzMDI3","html_url":"https://github.com/nickbutcher/plaid/pull/300","diff_url":"https://github.com/nickbutcher/plaid/pull/300.diff","patch_url":"https://github.com/nickbutcher/plaid/pull/300.patch","issue_url":"https://api.github.com/repos/nickbutcher/plaid/issues/300","number":300,"state":"open","locked":false,"title":"Moving the DN login logic away from the activity","user":{"login":"florina-muntenescu","id":2998890,"node_id":"MDQ6VXNlcjI5OTg4OTA=","avatar_url":"https://avatars1.githubusercontent.com/u/2998890?v=4","gravatar_id":"","url":"https://api.github.com/users/florina-muntenescu","html_url":"https://github.com/florina-muntenescu","followers_url":"https://api.github.com/users/florina-muntenescu/followers","following_url":"https://api.github.com/users/florina-muntenescu/following{/other_user}","gists_url":"https://api.github.com/users/florina-muntenescu/gists{/gist_id}","starred_url":"https://api.github.com/users/florina-muntenescu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/florina-muntenescu/subscriptions","organizations_url":"https://api.github.com/users/florina-muntenescu/orgs","repos_url":"https://api.github.com/users/florina-muntenescu/repos","events_url":"https://api.github.com/users/florina-muntenescu/events{/privacy}","received_events_url":"https://api.github.com/users/florina-muntenescu/received_events","type":"User","site_admin":false},"body":"Moving the DN login logic away from the login activity.\r\n\r\nUsing v2 version of DN /me API","created_at":"2018-06-14T13:58:03Z","updated_at":"2018-06-20T10:59:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15eabf902a42c2ac83a765db982a09d25e46d247","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":967812733,"node_id":"MDU6TGFiZWw5Njc4MTI3MzM=","url":"https://api.github.com/repos/nickbutcher/plaid/labels/Ready%20for%20review","name":"Ready for review","color":"b5dd5d","default":false},{"id":297408938,"node_id":"MDU6TGFiZWwyOTc0MDg5Mzg=","url":"https://api.github.com/repos/nickbutcher/plaid/labels/cla:%20yes","name":"cla: yes","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/nickbutcher/plaid/pulls/300/commits","review_comments_url":"https://api.github.com/repos/nickbutcher/plaid/pulls/300/comments","review_comment_url":"https://api.github.com/repos/nickbutcher/plaid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nickbutcher/plaid/issues/300/comments","statuses_url":"https://api.github.com/repos/nickbutcher/plaid/statuses/20a3890355373df22a8cd40e62efacd47ecfd458","head":{"label":"nickbutcher:fm/dn_api_move","ref":"fm/dn_api_move","sha":"20a3890355373df22a8cd40e62efacd47ecfd458","user":{"login":"nickbutcher","id":352556,"node_id":"MDQ6VXNlcjM1MjU1Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/352556?v=4","gravatar_id":"","url":"https://api.github.com/users/nickbutcher","html_url":"https://github.com/nickbutcher","followers_url":"https://api.github.com/users/nickbutcher/followers","following_url":"https://api.github.com/users/nickbutcher/following{/other_user}","gists_url":"https://api.github.com/users/nickbutcher/gists{/gist_id}","starred_url":"https://api.github.com/users/nickbutcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickbutcher/subscriptions","organizations_url":"https://api.github.com/users/nickbutcher/orgs","repos_url":"https://api.github.com/users/nickbutcher/repos","events_url":"https://api.github.com/users/nickbutcher/events{/privacy}","received_events_url":"https://api.github.com/users/nickbutcher/received_events","type":"User","site_admin":false},"repo":{"id":45261969,"node_id":"MDEwOlJlcG9zaXRvcnk0NTI2MTk2OQ==","name":"plaid","full_name":"nickbutcher/plaid","owner":{"login":"nickbutcher","id":352556,"node_id":"MDQ6VXNlcjM1MjU1Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/352556?v=4","gravatar_id":"","url":"https://api.github.com/users/nickbutcher","html_url":"https://github.com/nickbutcher","followers_url":"https://api.github.com/users/nickbutcher/followers","following_url":"https://api.github.com/users/nickbutcher/following{/other_user}","gists_url":"https://api.github.com/users/nickbutcher/gists{/gist_id}","starred_url":"https://api.github.com/users/nickbutcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickbutcher/subscriptions","organizations_url":"https://api.github.com/users/nickbutcher/orgs","repos_url":"https://api.github.com/users/nickbutcher/repos","events_url":"https://api.github.com/users/nickbutcher/events{/privacy}","received_events_url":"https://api.github.com/users/nickbutcher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nickbutcher/plaid","description":"An Android app which provides design news & inspiration as well as being an example of implementing material design.","fork":false,"url":"https://api.github.com/repos/nickbutcher/plaid","forks_url":"https://api.github.com/repos/nickbutcher/plaid/forks","keys_url":"https://api.github.com/repos/nickbutcher/plaid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nickbutcher/plaid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nickbutcher/plaid/teams","hooks_url":"https://api.github.com/repos/nickbutcher/plaid/hooks","issue_events_url":"https://api.github.com/repos/nickbutcher/plaid/issues/events{/number}","events_url":"https://api.github.com/repos/nickbutcher/plaid/events","assignees_url":"https://api.github.com/repos/nickbutcher/plaid/assignees{/user}","branches_url":"https://api.github.com/repos/nickbutcher/plaid/branches{/branch}","tags_url":"https://api.github.com/repos/nickbutcher/plaid/tags","blobs_url":"https://api.github.com/repos/nickbutcher/plaid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nickbutcher/plaid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nickbutcher/plaid/git/refs{/sha}","trees_url":"https://api.github.com/repos/nickbutcher/plaid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nickbutcher/plaid/statuses/{sha}","languages_url":"https://api.github.com/repos/nickbutcher/plaid/languages","stargazers_url":"https://api.github.com/repos/nickbutcher/plaid/stargazers","contributors_url":"https://api.github.com/repos/nickbutcher/plaid/contributors","subscribers_url":"https://api.github.com/repos/nickbutcher/plaid/subscribers","subscription_url":"https://api.github.com/repos/nickbutcher/plaid/subscription","commits_url":"https://api.github.com/repos/nickbutcher/plaid/commits{/sha}","git_commits_url":"https://api.github.com/repos/nickbutcher/plaid/git/commits{/sha}","comments_url":"https://api.github.com/repos/nickbutcher/plaid/comments{/number}","issue_comment_url":"https://api.github.com/repos/nickbutcher/plaid/issues/comments{/number}","contents_url":"https://api.github.com/repos/nickbutcher/plaid/contents/{+path}","compare_url":"https://api.github.com/repos/nickbutcher/plaid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nickbutcher/plaid/merges","archive_url":"https://api.github.com/repos/nickbutcher/plaid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nickbutcher/plaid/downloads","issues_url":"https://api.github.com/repos/nickbutcher/plaid/issues{/number}","pulls_url":"https://api.github.com/repos/nickbutcher/plaid/pulls{/number}","milestones_url":"https://api.github.com/repos/nickbutcher/plaid/milestones{/number}","notifications_url":"https://api.github.com/repos/nickbutcher/plaid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nickbutcher/plaid/labels{/name}","releases_url":"https://api.github.com/repos/nickbutcher/plaid/releases{/id}","deployments_url":"https://api.github.com/repos/nickbutcher/plaid/deployments","created_at":"2015-10-30T16:10:56Z","updated_at":"2018-06-20T08:51:55Z","pushed_at":"2018-06-20T07:18:17Z","git_url":"git://github.com/nickbutcher/plaid.git","ssh_url":"git@github.com:nickbutcher/plaid.git","clone_url":"https://github.com/nickbutcher/plaid.git","svn_url":"https://github.com/nickbutcher/plaid","homepage":"","size":31650,"stargazers_count":11142,"watchers_count":11142,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2368,"mirror_url":null,"archived":false,"open_issues_count":74,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2368,"open_issues":74,"watchers":11142,"default_branch":"master"}},"base":{"label":"nickbutcher:master","ref":"master","sha":"7ab70c98655917dd2e15a8f05a7491c12b5f0b37","user":{"login":"nickbutcher","id":352556,"node_id":"MDQ6VXNlcjM1MjU1Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/352556?v=4","gravatar_id":"","url":"https://api.github.com/users/nickbutcher","html_url":"https://github.com/nickbutcher","followers_url":"https://api.github.com/users/nickbutcher/followers","following_url":"https://api.github.com/users/nickbutcher/following{/other_user}","gists_url":"https://api.github.com/users/nickbutcher/gists{/gist_id}","starred_url":"https://api.github.com/users/nickbutcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickbutcher/subscriptions","organizations_url":"https://api.github.com/users/nickbutcher/orgs","repos_url":"https://api.github.com/users/nickbutcher/repos","events_url":"https://api.github.com/users/nickbutcher/events{/privacy}","received_events_url":"https://api.github.com/users/nickbutcher/received_events","type":"User","site_admin":false},"repo":{"id":45261969,"node_id":"MDEwOlJlcG9zaXRvcnk0NTI2MTk2OQ==","name":"plaid","full_name":"nickbutcher/plaid","owner":{"login":"nickbutcher","id":352556,"node_id":"MDQ6VXNlcjM1MjU1Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/352556?v=4","gravatar_id":"","url":"https://api.github.com/users/nickbutcher","html_url":"https://github.com/nickbutcher","followers_url":"https://api.github.com/users/nickbutcher/followers","following_url":"https://api.github.com/users/nickbutcher/following{/other_user}","gists_url":"https://api.github.com/users/nickbutcher/gists{/gist_id}","starred_url":"https://api.github.com/users/nickbutcher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickbutcher/subscriptions","organizations_url":"https://api.github.com/users/nickbutcher/orgs","repos_url":"https://api.github.com/users/nickbutcher/repos","events_url":"https://api.github.com/users/nickbutcher/events{/privacy}","received_events_url":"https://api.github.com/users/nickbutcher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nickbutcher/plaid","description":"An Android app which provides design news & inspiration as well as being an example of implementing material design.","fork":false,"url":"https://api.github.com/repos/nickbutcher/plaid","forks_url":"https://api.github.com/repos/nickbutcher/plaid/forks","keys_url":"https://api.github.com/repos/nickbutcher/plaid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nickbutcher/plaid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nickbutcher/plaid/teams","hooks_url":"https://api.github.com/repos/nickbutcher/plaid/hooks","issue_events_url":"https://api.github.com/repos/nickbutcher/plaid/issues/events{/number}","events_url":"https://api.github.com/repos/nickbutcher/plaid/events","assignees_url":"https://api.github.com/repos/nickbutcher/plaid/assignees{/user}","branches_url":"https://api.github.com/repos/nickbutcher/plaid/branches{/branch}","tags_url":"https://api.github.com/repos/nickbutcher/plaid/tags","blobs_url":"https://api.github.com/repos/nickbutcher/plaid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nickbutcher/plaid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nickbutcher/plaid/git/refs{/sha}","trees_url":"https://api.github.com/repos/nickbutcher/plaid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nickbutcher/plaid/statuses/{sha}","languages_url":"https://api.github.com/repos/nickbutcher/plaid/languages","stargazers_url":"https://api.github.com/repos/nickbutcher/plaid/stargazers","contributors_url":"https://api.github.com/repos/nickbutcher/plaid/contributors","subscribers_url":"https://api.github.com/repos/nickbutcher/plaid/subscribers","subscription_url":"https://api.github.com/repos/nickbutcher/plaid/subscription","commits_url":"https://api.github.com/repos/nickbutcher/plaid/commits{/sha}","git_commits_url":"https://api.github.com/repos/nickbutcher/plaid/git/commits{/sha}","comments_url":"https://api.github.com/repos/nickbutcher/plaid/comments{/number}","issue_comment_url":"https://api.github.com/repos/nickbutcher/plaid/issues/comments{/number}","contents_url":"https://api.github.com/repos/nickbutcher/plaid/contents/{+path}","compare_url":"https://api.github.com/repos/nickbutcher/plaid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nickbutcher/plaid/merges","archive_url":"https://api.github.com/repos/nickbutcher/plaid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nickbutcher/plaid/downloads","issues_url":"https://api.github.com/repos/nickbutcher/plaid/issues{/number}","pulls_url":"https://api.github.com/repos/nickbutcher/plaid/pulls{/number}","milestones_url":"https://api.github.com/repos/nickbutcher/plaid/milestones{/number}","notifications_url":"https://api.github.com/repos/nickbutcher/plaid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nickbutcher/plaid/labels{/name}","releases_url":"https://api.github.com/repos/nickbutcher/plaid/releases{/id}","deployments_url":"https://api.github.com/repos/nickbutcher/plaid/deployments","created_at":"2015-10-30T16:10:56Z","updated_at":"2018-06-20T08:51:55Z","pushed_at":"2018-06-20T07:18:17Z","git_url":"git://github.com/nickbutcher/plaid.git","ssh_url":"git@github.com:nickbutcher/plaid.git","clone_url":"https://github.com/nickbutcher/plaid.git","svn_url":"https://github.com/nickbutcher/plaid","homepage":"","size":31650,"stargazers_count":11142,"watchers_count":11142,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2368,"mirror_url":null,"archived":false,"open_issues_count":74,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":2368,"open_issues":74,"watchers":11142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nickbutcher/plaid/pulls/300"},"html":{"href":"https://github.com/nickbutcher/plaid/pull/300"},"issue":{"href":"https://api.github.com/repos/nickbutcher/plaid/issues/300"},"comments":{"href":"https://api.github.com/repos/nickbutcher/plaid/issues/300/comments"},"review_comments":{"href":"https://api.github.com/repos/nickbutcher/plaid/pulls/300/comments"},"review_comment":{"href":"https://api.github.com/repos/nickbutcher/plaid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nickbutcher/plaid/pulls/300/commits"},"statuses":{"href":"https://api.github.com/repos/nickbutcher/plaid/statuses/20a3890355373df22a8cd40e62efacd47ecfd458"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"nickbutcher"}}