1
2
3
4
5 package com.jcabi.github;
6
7 import com.jcabi.http.request.FakeRequest;
8 import org.hamcrest.MatcherAssert;
9 import org.hamcrest.Matchers;
10 import org.junit.jupiter.api.Disabled;
11 import org.junit.jupiter.api.Test;
12
13
14
15
16
17
18
19
20
21
22
23
24 @SuppressWarnings("PMD.AvoidDuplicateLiterals")
25 final class RtNotificationsTest {
26
27
28
29
30
31 @Test
32 void iterateEmpty() {
33 MatcherAssert.assertThat(
34 "Collection is not empty",
35 new RtNotifications(
36 new FakeRequest()
37 .withBody("[]")
38 ).iterate(),
39 Matchers.emptyIterable()
40 );
41 }
42
43
44
45
46 @Test
47 void iterateNotifications() {
48 MatcherAssert.assertThat(
49 "Assertion failed",
50 new RtNotifications(
51 new FakeRequest().withBody(
52
53
54 "[\n"
55 + " {\n"
56 + " \"id\": \"1\", \n"
57 + " \"repository\": {\n"
58 + " \"id\": 1296269, \n"
59 + " \"owner\": {\n"
60 + " \"login\": \"octocat\", \n"
61 + " \"id\": 1, \n"
62 + " \"avatar_url\": \"https://github.com/"
63 + "images/error/octocat_happy.gif\", \n"
64 + " \"gravatar_id\": \"\", \n"
65 + " \"url\": \"https://api.github.com/users/octocat\", \n"
66 + " \"html_url\": \"https://github.com/octocat\", \n"
67 + " \"followers_url\": "
68 + "\"https://api.github.com/users/octocat/"
69 + "followers\", \n"
70 + " \"following_url\": "
71 + "\"https://api.github.com/users/octocat/"
72 + "following{/other_user}\", \n"
73 + " \"gists_url\": "
74 + "\"https://api.github.com/users/octocat/"
75 + "gists{/gist_id}\", \n"
76 + " \"starred_url\": "
77 + "\"https://api.github.com/users/octocat/"
78 + "starred{/owner}{/repo}\", \n"
79 + " \"subscriptions_url\": "
80 + "\"https://api.github.com/users/octocat/"
81 + "subscriptions\", \n"
82 + " \"organizations_url\": "
83 + "\"https://api.github.com/users/octocat/orgs\", \n"
84 + " \"repos_url\": \"https://api.github.com/users/octocat/repos\", \n"
85 + " \"events_url\": "
86 + "\"https://api.github.com/users/octocat/"
87 + "events{/privacy}\", \n"
88 + " \"received_events_url\": "
89 + "\"https://api.github.com/users/octocat/"
90 + "received_events\", \n"
91 + " \"type\": \"User\", \n"
92 + " \"site_admin\": false\n"
93 + " }, \n"
94 + " \"name\": \"Hello-World\", \n"
95 + " \"full_name\": \"octocat/Hello-World\", \n"
96 + " \"description\": \"This your first repo!\", \n"
97 + " \"private\": false, \n"
98 + " \"fork\": false, \n"
99 + " \"url\": \"https://api.github.com/repos/octocat/Hello-World\", \n"
100 + " \"html_url\": \"https://github.com/octocat/Hello-World\"\n"
101 + " }, \n"
102 + " \"subject\": {\n"
103 + " \"title\": \"Greetings\", \n"
104 + " \"url\": "
105 + "\"https://api.github.com/repos/octokit/octokit.rb/issues/123\", \n"
106 + " \"latest_comment_url\": "
107 + "\"https://api.github.com/repos/octokit/octokit.rb/issues/comments/123\", \n"
108 + " \"type\": \"Issue\"\n"
109 + " }, \n"
110 + " \"reason\": \"subscribed\", \n"
111 + " \"unread\": true, \n"
112 + " \"updated_at\": \"2014-11-07T22:01:45Z\", \n"
113 + " \"last_read_at\": \"2014-11-07T22:01:45Z\", \n"
114 + " \"url\": \"https://api.github.com/notifications/threads/1\"\n"
115 + " }\n]"
116 )
117 ).iterate(),
118 Matchers.not(Matchers.emptyIterable())
119 );
120 }
121
122 @Test
123 @Disabled
124 void markNotificationAsRead() {
125
126 }
127 }