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.aspects.Tv;
33 import com.jcabi.github.OAuthScope.Scope;
34 import javax.json.Json;
35 import org.apache.commons.codec.binary.Base64;
36 import org.apache.commons.lang3.RandomStringUtils;
37 import org.hamcrest.MatcherAssert;
38 import org.hamcrest.Matchers;
39 import org.junit.AfterClass;
40 import org.junit.BeforeClass;
41 import org.junit.Ignore;
42 import org.junit.Test;
43
44
45
46
47
48
49
50
51 @OAuthScope(Scope.REPO)
52 public final class RtRepoITCase {
53
54
55
56 private static Repos repos;
57
58
59
60
61 private static Repo repo;
62
63
64
65
66
67 @BeforeClass
68 public static void setUp() throws Exception {
69 final Github github = new GithubIT().connect();
70 repos = github.repos();
71 repo = repos.create(
72 new Repos.RepoCreate(
73 RandomStringUtils.randomAlphanumeric(Tv.TEN),
74 false
75 ).withAutoInit(true)
76 );
77 repo.contents().create(
78 Json.createObjectBuilder()
79 .add("path", "test.java")
80 .add("message", "Test file for language test")
81 .add(
82 "content", Base64.encodeBase64String(
83 "some content".getBytes()
84 )
85 )
86 .add("ref", "master")
87 .build()
88 );
89 }
90
91
92
93
94
95 @AfterClass
96 public static void tearDown() throws Exception {
97 if (repos != null && repo != null) {
98 repos.remove(repo.coordinates());
99 }
100 }
101
102
103
104
105
106 @Test
107 public void identifiesItself() throws Exception {
108 MatcherAssert.assertThat(
109 repo.coordinates(),
110 Matchers.notNullValue()
111 );
112 }
113
114
115
116
117
118 @Test
119 public void iteratesEvents() throws Exception {
120 final Issue issue = repo.issues().create("Test", "This is a bug");
121 new Issue.Smart(issue).close();
122 MatcherAssert.assertThat(
123 repo.issueEvents().iterate(),
124 Matchers.not(Matchers.emptyIterable())
125 );
126 }
127
128
129
130
131
132 @Test
133 public void exists() throws Exception {
134 MatcherAssert.assertThat(
135 new Repo.Smart(repo).exists(), Matchers.is(Boolean.TRUE)
136 );
137 }
138
139
140
141
142
143 @Test
144 public void fetchCommits() throws Exception {
145 MatcherAssert.assertThat(repo.commits(), Matchers.notNullValue());
146 }
147
148
149
150
151
152 @Test
153 public void iteratesAssignees() throws Exception {
154 MatcherAssert.assertThat(
155 repo.assignees().iterate(),
156 Matchers.not(Matchers.emptyIterable())
157 );
158 }
159
160
161
162
163
164 @Test
165 public void fetchLanguages() throws Exception {
166 MatcherAssert.assertThat(repo.languages(), Matchers.notNullValue());
167 }
168
169
170
171
172
173
174 @Test
175 @Ignore
176 public void iteratesLanguages() throws Exception {
177 MatcherAssert.assertThat(
178 repo.languages(),
179 Matchers.not(Matchers.emptyIterable())
180 );
181 }
182 }