{"action":"created","comment":{"url":"https://api.github.com/repos/pushtorefresh/storio/pulls/comments/40600848","id":40600848,"diff_hunk":"@@ -0,0 +1,146 @@\n+package com.pushtorefresh.storio.sqlite.operations.get;\n+\n+import android.database.Cursor;\n+import android.support.annotation.NonNull;\n+\n+import com.pushtorefresh.storio.sqlite.Changes;\n+import com.pushtorefresh.storio.sqlite.StorIOSQLite;\n+import com.pushtorefresh.storio.sqlite.queries.Query;\n+import com.pushtorefresh.storio.sqlite.queries.RawQuery;\n+import com.pushtorefresh.storio.test.ObservableBehaviorChecker;\n+\n+import rx.Observable;\n+import rx.functions.Action1;\n+\n+import static java.util.Collections.singleton;\n+import static org.assertj.core.api.Assertions.assertThat;\n+import static org.mockito.Matchers.eq;\n+import static org.mockito.Mockito.mock;\n+import static org.mockito.Mockito.times;\n+import static org.mockito.Mockito.verify;\n+import static org.mockito.Mockito.verifyNoMoreInteractions;\n+import static org.mockito.Mockito.when;\n+\n+class GetNumberOfResultsStub {\n+\n+    @NonNull\n+    final StorIOSQLite storIOSQLite;\n+\n+    @NonNull\n+    private final StorIOSQLite.Internal internal;\n+\n+    @NonNull\n+    final Query query;\n+\n+    @NonNull\n+    final RawQuery rawQuery;\n+\n+    @NonNull\n+    final GetResolver<Integer> getResolverForNumberOfResults;\n+\n+    @NonNull\n+    private final Cursor cursor;\n+\n+    @NonNull\n+    private final Integer numberOfResults;\n+\n+    @SuppressWarnings(\"unchecked\")\n+    private GetNumberOfResultsStub() {\n+        storIOSQLite = mock(StorIOSQLite.class);\n+        internal = mock(StorIOSQLite.Internal.class);\n+\n+        when(storIOSQLite.internal())\n+                .thenReturn(internal);\n+\n+        query = Query\n+                .builder()\n+                .table(\"test_table\")\n+                .build();\n+\n+        rawQuery = RawQuery\n+                .builder()\n+                .query(\"select * from who_cares\")\n+                .observesTables(\"test_table\")\n+                .build();\n+\n+        getResolverForNumberOfResults = mock(GetResolver.class);\n+        cursor = mock(Cursor.class);\n+\n+        numberOfResults = 129;\n+\n+        when(storIOSQLite.get())\n+                .thenReturn(new PreparedGet.Builder(storIOSQLite));\n+\n+        when(storIOSQLite.observeChangesInTables(eq(singleton(query.table()))))\n+                .thenReturn(Observable.<Changes>empty());\n+\n+        assertThat(rawQuery.observesTables()).isNotNull();\n+\n+        when(storIOSQLite.observeChangesInTables(rawQuery.observesTables()))\n+                .thenReturn(Observable.<Changes>empty());\n+\n+        when(getResolverForNumberOfResults.performGet(storIOSQLite, query))\n+                .thenReturn(cursor);\n+\n+        when(getResolverForNumberOfResults.performGet(storIOSQLite, rawQuery))\n+                .thenReturn(cursor);\n+\n+        when(getResolverForNumberOfResults.mapFromCursor(cursor))\n+                .thenReturn(numberOfResults);\n+    }\n+\n+    @NonNull\n+    static GetNumberOfResultsStub newInstance() {\n+        return new GetNumberOfResultsStub();\n+    }\n+\n+    void verifyQueryBehaviorForInteger(@NonNull Integer actualNumberOfResults) {\n+        assertThat(actualNumberOfResults).isNotNull();\n+        verify(storIOSQLite).get();\n+        verify(getResolverForNumberOfResults).performGet(storIOSQLite, query);\n+        assertThat(actualNumberOfResults).isSameAs(numberOfResults);\n+        verify(cursor).close();\n+        verifyNoMoreInteractions(storIOSQLite, internal, cursor);\n+    }\n+\n+    void verifyQueryBehaviorForInteger(@NonNull Observable<Integer> observable) {\n+        new ObservableBehaviorChecker<Integer>()\n+                .observable(observable)\n+                .expectedNumberOfEmissions(1)\n+                .testAction(new Action1<Integer>() {\n+                    @Override\n+                    public void call(Integer numberOfResults) {\n+                        // Get Operation should be subscribed to changes of tables from Query\n+                        verify(storIOSQLite).observeChangesInTables(eq(singleton(query.table())));\n+                        verifyQueryBehaviorForInteger(numberOfResults);\n+                    }\n+                })\n+                .checkBehaviorOfObservable();\n+    }\n+\n+    void verifyRawQueryBehaviorForInteger(@NonNull Integer actualNumberOfResults) {\n+        assertThat(actualNumberOfResults).isNotNull();\n+        verify(storIOSQLite, times(1)).get();","path":"storio-sqlite/src/test/java/com/pushtorefresh/storio/sqlite/operations/get/GetNumberOfResultsStub.java","position":123,"original_position":123,"commit_id":"74f2240cfca5e478bf11c5045a75c7380fba154a","original_commit_id":"74f2240cfca5e478bf11c5045a75c7380fba154a","user":{"login":"artem-zinnatullin","id":967132,"avatar_url":"https://avatars.githubusercontent.com/u/967132?v=3","gravatar_id":"","url":"https://api.github.com/users/artem-zinnatullin","html_url":"https://github.com/artem-zinnatullin","followers_url":"https://api.github.com/users/artem-zinnatullin/followers","following_url":"https://api.github.com/users/artem-zinnatullin/following{/other_user}","gists_url":"https://api.github.com/users/artem-zinnatullin/gists{/gist_id}","starred_url":"https://api.github.com/users/artem-zinnatullin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artem-zinnatullin/subscriptions","organizations_url":"https://api.github.com/users/artem-zinnatullin/orgs","repos_url":"https://api.github.com/users/artem-zinnatullin/repos","events_url":"https://api.github.com/users/artem-zinnatullin/events{/privacy}","received_events_url":"https://api.github.com/users/artem-zinnatullin/received_events","type":"User","site_admin":false},"body":"Ah, copy paste…)","created_at":"2015-09-28T20:26:05Z","updated_at":"2015-09-28T20:26:05Z","html_url":"https://github.com/pushtorefresh/storio/pull/533#discussion_r40600848","pull_request_url":"https://api.github.com/repos/pushtorefresh/storio/pulls/533","_links":{"self":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/comments/40600848"},"html":{"href":"https://github.com/pushtorefresh/storio/pull/533#discussion_r40600848"},"pull_request":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/533"}}},"pull_request":{"url":"https://api.github.com/repos/pushtorefresh/storio/pulls/533","id":46113137,"html_url":"https://github.com/pushtorefresh/storio/pull/533","diff_url":"https://github.com/pushtorefresh/storio/pull/533.diff","patch_url":"https://github.com/pushtorefresh/storio/pull/533.patch","issue_url":"https://api.github.com/repos/pushtorefresh/storio/issues/533","number":533,"state":"open","locked":false,"title":"Add StorIOSQLite get().numberOfResults()!","user":{"login":"artem-zinnatullin","id":967132,"avatar_url":"https://avatars.githubusercontent.com/u/967132?v=3","gravatar_id":"","url":"https://api.github.com/users/artem-zinnatullin","html_url":"https://github.com/artem-zinnatullin","followers_url":"https://api.github.com/users/artem-zinnatullin/followers","following_url":"https://api.github.com/users/artem-zinnatullin/following{/other_user}","gists_url":"https://api.github.com/users/artem-zinnatullin/gists{/gist_id}","starred_url":"https://api.github.com/users/artem-zinnatullin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artem-zinnatullin/subscriptions","organizations_url":"https://api.github.com/users/artem-zinnatullin/orgs","repos_url":"https://api.github.com/users/artem-zinnatullin/repos","events_url":"https://api.github.com/users/artem-zinnatullin/events{/privacy}","received_events_url":"https://api.github.com/users/artem-zinnatullin/received_events","type":"User","site_admin":false},"body":"Part of #44!\r\n\r\n@nikitin-da PTAL","created_at":"2015-09-28T00:51:01Z","updated_at":"2015-09-28T20:26:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e2bae01b148d6332f76338f5cc9125de72e90e93","assignee":{"login":"artem-zinnatullin","id":967132,"avatar_url":"https://avatars.githubusercontent.com/u/967132?v=3","gravatar_id":"","url":"https://api.github.com/users/artem-zinnatullin","html_url":"https://github.com/artem-zinnatullin","followers_url":"https://api.github.com/users/artem-zinnatullin/followers","following_url":"https://api.github.com/users/artem-zinnatullin/following{/other_user}","gists_url":"https://api.github.com/users/artem-zinnatullin/gists{/gist_id}","starred_url":"https://api.github.com/users/artem-zinnatullin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artem-zinnatullin/subscriptions","organizations_url":"https://api.github.com/users/artem-zinnatullin/orgs","repos_url":"https://api.github.com/users/artem-zinnatullin/repos","events_url":"https://api.github.com/users/artem-zinnatullin/events{/privacy}","received_events_url":"https://api.github.com/users/artem-zinnatullin/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/pushtorefresh/storio/milestones/17","html_url":"https://github.com/pushtorefresh/storio/milestones/v1.5.0","labels_url":"https://api.github.com/repos/pushtorefresh/storio/milestones/17/labels","id":1321209,"number":17,"title":"v1.5.0","description":null,"creator":{"login":"artem-zinnatullin","id":967132,"avatar_url":"https://avatars.githubusercontent.com/u/967132?v=3","gravatar_id":"","url":"https://api.github.com/users/artem-zinnatullin","html_url":"https://github.com/artem-zinnatullin","followers_url":"https://api.github.com/users/artem-zinnatullin/followers","following_url":"https://api.github.com/users/artem-zinnatullin/following{/other_user}","gists_url":"https://api.github.com/users/artem-zinnatullin/gists{/gist_id}","starred_url":"https://api.github.com/users/artem-zinnatullin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artem-zinnatullin/subscriptions","organizations_url":"https://api.github.com/users/artem-zinnatullin/orgs","repos_url":"https://api.github.com/users/artem-zinnatullin/repos","events_url":"https://api.github.com/users/artem-zinnatullin/events{/privacy}","received_events_url":"https://api.github.com/users/artem-zinnatullin/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":4,"state":"open","created_at":"2015-09-23T22:04:16Z","updated_at":"2015-09-28T00:51:01Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/pushtorefresh/storio/pulls/533/commits","review_comments_url":"https://api.github.com/repos/pushtorefresh/storio/pulls/533/comments","review_comment_url":"https://api.github.com/repos/pushtorefresh/storio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pushtorefresh/storio/issues/533/comments","statuses_url":"https://api.github.com/repos/pushtorefresh/storio/statuses/74f2240cfca5e478bf11c5045a75c7380fba154a","head":{"label":"pushtorefresh:sqlite-number-of-results","ref":"sqlite-number-of-results","sha":"74f2240cfca5e478bf11c5045a75c7380fba154a","user":{"login":"pushtorefresh","id":7294803,"avatar_url":"https://avatars.githubusercontent.com/u/7294803?v=3","gravatar_id":"","url":"https://api.github.com/users/pushtorefresh","html_url":"https://github.com/pushtorefresh","followers_url":"https://api.github.com/users/pushtorefresh/followers","following_url":"https://api.github.com/users/pushtorefresh/following{/other_user}","gists_url":"https://api.github.com/users/pushtorefresh/gists{/gist_id}","starred_url":"https://api.github.com/users/pushtorefresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushtorefresh/subscriptions","organizations_url":"https://api.github.com/users/pushtorefresh/orgs","repos_url":"https://api.github.com/users/pushtorefresh/repos","events_url":"https://api.github.com/users/pushtorefresh/events{/privacy}","received_events_url":"https://api.github.com/users/pushtorefresh/received_events","type":"Organization","site_admin":false},"repo":{"id":23502577,"name":"storio","full_name":"pushtorefresh/storio","owner":{"login":"pushtorefresh","id":7294803,"avatar_url":"https://avatars.githubusercontent.com/u/7294803?v=3","gravatar_id":"","url":"https://api.github.com/users/pushtorefresh","html_url":"https://github.com/pushtorefresh","followers_url":"https://api.github.com/users/pushtorefresh/followers","following_url":"https://api.github.com/users/pushtorefresh/following{/other_user}","gists_url":"https://api.github.com/users/pushtorefresh/gists{/gist_id}","starred_url":"https://api.github.com/users/pushtorefresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushtorefresh/subscriptions","organizations_url":"https://api.github.com/users/pushtorefresh/orgs","repos_url":"https://api.github.com/users/pushtorefresh/repos","events_url":"https://api.github.com/users/pushtorefresh/events{/privacy}","received_events_url":"https://api.github.com/users/pushtorefresh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pushtorefresh/storio","description":"Beautiful API for SQLiteDatabase and ContentResolver","fork":false,"url":"https://api.github.com/repos/pushtorefresh/storio","forks_url":"https://api.github.com/repos/pushtorefresh/storio/forks","keys_url":"https://api.github.com/repos/pushtorefresh/storio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pushtorefresh/storio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pushtorefresh/storio/teams","hooks_url":"https://api.github.com/repos/pushtorefresh/storio/hooks","issue_events_url":"https://api.github.com/repos/pushtorefresh/storio/issues/events{/number}","events_url":"https://api.github.com/repos/pushtorefresh/storio/events","assignees_url":"https://api.github.com/repos/pushtorefresh/storio/assignees{/user}","branches_url":"https://api.github.com/repos/pushtorefresh/storio/branches{/branch}","tags_url":"https://api.github.com/repos/pushtorefresh/storio/tags","blobs_url":"https://api.github.com/repos/pushtorefresh/storio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pushtorefresh/storio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pushtorefresh/storio/git/refs{/sha}","trees_url":"https://api.github.com/repos/pushtorefresh/storio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pushtorefresh/storio/statuses/{sha}","languages_url":"https://api.github.com/repos/pushtorefresh/storio/languages","stargazers_url":"https://api.github.com/repos/pushtorefresh/storio/stargazers","contributors_url":"https://api.github.com/repos/pushtorefresh/storio/contributors","subscribers_url":"https://api.github.com/repos/pushtorefresh/storio/subscribers","subscription_url":"https://api.github.com/repos/pushtorefresh/storio/subscription","commits_url":"https://api.github.com/repos/pushtorefresh/storio/commits{/sha}","git_commits_url":"https://api.github.com/repos/pushtorefresh/storio/git/commits{/sha}","comments_url":"https://api.github.com/repos/pushtorefresh/storio/comments{/number}","issue_comment_url":"https://api.github.com/repos/pushtorefresh/storio/issues/comments{/number}","contents_url":"https://api.github.com/repos/pushtorefresh/storio/contents/{+path}","compare_url":"https://api.github.com/repos/pushtorefresh/storio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pushtorefresh/storio/merges","archive_url":"https://api.github.com/repos/pushtorefresh/storio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pushtorefresh/storio/downloads","issues_url":"https://api.github.com/repos/pushtorefresh/storio/issues{/number}","pulls_url":"https://api.github.com/repos/pushtorefresh/storio/pulls{/number}","milestones_url":"https://api.github.com/repos/pushtorefresh/storio/milestones{/number}","notifications_url":"https://api.github.com/repos/pushtorefresh/storio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pushtorefresh/storio/labels{/name}","releases_url":"https://api.github.com/repos/pushtorefresh/storio/releases{/id}","created_at":"2014-08-30T23:23:41Z","updated_at":"2015-09-28T17:23:46Z","pushed_at":"2015-09-28T00:51:02Z","git_url":"git://github.com/pushtorefresh/storio.git","ssh_url":"git@github.com:pushtorefresh/storio.git","clone_url":"https://github.com/pushtorefresh/storio.git","svn_url":"https://github.com/pushtorefresh/storio","homepage":"","size":4936,"stargazers_count":1235,"watchers_count":1235,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":33,"forks":62,"open_issues":33,"watchers":1235,"default_branch":"master"}},"base":{"label":"pushtorefresh:master","ref":"master","sha":"879610c087333e4b2ef8ed3ee749a5260ea086c6","user":{"login":"pushtorefresh","id":7294803,"avatar_url":"https://avatars.githubusercontent.com/u/7294803?v=3","gravatar_id":"","url":"https://api.github.com/users/pushtorefresh","html_url":"https://github.com/pushtorefresh","followers_url":"https://api.github.com/users/pushtorefresh/followers","following_url":"https://api.github.com/users/pushtorefresh/following{/other_user}","gists_url":"https://api.github.com/users/pushtorefresh/gists{/gist_id}","starred_url":"https://api.github.com/users/pushtorefresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushtorefresh/subscriptions","organizations_url":"https://api.github.com/users/pushtorefresh/orgs","repos_url":"https://api.github.com/users/pushtorefresh/repos","events_url":"https://api.github.com/users/pushtorefresh/events{/privacy}","received_events_url":"https://api.github.com/users/pushtorefresh/received_events","type":"Organization","site_admin":false},"repo":{"id":23502577,"name":"storio","full_name":"pushtorefresh/storio","owner":{"login":"pushtorefresh","id":7294803,"avatar_url":"https://avatars.githubusercontent.com/u/7294803?v=3","gravatar_id":"","url":"https://api.github.com/users/pushtorefresh","html_url":"https://github.com/pushtorefresh","followers_url":"https://api.github.com/users/pushtorefresh/followers","following_url":"https://api.github.com/users/pushtorefresh/following{/other_user}","gists_url":"https://api.github.com/users/pushtorefresh/gists{/gist_id}","starred_url":"https://api.github.com/users/pushtorefresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pushtorefresh/subscriptions","organizations_url":"https://api.github.com/users/pushtorefresh/orgs","repos_url":"https://api.github.com/users/pushtorefresh/repos","events_url":"https://api.github.com/users/pushtorefresh/events{/privacy}","received_events_url":"https://api.github.com/users/pushtorefresh/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pushtorefresh/storio","description":"Beautiful API for SQLiteDatabase and ContentResolver","fork":false,"url":"https://api.github.com/repos/pushtorefresh/storio","forks_url":"https://api.github.com/repos/pushtorefresh/storio/forks","keys_url":"https://api.github.com/repos/pushtorefresh/storio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pushtorefresh/storio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pushtorefresh/storio/teams","hooks_url":"https://api.github.com/repos/pushtorefresh/storio/hooks","issue_events_url":"https://api.github.com/repos/pushtorefresh/storio/issues/events{/number}","events_url":"https://api.github.com/repos/pushtorefresh/storio/events","assignees_url":"https://api.github.com/repos/pushtorefresh/storio/assignees{/user}","branches_url":"https://api.github.com/repos/pushtorefresh/storio/branches{/branch}","tags_url":"https://api.github.com/repos/pushtorefresh/storio/tags","blobs_url":"https://api.github.com/repos/pushtorefresh/storio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pushtorefresh/storio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pushtorefresh/storio/git/refs{/sha}","trees_url":"https://api.github.com/repos/pushtorefresh/storio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pushtorefresh/storio/statuses/{sha}","languages_url":"https://api.github.com/repos/pushtorefresh/storio/languages","stargazers_url":"https://api.github.com/repos/pushtorefresh/storio/stargazers","contributors_url":"https://api.github.com/repos/pushtorefresh/storio/contributors","subscribers_url":"https://api.github.com/repos/pushtorefresh/storio/subscribers","subscription_url":"https://api.github.com/repos/pushtorefresh/storio/subscription","commits_url":"https://api.github.com/repos/pushtorefresh/storio/commits{/sha}","git_commits_url":"https://api.github.com/repos/pushtorefresh/storio/git/commits{/sha}","comments_url":"https://api.github.com/repos/pushtorefresh/storio/comments{/number}","issue_comment_url":"https://api.github.com/repos/pushtorefresh/storio/issues/comments{/number}","contents_url":"https://api.github.com/repos/pushtorefresh/storio/contents/{+path}","compare_url":"https://api.github.com/repos/pushtorefresh/storio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pushtorefresh/storio/merges","archive_url":"https://api.github.com/repos/pushtorefresh/storio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pushtorefresh/storio/downloads","issues_url":"https://api.github.com/repos/pushtorefresh/storio/issues{/number}","pulls_url":"https://api.github.com/repos/pushtorefresh/storio/pulls{/number}","milestones_url":"https://api.github.com/repos/pushtorefresh/storio/milestones{/number}","notifications_url":"https://api.github.com/repos/pushtorefresh/storio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pushtorefresh/storio/labels{/name}","releases_url":"https://api.github.com/repos/pushtorefresh/storio/releases{/id}","created_at":"2014-08-30T23:23:41Z","updated_at":"2015-09-28T17:23:46Z","pushed_at":"2015-09-28T00:51:02Z","git_url":"git://github.com/pushtorefresh/storio.git","ssh_url":"git@github.com:pushtorefresh/storio.git","clone_url":"https://github.com/pushtorefresh/storio.git","svn_url":"https://github.com/pushtorefresh/storio","homepage":"","size":4936,"stargazers_count":1235,"watchers_count":1235,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":33,"forks":62,"open_issues":33,"watchers":1235,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/533"},"html":{"href":"https://github.com/pushtorefresh/storio/pull/533"},"issue":{"href":"https://api.github.com/repos/pushtorefresh/storio/issues/533"},"comments":{"href":"https://api.github.com/repos/pushtorefresh/storio/issues/533/comments"},"review_comments":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/533/comments"},"review_comment":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/533/commits"},"statuses":{"href":"https://api.github.com/repos/pushtorefresh/storio/statuses/74f2240cfca5e478bf11c5045a75c7380fba154a"}}}}