{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-app-android/pulls/comments/28980280","id":28980280,"diff_hunk":"@@ -0,0 +1,118 @@\n+package org.edx.mobile.test;\n+\n+import org.edx.mobile.model.api.CourseEntry;\n+import org.edx.mobile.model.api.EnrolledCoursesResponse;\n+import org.edx.mobile.module.notification.EdxLocalParseChannel;\n+import org.edx.mobile.module.notification.NotificationDelegate;\n+import org.edx.mobile.module.notification.NotificationPreference;\n+import org.edx.mobile.module.notification.UserNotificationManager;\n+import org.mockito.Mockito;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+public class NotificationTest extends BaseTestCase {\n+\n+    private static NotificationDelegate tracker;\n+    private static UserNotificationManager manager;\n+\n+    private final String  courseId1 = \"course_id_1\";\n+    private final String  courseId2 = \"course_id_2\";\n+    private final String  courseId3 = \"course_id_3\";\n+    private final String  channelId1 = \"channel_id_1\";\n+    private final String  channelId2 = \"channel_id_2\";\n+    private final String  channelId3 = \"channel_id_3\";\n+\n+    @Override\n+    protected void setUp() throws Exception {\n+        super.setUp();\n+        initDelegation();\n+    }\n+\n+    private void initDelegation() {\n+\n+        if (manager == null) {\n+            tracker = Mockito.mock(NotificationDelegate.class);\n+\n+            manager =   UserNotificationManager.getInstance();\n+            // use mocked tracker\n+            manager.setDelegate(tracker);\n+        }\n+    }\n+\n+\n+    public void testNotificationPreference() throws Exception {\n+\n+        EdxLocalParseChannel channel1 =\n+                new EdxLocalParseChannel( courseId1, channelId1, true);\n+        EdxLocalParseChannel channel2 =\n+                new EdxLocalParseChannel( courseId2, channelId2, false);\n+\n+        NotificationPreference pref = new NotificationPreference();\n+        pref.add( channel1 ) ;\n+        pref.add( channel2 ) ;\n+\n+        assertTrue(\"getByChannelId\", pref.getByChannelId(channelId1).getChannelId().equals(channelId1));\n+        assertTrue(\"getByCourseId\", pref.getByCourseId(courseId1).getCourseId().equals(courseId1));\n+\n+        assertTrue( pref.size() == 2 );\n+\n+\n+        CourseEntry courseEntry1 = new CourseEntry();\n+        courseEntry1.setId( courseId1 );\n+        CourseEntry courseEntry2 = new CourseEntry();\n+        courseEntry2.setId( courseId2 );\n+        CourseEntry courseEntry3 = new CourseEntry();\n+        courseEntry3.setId( courseId3 );\n+\n+        List<CourseEntry> courseEntryList = new ArrayList<>();\n+        courseEntryList.add(courseEntry1);\n+        courseEntryList.add(courseEntry3);\n+\n+        // find a list of courseId which is not in the dictionary\n+        List<CourseEntry> newCourses = pref.filterForNewCourses(courseEntryList);\n+\n+        assertTrue(\"filterForNewCourses\", newCourses.size() == 1 && newCourses.get(0).getId().equals(courseId3));\n+\n+        //find all the course entry in saved preference which are not in the current active\n+        courseEntryList.clear();\n+        courseEntryList.add(courseEntry2);\n+        courseEntryList.add(courseEntry3);\n+        List<EdxLocalParseChannel> inactiveCourses = pref.filterForInactiveCourses(courseEntryList);\n+\n+\n+        assertTrue(\"filterForInactiveCourses\", newCourses.size() == 1 && newCourses.get(0).getId().equals(courseId2));\n+\n+        pref.removeByChannelId(channelId3);\n+        assertTrue(\"removeByChannelId\", pref.size() == 2);\n+        pref.removeByCourseId(courseId3);\n+        assertTrue( \"removeByCourseId\", pref.size() == 2 );\n+        pref.removeByChannelId(channelId1);\n+        assertTrue( \"removeByChannelId\", pref.size() == 1 );\n+        pref.removeByCourseId(courseId2);\n+        assertTrue( \"removeByCourseId\", pref.size() ==  0 );\n+    }\n+\n+    /**\n+     * nothing interesting here.\n+     * @throws Exception\n+     */\n+    public void testNotificationManager() throws Exception {","path":"VideoLocker/src/androidTest/java/org/edx/mobile/test/NotificationTest.java","position":100,"original_position":100,"commit_id":"e82ebcd1604bd1fb8a42abf2225f5170ca7712a8","original_commit_id":"3d2692a4356e15944b2587e4f6d44124adf6e5a6","user":{"login":"hanningni","id":11091163,"avatar_url":"https://avatars.githubusercontent.com/u/11091163?v=3","gravatar_id":"","url":"https://api.github.com/users/hanningni","html_url":"https://github.com/hanningni","followers_url":"https://api.github.com/users/hanningni/followers","following_url":"https://api.github.com/users/hanningni/following{/other_user}","gists_url":"https://api.github.com/users/hanningni/gists{/gist_id}","starred_url":"https://api.github.com/users/hanningni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanningni/subscriptions","organizations_url":"https://api.github.com/users/hanningni/orgs","repos_url":"https://api.github.com/users/hanningni/repos","events_url":"https://api.github.com/users/hanningni/events{/privacy}","received_events_url":"https://api.github.com/users/hanningni/received_events","type":"User","site_admin":false},"body":"@aleffert  just make sure all the api calls for Notification Manager do not throw exception.","created_at":"2015-04-23T16:45:11Z","updated_at":"2015-04-23T16:45:11Z","html_url":"https://github.com/edx/edx-app-android/pull/218#discussion_r28980280","pull_request_url":"https://api.github.com/repos/edx/edx-app-android/pulls/218","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/comments/28980280"},"html":{"href":"https://github.com/edx/edx-app-android/pull/218#discussion_r28980280"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/218"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-app-android/pulls/218","id":33958674,"html_url":"https://github.com/edx/edx-app-android/pull/218","diff_url":"https://github.com/edx/edx-app-android/pull/218.diff","patch_url":"https://github.com/edx/edx-app-android/pull/218.patch","issue_url":"https://api.github.com/repos/edx/edx-app-android/issues/218","number":218,"state":"open","locked":false,"title":"Notification unit test","user":{"login":"hanningni","id":11091163,"avatar_url":"https://avatars.githubusercontent.com/u/11091163?v=3","gravatar_id":"","url":"https://api.github.com/users/hanningni","html_url":"https://github.com/hanningni","followers_url":"https://api.github.com/users/hanningni/followers","following_url":"https://api.github.com/users/hanningni/following{/other_user}","gists_url":"https://api.github.com/users/hanningni/gists{/gist_id}","starred_url":"https://api.github.com/users/hanningni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanningni/subscriptions","organizations_url":"https://api.github.com/users/hanningni/orgs","repos_url":"https://api.github.com/users/hanningni/repos","events_url":"https://api.github.com/users/hanningni/events{/privacy}","received_events_url":"https://api.github.com/users/hanningni/received_events","type":"User","site_admin":false},"body":"@aleffert  please review.\r\n\r\nadded some simple unit testing code. \r\n\r\nclean up some notification code","created_at":"2015-04-23T14:09:22Z","updated_at":"2015-04-23T16:45:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a1651aa0165a2ab8b924c75b92020f2fe54d00d1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-app-android/pulls/218/commits","review_comments_url":"https://api.github.com/repos/edx/edx-app-android/pulls/218/comments","review_comment_url":"https://api.github.com/repos/edx/edx-app-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-app-android/issues/218/comments","statuses_url":"https://api.github.com/repos/edx/edx-app-android/statuses/e82ebcd1604bd1fb8a42abf2225f5170ca7712a8","head":{"label":"edx:hanning/notification-uni-test","ref":"hanning/notification-uni-test","sha":"e82ebcd1604bd1fb8a42abf2225f5170ca7712a8","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":29251742,"name":"edx-app-android","full_name":"edx/edx-app-android","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-app-android","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-app-android","forks_url":"https://api.github.com/repos/edx/edx-app-android/forks","keys_url":"https://api.github.com/repos/edx/edx-app-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-app-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-app-android/teams","hooks_url":"https://api.github.com/repos/edx/edx-app-android/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-app-android/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-app-android/events","assignees_url":"https://api.github.com/repos/edx/edx-app-android/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-app-android/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-app-android/tags","blobs_url":"https://api.github.com/repos/edx/edx-app-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-app-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-app-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-app-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-app-android/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-app-android/languages","stargazers_url":"https://api.github.com/repos/edx/edx-app-android/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-app-android/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-app-android/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-app-android/subscription","commits_url":"https://api.github.com/repos/edx/edx-app-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-app-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-app-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-app-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-app-android/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-app-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-app-android/merges","archive_url":"https://api.github.com/repos/edx/edx-app-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-app-android/downloads","issues_url":"https://api.github.com/repos/edx/edx-app-android/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-app-android/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-app-android/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-app-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-app-android/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-app-android/releases{/id}","created_at":"2015-01-14T15:49:47Z","updated_at":"2015-04-22T13:38:30Z","pushed_at":"2015-04-23T14:42:50Z","git_url":"git://github.com/edx/edx-app-android.git","ssh_url":"git@github.com:edx/edx-app-android.git","clone_url":"https://github.com/edx/edx-app-android.git","svn_url":"https://github.com/edx/edx-app-android","homepage":null,"size":34567,"stargazers_count":16,"watchers_count":16,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":5,"forks":23,"open_issues":5,"watchers":16,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"7b3985853f9a981b32bd72efc89732051963d1ae","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":29251742,"name":"edx-app-android","full_name":"edx/edx-app-android","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-app-android","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-app-android","forks_url":"https://api.github.com/repos/edx/edx-app-android/forks","keys_url":"https://api.github.com/repos/edx/edx-app-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-app-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-app-android/teams","hooks_url":"https://api.github.com/repos/edx/edx-app-android/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-app-android/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-app-android/events","assignees_url":"https://api.github.com/repos/edx/edx-app-android/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-app-android/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-app-android/tags","blobs_url":"https://api.github.com/repos/edx/edx-app-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-app-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-app-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-app-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-app-android/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-app-android/languages","stargazers_url":"https://api.github.com/repos/edx/edx-app-android/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-app-android/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-app-android/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-app-android/subscription","commits_url":"https://api.github.com/repos/edx/edx-app-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-app-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-app-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-app-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-app-android/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-app-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-app-android/merges","archive_url":"https://api.github.com/repos/edx/edx-app-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-app-android/downloads","issues_url":"https://api.github.com/repos/edx/edx-app-android/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-app-android/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-app-android/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-app-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-app-android/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-app-android/releases{/id}","created_at":"2015-01-14T15:49:47Z","updated_at":"2015-04-22T13:38:30Z","pushed_at":"2015-04-23T14:42:50Z","git_url":"git://github.com/edx/edx-app-android.git","ssh_url":"git@github.com:edx/edx-app-android.git","clone_url":"https://github.com/edx/edx-app-android.git","svn_url":"https://github.com/edx/edx-app-android","homepage":null,"size":34567,"stargazers_count":16,"watchers_count":16,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":5,"forks":23,"open_issues":5,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/218"},"html":{"href":"https://github.com/edx/edx-app-android/pull/218"},"issue":{"href":"https://api.github.com/repos/edx/edx-app-android/issues/218"},"comments":{"href":"https://api.github.com/repos/edx/edx-app-android/issues/218/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/218/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/218/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-app-android/statuses/e82ebcd1604bd1fb8a42abf2225f5170ca7712a8"}}}}