1
2
3
4
5 package com.jcabi.github;
6
7 import java.io.IOException;
8 import org.hamcrest.MatcherAssert;
9 import org.hamcrest.Matchers;
10 import org.junit.jupiter.api.AfterAll;
11 import org.junit.jupiter.api.BeforeAll;
12 import org.junit.jupiter.api.Test;
13
14
15
16
17
18
19 @OAuthScope(OAuthScope.Scope.REPO)
20 final class RtLabelsITCase {
21
22
23
24 private static Repos repos;
25
26
27
28
29 private static Repo repo;
30
31
32
33
34 @BeforeAll
35 static void setUp() throws IOException {
36 final GitHub github = GitHubIT.connect();
37 RtLabelsITCase.repos = github.repos();
38 RtLabelsITCase.repo = new RepoRule().repo(RtLabelsITCase.repos);
39 }
40
41
42
43
44 @AfterAll
45 static void tearDown() throws IOException {
46 if (RtLabelsITCase.repos != null && RtLabelsITCase.repo != null) {
47 RtLabelsITCase.repos.remove(RtLabelsITCase.repo.coordinates());
48 }
49 }
50
51 @Test
52 void listsLabels() throws IOException {
53 final Labels labels = RtLabelsITCase.repo.labels();
54 final Iterable<Label.Smart> list =
55 new Smarts<>(labels.iterate());
56 for (final Label.Smart label : list) {
57 MatcherAssert.assertThat(
58 "Values are not equal",
59 label.color(),
60 Matchers.not(Matchers.is(Matchers.emptyString()))
61 );
62 }
63 }
64
65 @Test
66 void createsNewLabel() throws IOException {
67 final Labels labels = RtLabelsITCase.repo.labels();
68 final Label label = new Labels.Smart(labels).createOrGet("test-3");
69 MatcherAssert.assertThat(
70 "Value is null",
71 new Label.Smart(label).color(),
72 Matchers.notNullValue()
73 );
74 MatcherAssert.assertThat(
75 "Collection is not empty",
76 labels.iterate(),
77 Matchers.not(Matchers.emptyIterable())
78 );
79 }
80 }