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 RtIssueLabelsITCase {
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 RtIssueLabelsITCase.repos = github.repos();
38 RtIssueLabelsITCase.repo = new RepoRule().repo(RtIssueLabelsITCase.repos);
39 }
40
41
42
43
44 @AfterAll
45 static void tearDown() throws IOException {
46 if (RtIssueLabelsITCase.repos != null && RtIssueLabelsITCase.repo != null) {
47 RtIssueLabelsITCase.repos.remove(RtIssueLabelsITCase.repo.coordinates());
48 }
49 }
50
51
52
53
54
55 @Test
56 void listsLabels() throws Exception {
57 final IssueLabels.Smart labels = new IssueLabels.Smart(
58 RtIssueLabelsITCase.issue().labels()
59 );
60 final String name = "test-label";
61 final String color = "cfcfcf";
62 labels.addIfAbsent(name, color);
63 MatcherAssert.assertThat(
64 "Values are not equal",
65 new Label.Smart(labels.get(name)).color(),
66 Matchers.equalTo(color)
67 );
68 labels.remove(name);
69 }
70
71
72
73
74
75 private static Issue issue() throws IOException {
76 return RtIssueLabelsITCase.repo.issues().create("test issue title", "test issue body");
77 }
78
79 }