1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package com.jcabi.github;
31
32 import javax.json.Json;
33 import org.hamcrest.MatcherAssert;
34 import org.hamcrest.Matchers;
35 import org.junit.Test;
36 import org.mockito.Mockito;
37
38
39
40
41
42
43 @SuppressWarnings("PMD.TooManyMethods")
44 public final class OrganizationTest {
45
46
47
48
49
50 @Test
51 public void fetchesUrl() throws Exception {
52 final Organization orgn = Mockito.mock(Organization.class);
53 Mockito.doReturn(
54 Json.createObjectBuilder()
55 .add("url", "https://api.github.com/orgs/github")
56 .build()
57 ).when(orgn).json();
58 MatcherAssert.assertThat(
59 new Organization.Smart(orgn).url(),
60 Matchers.notNullValue()
61 );
62 }
63
64
65
66
67
68 @Test
69 public void fetchesAvatarUrl() throws Exception {
70 final Organization orgn = Mockito.mock(Organization.class);
71 Mockito.doReturn(
72 Json.createObjectBuilder()
73 .add("avatar_url", "https://github.com/images/happy.gif")
74 .build()
75 ).when(orgn).json();
76 MatcherAssert.assertThat(
77 new Organization.Smart(orgn).avatarUrl(),
78 Matchers.notNullValue()
79 );
80 }
81
82
83
84
85
86 @Test
87 public void fetchesName() throws Exception {
88 final Organization orgn = Mockito.mock(Organization.class);
89 Mockito.doReturn(
90 Json.createObjectBuilder()
91 .add("name", "github")
92 .build()
93 ).when(orgn).json();
94 MatcherAssert.assertThat(
95 new Organization.Smart(orgn).name(),
96 Matchers.notNullValue()
97 );
98 }
99
100
101
102
103
104 @Test
105 public void fetchesCompany() throws Exception {
106 final Organization orgn = Mockito.mock(Organization.class);
107 Mockito.doReturn(
108 Json.createObjectBuilder()
109 .add("company", "GitHub")
110 .build()
111 ).when(orgn).json();
112 MatcherAssert.assertThat(
113 new Organization.Smart(orgn).company(),
114 Matchers.notNullValue()
115 );
116 }
117
118
119
120
121
122 @Test
123 public void fetchesBlog() throws Exception {
124 final Organization orgn = Mockito.mock(Organization.class);
125 Mockito.doReturn(
126 Json.createObjectBuilder()
127 .add("blog", "https://github.com/blog")
128 .build()
129 ).when(orgn).json();
130 MatcherAssert.assertThat(
131 new Organization.Smart(orgn).blog(),
132 Matchers.notNullValue()
133 );
134 }
135
136
137
138
139
140 @Test
141 public void fetchesLocation() throws Exception {
142 final Organization orgn = Mockito.mock(Organization.class);
143 Mockito.doReturn(
144 Json.createObjectBuilder()
145 .add("location", "https://github.com/location")
146 .build()
147 ).when(orgn).json();
148 MatcherAssert.assertThat(
149 new Organization.Smart(orgn).location(),
150 Matchers.notNullValue()
151 );
152 }
153
154
155
156
157
158 @Test
159 public void fetchesEmail() throws Exception {
160 final Organization orgn = Mockito.mock(Organization.class);
161 Mockito.doReturn(
162 Json.createObjectBuilder()
163 .add("email", "octocat@github.com")
164 .build()
165 ).when(orgn).json();
166 MatcherAssert.assertThat(
167 new Organization.Smart(orgn).email(),
168 Matchers.notNullValue()
169 );
170 }
171
172
173
174
175
176 @Test
177 public void fetchesBillingEmail() throws Exception {
178 final Organization orgn = Mockito.mock(Organization.class);
179 Mockito.doReturn(
180 Json.createObjectBuilder()
181 .add("billing_email", "octocat_billing@github.com")
182 .build()
183 ).when(orgn).json();
184 MatcherAssert.assertThat(
185 new Organization.Smart(orgn).billingEmail(),
186 Matchers.notNullValue()
187 );
188 }
189
190
191
192
193
194 @Test
195 public void fetchesPublicRepos() throws Exception {
196 final Organization orgn = Mockito.mock(Organization.class);
197 Mockito.doReturn(
198 Json.createObjectBuilder()
199 .add("public_repos", 1)
200 .build()
201 ).when(orgn).json();
202 MatcherAssert.assertThat(
203 new Organization.Smart(orgn).publicRepos(),
204 Matchers.notNullValue()
205 );
206 }
207
208
209
210
211
212 @Test
213 public void fetchesPublicGists() throws Exception {
214 final Organization orgn = Mockito.mock(Organization.class);
215 Mockito.doReturn(
216 Json.createObjectBuilder()
217 .add("public_gists", 1)
218 .build()
219 ).when(orgn).json();
220 MatcherAssert.assertThat(
221 new Organization.Smart(orgn).publicGists(),
222 Matchers.notNullValue()
223 );
224 }
225
226
227
228
229
230 @Test
231 public void fetchesFollowers() throws Exception {
232 final Organization orgn = Mockito.mock(Organization.class);
233 Mockito.doReturn(
234 Json.createObjectBuilder()
235 .add("followers", 1)
236 .build()
237 ).when(orgn).json();
238 MatcherAssert.assertThat(
239 new Organization.Smart(orgn).followers(),
240 Matchers.notNullValue()
241 );
242 }
243
244
245
246
247
248 @Test
249 public void fetchesFollowing() throws Exception {
250 final Organization orgn = Mockito.mock(Organization.class);
251 Mockito.doReturn(
252 Json.createObjectBuilder()
253 .add("following", 1)
254 .build()
255 ).when(orgn).json();
256 MatcherAssert.assertThat(
257 new Organization.Smart(orgn).following(),
258 Matchers.notNullValue()
259 );
260 }
261
262
263
264
265
266 @Test
267 public void fetchesHtmlUrl() throws Exception {
268 final Organization orgn = Mockito.mock(Organization.class);
269 Mockito.doReturn(
270 Json.createObjectBuilder()
271 .add("html_url", "https://github.com/octocat")
272 .build()
273 ).when(orgn).json();
274 MatcherAssert.assertThat(
275 new Organization.Smart(orgn).htmlUrl(),
276 Matchers.notNullValue()
277 );
278 }
279
280
281
282
283
284 @Test
285 public void fetchesCreatedAt() throws Exception {
286 final Organization orgn = Mockito.mock(Organization.class);
287 Mockito.doReturn(
288 Json.createObjectBuilder()
289 .add("created_at", "2008-01-14T04:33:35Z")
290 .build()
291 ).when(orgn).json();
292 MatcherAssert.assertThat(
293 new Organization.Smart(orgn).createdAt(),
294 Matchers.notNullValue()
295 );
296 }
297
298
299
300
301
302 @Test
303 public void fetchesType() throws Exception {
304 final Organization orgn = Mockito.mock(Organization.class);
305 Mockito.doReturn(
306 Json.createObjectBuilder()
307 .add("type", "Organization")
308 .build()
309 ).when(orgn).json();
310 MatcherAssert.assertThat(
311 new Organization.Smart(orgn).type(),
312 Matchers.notNullValue()
313 );
314 }
315 }