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 org.hamcrest.MatcherAssert;
33 import org.hamcrest.Matchers;
34 import org.junit.AfterClass;
35 import org.junit.BeforeClass;
36 import org.junit.Test;
37
38
39
40
41
42
43
44
45
46 @OAuthScope(OAuthScope.Scope.REPO)
47 public final class RtIssueMilestoneITCase {
48
49
50
51 private static Repos repos;
52
53
54
55
56 private static Repo repo;
57
58
59
60
61
62 @BeforeClass
63 public static void setUp() throws Exception {
64 final Github github = new GithubIT().connect();
65 repos = github.repos();
66 repo = new RepoRule().repo(RtIssueMilestoneITCase.repos);
67 }
68
69
70
71
72
73 @AfterClass
74 public static void tearDown() throws Exception {
75 if (repos != null && repo != null) {
76 repos.remove(repo.coordinates());
77 }
78 }
79
80 @Test
81 public void addIssueToMilestone() throws Exception {
82 final Issue issue = RtIssueMilestoneITCase.issue();
83 final Milestone milestone = RtIssueMilestoneITCase.repo
84 .milestones().create("one");
85 new Issue.Smart(issue).milestone(milestone);
86 MatcherAssert.assertThat(
87 new Milestone.Smart(milestone).openIssues(),
88 Matchers.greaterThan(0)
89 );
90 }
91
92 @Test
93 public void checkMilestone() throws Exception {
94 final Issue.Smart issue = new Issue.Smart(
95 RtIssueMilestoneITCase.issue()
96 );
97 MatcherAssert.assertThat(
98 issue.hasMilestone(),
99 Matchers.is(false)
100 );
101 final Milestone milestone = RtIssueMilestoneITCase.repo
102 .milestones().create("two");
103 issue.milestone(milestone);
104 MatcherAssert.assertThat(
105 issue.hasMilestone(),
106 Matchers.is(true)
107 );
108 }
109
110 @Test
111 public void readMilestone() throws Exception {
112 final String title = "three";
113 final Issue.Smart issue = new Issue.Smart(
114 RtIssueMilestoneITCase.issue()
115 );
116 issue.milestone(
117 RtIssueMilestoneITCase.repo.milestones().create(title)
118 );
119 MatcherAssert.assertThat(
120 new Milestone.Smart(
121 new Issue.Smart(
122 RtIssueMilestoneITCase.repo.issues().get(issue.number())
123 ).milestone()
124 ).title(),
125 Matchers.equalTo(title)
126 );
127 }
128
129
130
131
132
133
134 private static Issue issue() throws Exception {
135 return repo.issues().create("test issue title", "test issue body");
136 }
137 }