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 @Test
106 public void identifiesItself() {
107 MatcherAssert.assertThat(
108 repo.coordinates(),
109 Matchers.notNullValue()
110 );
111 }
112
113
114
115
116
117 @Test
118 public void iteratesEvents() throws Exception {
119 final Issue issue = repo.issues().create("Test", "This is a bug");
120 new Issue.Smart(issue).close();
121 MatcherAssert.assertThat(
122 repo.issueEvents().iterate(),
123 Matchers.not(Matchers.emptyIterable())
124 );
125 }
126
127
128
129
130
131 @Test
132 public void exists() throws Exception {
133 MatcherAssert.assertThat(
134 new Repo.Smart(repo).exists(), Matchers.is(Boolean.TRUE)
135 );
136 }
137
138
139
140
141 @Test
142 public void fetchCommits() {
143 MatcherAssert.assertThat(repo.commits(), Matchers.notNullValue());
144 }
145
146
147
148
149 @Test
150 public void iteratesAssignees() {
151 MatcherAssert.assertThat(
152 repo.assignees().iterate(),
153 Matchers.not(Matchers.emptyIterable())
154 );
155 }
156
157
158
159
160
161 @Test
162 public void fetchLanguages() throws Exception {
163 MatcherAssert.assertThat(repo.languages(), Matchers.notNullValue());
164 }
165
166
167
168
169
170
171 @Test
172 @Ignore
173 public void iteratesLanguages() throws Exception {
174 MatcherAssert.assertThat(
175 repo.languages(),
176 Matchers.not(Matchers.emptyIterable())
177 );
178 }
179 }