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.mock;
31
32 import com.google.common.collect.Lists;
33 import com.jcabi.aspects.Tv;
34 import com.jcabi.github.Coordinates;
35 import com.jcabi.github.Language;
36 import com.jcabi.github.Milestones;
37 import com.jcabi.github.Repo;
38 import com.jcabi.github.Repos;
39 import java.io.IOException;
40 import org.hamcrest.MatcherAssert;
41 import org.hamcrest.Matchers;
42 import org.junit.Test;
43
44
45
46
47
48
49
50 public final class MkRepoTest {
51
52
53
54
55
56 @Test
57 public void works() throws Exception {
58 final Repos repos = new MkRepos(new MkStorage.InFile(), "jeff");
59 final Repo repo = repos.create(
60 new Repos.RepoCreate("test5", false)
61 );
62 MatcherAssert.assertThat(
63 repo.coordinates(),
64 Matchers.hasToString("jeff/test5")
65 );
66 }
67
68
69
70
71
72 @Test
73 public void returnsMkMilestones() throws Exception {
74 final Repos repos = new MkRepos(new MkStorage.InFile(), "jeff");
75 final Repo repo = repos.create(
76 new Repos.RepoCreate("test1", false)
77 );
78 final Milestones milestones = repo.milestones();
79 MatcherAssert.assertThat(milestones, Matchers.notNullValue());
80 }
81
82
83
84
85
86
87 @Test
88 public void fetchCommits() throws IOException {
89 final String user = "testuser";
90 final Repo repo = new MkRepo(
91 new MkStorage.InFile(),
92 user,
93 new Coordinates.Simple(user, "testrepo")
94 );
95 MatcherAssert.assertThat(repo.commits(), Matchers.notNullValue());
96 }
97
98
99
100
101
102
103 @Test
104 public void fetchBranches() throws IOException {
105 final String user = "testuser";
106 final Repo repo = new MkRepo(
107 new MkStorage.InFile(),
108 user,
109 new Coordinates.Simple(user, "testrepo")
110 );
111 MatcherAssert.assertThat(repo.branches(), Matchers.notNullValue());
112 }
113
114
115
116
117
118 @Test
119 public void exposesAttributes() throws Exception {
120 final Repo repo = new MkGithub().randomRepo();
121 MatcherAssert.assertThat(
122 new Repo.Smart(repo).description(),
123 Matchers.notNullValue()
124 );
125 MatcherAssert.assertThat(
126 new Repo.Smart(repo).isPrivate(),
127 Matchers.is(true)
128 );
129 }
130
131
132
133
134
135 @Test
136 public void fetchStars() throws IOException {
137 final String user = "testuser2";
138 final Repo repo = new MkRepo(
139 new MkStorage.InFile(),
140 user,
141 new Coordinates.Simple(user, "testrepo2")
142 );
143 MatcherAssert.assertThat(repo.stars(), Matchers.notNullValue());
144 }
145
146
147
148
149
150 @Test
151 public void fetchNotifications() throws IOException {
152 final String user = "testuser3";
153 final Repo repo = new MkRepo(
154 new MkStorage.InFile(),
155 user,
156 new Coordinates.Simple(user, "testrepo3")
157 );
158 MatcherAssert.assertThat(repo.notifications(), Matchers.notNullValue());
159 }
160
161
162
163
164
165 @Test
166 public void fetchLanguages() throws IOException {
167 final String user = "testuser4";
168 final Repo repo = new MkRepo(
169 new MkStorage.InFile(),
170 user,
171 new Coordinates.Simple(user, "testrepo4")
172 );
173 final Iterable<Language> languages = repo.languages();
174 MatcherAssert.assertThat(languages, Matchers.notNullValue());
175 MatcherAssert.assertThat(
176 Lists.newArrayList(languages),
177 Matchers.hasSize(Tv.THREE)
178 );
179 }
180
181
182
183
184
185 @Test
186 public void retrievesDefaultBranch() throws IOException {
187 final String user = "testuser5";
188 final Repo repo = new MkRepo(
189 new MkStorage.InFile(),
190 user,
191 new Coordinates.Simple(user, "testrepo5")
192 );
193 MatcherAssert.assertThat(
194 repo.defaultBranch().name(),
195 Matchers.equalTo("master")
196 );
197 }
198 }