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 com.jcabi.http.wire.RetryWire;
35 import com.jcabi.immutable.ArrayMap;
36 import java.util.Collections;
37 import org.apache.commons.lang3.RandomStringUtils;
38 import org.hamcrest.MatcherAssert;
39 import org.hamcrest.Matchers;
40 import org.junit.AfterClass;
41 import org.junit.BeforeClass;
42 import org.junit.Test;
43
44
45
46
47
48
49
50 @OAuthScope(Scope.REPO)
51 public final class RtMilestonesITCase {
52
53
54
55 private static Repos repos;
56
57
58
59
60 private static Repo repo;
61
62
63
64
65
66 @BeforeClass
67 public static void setUp() throws Exception {
68 final Github github = new RtGithub(
69 new GithubIT().connect().entry().through(RetryWire.class)
70 );
71 repos = github.repos();
72 repo = new RepoRule().repo(repos);
73 }
74
75
76
77
78
79 @AfterClass
80 public static void tearDown() throws Exception {
81 if (repos != null && repo != null) {
82 repos.remove(repo.coordinates());
83 }
84 }
85
86
87
88
89
90 @Test
91 public void iteratesIssues() throws Exception {
92 final Milestones milestones = repo.milestones();
93 final Milestone milestone = milestones.create(
94 RandomStringUtils.randomAlphabetic(Tv.TEN)
95 );
96 try {
97 MatcherAssert.assertThat(
98 milestones.iterate(Collections.singletonMap("state", "all")),
99 Matchers.hasItem(milestone)
100 );
101 } finally {
102 milestones.remove(milestone.number());
103 }
104 }
105
106
107
108
109
110 @Test
111 public void createsNewMilestone() throws Exception {
112 final Milestones milestones = repo.milestones();
113 final Milestone milestone = milestones.create(
114 RandomStringUtils.randomAlphabetic(Tv.TEN)
115 );
116 try {
117 MatcherAssert.assertThat(
118 milestones.iterate(Collections.singletonMap("state", "all")),
119 Matchers.not(Matchers.emptyIterable())
120 );
121 } finally {
122 milestones.remove(milestone.number());
123 }
124 }
125
126
127
128
129
130 @Test
131 public void deleteMilestone() throws Exception {
132 final Milestones milestones = repo.milestones();
133 final Milestone milestone = milestones.create("a milestones");
134 MatcherAssert.assertThat(
135 milestones.iterate(new ArrayMap<>()),
136 Matchers.hasItem(milestone)
137 );
138 milestones.remove(milestone.number());
139 MatcherAssert.assertThat(
140 milestones.iterate(new ArrayMap<>()),
141 Matchers.not(Matchers.hasItem(milestone))
142 );
143 }
144 }
145