{"action":"created","comment":{"url":"https://api.github.com/repos/pushtorefresh/storio/pulls/comments/29558430","id":29558430,"diff_hunk":"@@ -0,0 +1,99 @@\n+package com.pushtorefresh.storio.sqlite.impl;\n+\n+\n+import android.os.SystemClock;\n+import android.support.test.runner.AndroidJUnit4;\n+\n+import com.pushtorefresh.storio.sqlite.Changes;\n+\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+\n+import java.util.ArrayList;\n+import java.util.HashSet;\n+import java.util.List;\n+import java.util.Set;\n+import java.util.concurrent.CountDownLatch;\n+\n+import rx.observers.TestObserver;\n+\n+import static java.util.Collections.singletonList;\n+import static org.junit.Assert.assertEquals;\n+\n+@RunWith(AndroidJUnit4.class)\n+public class NotifyAboutChangesTest extends BaseTest {\n+\n+    @Test\n+    public void notifyAboutChange() {\n+        TestObserver<Changes> testObserver = new TestObserver<Changes>();\n+\n+        storIOSQLite\n+                .observeChangesInTable(\"test_table\")\n+                .subscribe(testObserver);\n+\n+        storIOSQLite\n+                .internal()\n+                .notifyAboutChanges(Changes.newInstance(\"test_table\"));\n+\n+        final long startTime = SystemClock.elapsedRealtime();\n+\n+        while (testObserver.getOnNextEvents().size() == 0 && SystemClock.elapsedRealtime() - startTime < 1000) {\n+            SystemClock.sleep(5);\n+        }\n+\n+        testObserver.assertReceivedOnNext(singletonList(Changes.newInstance(\"test_table\")));\n+    }\n+\n+    @Test\n+    public void notifyAboutChangesConcurrently() {\n+        final int numberOfThreads = 5;\n+\n+        final TestObserver<Changes> testObserver = new TestObserver<Changes>();\n+\n+        final Set<String> tables = new HashSet<String>();\n+        final List<Changes> expectedChanges = new ArrayList<Changes>();\n+\n+        for (int i = 0; i < numberOfThreads; i++) {\n+            final String table = \"test_table\" + i;\n+            tables.add(table);\n+            expectedChanges.add(Changes.newInstance(table));\n+        }\n+\n+        storIOSQLite\n+                .observeChangesInTables(tables)\n+                .subscribe(testObserver);\n+\n+        final CountDownLatch countDownLatch = new CountDownLatch(1);\n+\n+        for (int i = 0; i < numberOfThreads; i++) {\n+            final int finalI = i;\n+            new Thread(new Runnable() {\n+                @Override\n+                public void run() {\n+                    try {\n+                        // all threads should start simultaneously\n+                        countDownLatch.await();\n+\n+                        storIOSQLite\n+                                .internal()\n+                                .notifyAboutChanges(Changes.newInstance(\"test_table\" + finalI));\n+                    } catch (InterruptedException e) {\n+                        throw new RuntimeException(e);\n+                    }\n+                }\n+            }).start();\n+        }\n+\n+        countDownLatch.countDown();\n+\n+        final long startTime = SystemClock.elapsedRealtime();\n+\n+        while (testObserver.getOnNextEvents().size() != tables.size() && SystemClock.elapsedRealtime() - startTime < 1000) {\n+            SystemClock.sleep(5);\n+        }\n+\n+        // notice, that order of received notification can be different\n+        // but in total, they should be equal\n+        assertEquals(expectedChanges, testObserver.getOnNextEvents());","path":"storio-sqlite/src/androidTest/java/com/pushtorefresh/storio/sqlite/impl/NotifyAboutChangesTest.java","position":97,"original_position":97,"commit_id":"6f1880a1b3112a2760523d4574dc13e60a06d89a","original_commit_id":"6f1880a1b3112a2760523d4574dc13e60a06d89a","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":"Damn, I wrote correct comment but incorrect `assert`","created_at":"2015-05-03T18:02:45Z","updated_at":"2015-05-03T18:02:45Z","html_url":"https://github.com/pushtorefresh/storio/pull/314#discussion_r29558430","pull_request_url":"https://api.github.com/repos/pushtorefresh/storio/pulls/314","_links":{"self":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/comments/29558430"},"html":{"href":"https://github.com/pushtorefresh/storio/pull/314#discussion_r29558430"},"pull_request":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/314"}}},"pull_request":{"url":"https://api.github.com/repos/pushtorefresh/storio/pulls/314","id":34593970,"html_url":"https://github.com/pushtorefresh/storio/pull/314","diff_url":"https://github.com/pushtorefresh/storio/pull/314.diff","patch_url":"https://github.com/pushtorefresh/storio/pull/314.patch","issue_url":"https://api.github.com/repos/pushtorefresh/storio/issues/314","number":314,"state":"open","locked":false,"title":"SQLite transactions, pending changes","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":"New Pending Changes mechanism for `DefaultStorIOSQLite`, it will allow us create `GroupOperation` without worrying  about changes from nested transactions!\r\n\r\nAlso, I've added more tests for Put Operation\r\n\r\nCloses #296 \r\n\r\n@nikitin-da PTAL\r\n\r\n ","created_at":"2015-05-03T00:03:10Z","updated_at":"2015-05-03T18:02:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ee2d0cb3234aac6d39751a301580689bac70b8e","assignee":{"login":"nikitin-da","id":7294857,"avatar_url":"https://avatars.githubusercontent.com/u/7294857?v=3","gravatar_id":"","url":"https://api.github.com/users/nikitin-da","html_url":"https://github.com/nikitin-da","followers_url":"https://api.github.com/users/nikitin-da/followers","following_url":"https://api.github.com/users/nikitin-da/following{/other_user}","gists_url":"https://api.github.com/users/nikitin-da/gists{/gist_id}","starred_url":"https://api.github.com/users/nikitin-da/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikitin-da/subscriptions","organizations_url":"https://api.github.com/users/nikitin-da/orgs","repos_url":"https://api.github.com/users/nikitin-da/repos","events_url":"https://api.github.com/users/nikitin-da/events{/privacy}","received_events_url":"https://api.github.com/users/nikitin-da/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/pushtorefresh/storio/milestones/6","html_url":"https://github.com/pushtorefresh/storio/milestones/v1.0.0","labels_url":"https://api.github.com/repos/pushtorefresh/storio/milestones/6/labels","id":789775,"number":6,"title":"v1.0.0","description":"","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":8,"closed_issues":247,"state":"open","created_at":"2014-09-15T11:57:16Z","updated_at":"2015-05-03T00:12:40Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/pushtorefresh/storio/pulls/314/commits","review_comments_url":"https://api.github.com/repos/pushtorefresh/storio/pulls/314/comments","review_comment_url":"https://api.github.com/repos/pushtorefresh/storio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pushtorefresh/storio/issues/314/comments","statuses_url":"https://api.github.com/repos/pushtorefresh/storio/statuses/6f1880a1b3112a2760523d4574dc13e60a06d89a","head":{"label":"pushtorefresh:storio-sqlite-transactions","ref":"storio-sqlite-transactions","sha":"6f1880a1b3112a2760523d4574dc13e60a06d89a","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":"Modern 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-05-03T01:21:50Z","pushed_at":"2015-05-03T14:52:01Z","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":4286,"stargazers_count":239,"watchers_count":239,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":18,"forks":9,"open_issues":18,"watchers":239,"default_branch":"master"}},"base":{"label":"pushtorefresh:master","ref":"master","sha":"2d37cd95471cf03da33fbfe1033b099eb80bf275","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":"Modern 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-05-03T01:21:50Z","pushed_at":"2015-05-03T14:52:01Z","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":4286,"stargazers_count":239,"watchers_count":239,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":18,"forks":9,"open_issues":18,"watchers":239,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/314"},"html":{"href":"https://github.com/pushtorefresh/storio/pull/314"},"issue":{"href":"https://api.github.com/repos/pushtorefresh/storio/issues/314"},"comments":{"href":"https://api.github.com/repos/pushtorefresh/storio/issues/314/comments"},"review_comments":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/314/comments"},"review_comment":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pushtorefresh/storio/pulls/314/commits"},"statuses":{"href":"https://api.github.com/repos/pushtorefresh/storio/statuses/6f1880a1b3112a2760523d4574dc13e60a06d89a"}}}}