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 com.jcabi.http.request.FakeRequest;
33 import org.hamcrest.MatcherAssert;
34 import org.hamcrest.Matchers;
35 import org.hamcrest.core.IsEqual;
36 import org.junit.Test;
37
38
39
40
41
42
43
44 public final class RtGithubTest {
45
46
47
48
49
50 @Test
51 public void retrievesRepos() {
52 final RtGithub github = new RtGithub(new FakeRequest());
53 MatcherAssert.assertThat(
54 github.repos(),
55 Matchers.notNullValue()
56 );
57 }
58
59
60
61
62
63 @Test
64 public void retrievesGists() {
65 final RtGithub github = new RtGithub(new FakeRequest());
66 MatcherAssert.assertThat(
67 github.gists(),
68 Matchers.notNullValue()
69 );
70 }
71
72
73
74
75
76 @Test
77 public void retrievesUsers() {
78 final RtGithub github = new RtGithub(new FakeRequest());
79 MatcherAssert.assertThat(
80 github.users(),
81 Matchers.notNullValue()
82 );
83 }
84
85
86
87
88
89
90 @Test
91 public void retrievesMetaAsJson() throws Exception {
92 final RtGithub github = new RtGithub(
93 new FakeRequest().withBody("{\"meta\":\"blah\"}")
94 );
95 MatcherAssert.assertThat(
96 github.meta().getString("meta"),
97 Matchers.equalTo("blah")
98 );
99 }
100
101
102
103
104
105
106 @Test
107 public void retrievesEmojisAsJson() throws Exception {
108 final RtGithub github = new RtGithub(
109 new FakeRequest().withBody(
110 "{ \"emojikey\": \"urlvalue\" }"
111 )
112 );
113 MatcherAssert.assertThat(
114 github.emojis().getString("emojikey"),
115 new IsEqual<>("urlvalue")
116 );
117 }
118
119
120
121
122
123 @Test
124 public void retrievesMarkdown() {
125 final RtGithub github = new RtGithub(new FakeRequest());
126 MatcherAssert.assertThat(
127 github.markdown(),
128 Matchers.notNullValue()
129 );
130 }
131
132
133
134
135 @Test
136 public void retrievesGitignores() {
137 final RtGithub github = new RtGithub(new FakeRequest());
138 MatcherAssert.assertThat(
139 github.gitignores(),
140 Matchers.notNullValue()
141 );
142 }
143
144
145
146
147 @Test
148 public void testSameTimesAreEqual() {
149 final long time = System.currentTimeMillis();
150 final Github.Time first = new Github.Time(time);
151 final Github.Time second = new Github.Time(time);
152 MatcherAssert.assertThat(
153 first.equals(second),
154 Matchers.is(true)
155 );
156 }
157
158
159
160
161 @Test
162 public void testDifferentTimesAreNotEqual() {
163 final Github.Time first = new Github.Time(System.currentTimeMillis());
164 final Github.Time second = new Github.Time(
165 System.currentTimeMillis() + 1
166 );
167 MatcherAssert.assertThat(
168 first.equals(second),
169 Matchers.is(false)
170 );
171 }
172
173
174
175
176 @Test
177 public void equalsToAnotherGithub() {
178 MatcherAssert.assertThat(
179 new RtGithub(new FakeRequest().header("abc", "cde")),
180 Matchers.not(
181 Matchers.equalTo(
182 new RtGithub(new FakeRequest().header("fgh", "ikl"))
183 )
184 )
185 );
186 MatcherAssert.assertThat(
187 new RtGithub(new FakeRequest()),
188 Matchers.equalTo(new RtGithub(new FakeRequest()))
189 );
190 }
191 }