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
20 @OAuthScope(OAuthScope.Scope.REPO)
21 final class RtIssueMilestoneITCase {
22
23
24
25 private static Repos repos;
26
27
28
29
30 private static Repo repo;
31
32
33
34
35 @BeforeAll
36 static void setUp() throws IOException {
37 final GitHub github = GitHubIT.connect();
38 RtIssueMilestoneITCase.repos = github.repos();
39 RtIssueMilestoneITCase.repo = new RepoRule().repo(RtIssueMilestoneITCase.repos);
40 }
41
42
43
44
45 @AfterAll
46 static void tearDown() throws IOException {
47 if (RtIssueMilestoneITCase.repos != null && RtIssueMilestoneITCase.repo != null) {
48 RtIssueMilestoneITCase.repos.remove(RtIssueMilestoneITCase.repo.coordinates());
49 }
50 }
51
52 @Test
53 void addIssueToMilestone() throws Exception {
54 final Issue issue = RtIssueMilestoneITCase.issue();
55 final Milestone milestone = RtIssueMilestoneITCase.repo
56 .milestones().create("one");
57 new Issue.Smart(issue).milestone(milestone);
58 MatcherAssert.assertThat(
59 "Value is not greater than expected",
60 new Milestone.Smart(milestone).openIssues(),
61 Matchers.greaterThan(0)
62 );
63 }
64
65 @Test
66 void checkMilestone() throws Exception {
67 final Issue.Smart issue = new Issue.Smart(
68 RtIssueMilestoneITCase.issue()
69 );
70 MatcherAssert.assertThat(
71 "Values are not equal",
72 issue.hasMilestone(),
73 Matchers.is(false)
74 );
75 final Milestone milestone = RtIssueMilestoneITCase.repo
76 .milestones().create("two");
77 issue.milestone(milestone);
78 MatcherAssert.assertThat(
79 "Values are not equal",
80 issue.hasMilestone(),
81 Matchers.is(true)
82 );
83 }
84
85 @Test
86 void readMilestone() throws Exception {
87 final String title = "three";
88 final Issue.Smart issue = new Issue.Smart(
89 RtIssueMilestoneITCase.issue()
90 );
91 issue.milestone(
92 RtIssueMilestoneITCase.repo.milestones().create(title)
93 );
94 MatcherAssert.assertThat(
95 "Values are not equal",
96 new Milestone.Smart(
97 new Issue.Smart(
98 RtIssueMilestoneITCase.repo.issues().get(issue.number())
99 ).milestone()
100 ).title(),
101 Matchers.equalTo(title)
102 );
103 }
104
105
106
107
108
109 private static Issue issue() throws IOException {
110 return RtIssueMilestoneITCase.repo.issues().create("test issue title", "test issue body");
111 }
112 }