@@ -54,6 +54,11 @@ class GitHubTemplateTests {
54
54
private final MockRestServiceServer server = MockRestServiceServer
55
55
.createServer ((RestTemplate ) this .gitHub .getRestOperations ());
56
56
57
+ @ Test
58
+ void notSureYet () {
59
+ new GitHubTemplate (null , null , new RegexLinkParser ()).getIssues ("spring-projects" , "spring-boot" ).next ();
60
+ }
61
+
57
62
@ Test
58
63
void noIssues () {
59
64
this .server .expect (requestTo ("https://api.github.com/repos/org/repo/issues" ))
@@ -78,12 +83,10 @@ void singlePageOfIssues() {
78
83
79
84
@ Test
80
85
void multiplePagesOfIssues () {
81
- HttpHeaders headers = new HttpHeaders ();
82
- headers .set ("Link" , "<page-two>; rel=\" next\" " );
83
86
this .server .expect (requestTo ("https://api.github.com/repos/org/repo/issues" ))
84
87
.andExpect (method (HttpMethod .GET ))
85
88
.andExpect (basicAuth ())
86
- .andRespond (withResource ("issues-page-one.json" , "Link:<page-two>; rel=\" next\" " ));
89
+ .andRespond (withResource ("issues-page-one.json" , "Link:</ page-two>; rel=\" next\" " ));
87
90
this .server .expect (requestTo ("/page-two" ))
88
91
.andExpect (method (HttpMethod .GET ))
89
92
.andExpect (basicAuth ())
@@ -95,6 +98,23 @@ void multiplePagesOfIssues() {
95
98
assertThat (pageTwo .getContent ()).hasSize (15 );
96
99
}
97
100
101
+ @ Test
102
+ void multiplePagesOfIssuesWithPercentEncodedLink () {
103
+ this .server .expect (requestTo ("https://api.github.com/repos/org/repo/issues" ))
104
+ .andExpect (method (HttpMethod .GET ))
105
+ .andExpect (basicAuth ())
106
+ .andRespond (withResource ("issues-page-one.json" , "Link:</page-two%3D%3D>; rel=\" next\" " ));
107
+ this .server .expect (requestTo ("/page-two%3D%3D" ))
108
+ .andExpect (method (HttpMethod .GET ))
109
+ .andExpect (basicAuth ())
110
+ .andRespond (withResource ("issues-page-two.json" ));
111
+ Page <Issue > pageOne = this .gitHub .getIssues ("org" , "repo" );
112
+ assertThat (pageOne .getContent ()).hasSize (15 );
113
+ Page <Issue > pageTwo = pageOne .next ();
114
+ assertThat (pageTwo ).isNotNull ();
115
+ assertThat (pageTwo .getContent ()).hasSize (15 );
116
+ }
117
+
98
118
@ Test
99
119
void rateLimited () {
100
120
long reset = System .currentTimeMillis ();
@@ -117,7 +137,7 @@ void noComments() {
117
137
.andExpect (basicAuth ())
118
138
.andRespond (withSuccess ("[]" , MediaType .APPLICATION_JSON ));
119
139
Page <Comment > comments = this .gitHub
120
- .getComments (new Issue (null , "commentsUrl" , null , null , null , null , null , null ));
140
+ .getComments (new Issue (null , "/ commentsUrl" , null , null , null , null , null , null ));
121
141
assertThat (comments .getContent ()).isEmpty ();
122
142
assertThat (comments .next ()).isNull ();
123
143
}
@@ -129,7 +149,7 @@ void singlePageOfComments() {
129
149
.andExpect (basicAuth ())
130
150
.andRespond (withResource ("comments-page-one.json" ));
131
151
Page <Comment > comments = this .gitHub
132
- .getComments (new Issue (null , "commentsUrl" , null , null , null , null , null , null ));
152
+ .getComments (new Issue (null , "/ commentsUrl" , null , null , null , null , null , null ));
133
153
assertThat (comments .getContent ()).hasSize (17 );
134
154
assertThat (comments .next ()).isNull ();
135
155
}
@@ -141,13 +161,13 @@ void multiplePagesOfComments() {
141
161
this .server .expect (requestTo ("/commentsUrl" ))
142
162
.andExpect (method (HttpMethod .GET ))
143
163
.andExpect (basicAuth ())
144
- .andRespond (withResource ("comments-page-one.json" , "Link:<page-two>; rel=\" next\" " ));
164
+ .andRespond (withResource ("comments-page-one.json" , "Link:</ page-two>; rel=\" next\" " ));
145
165
this .server .expect (requestTo ("/page-two" ))
146
166
.andExpect (method (HttpMethod .GET ))
147
167
.andExpect (basicAuth ())
148
168
.andRespond (withResource ("comments-page-two.json" ));
149
169
Page <Comment > pageOne = this .gitHub
150
- .getComments (new Issue (null , "commentsUrl" , null , null , null , null , null , null ));
170
+ .getComments (new Issue (null , "/ commentsUrl" , null , null , null , null , null , null ));
151
171
assertThat (pageOne .getContent ()).hasSize (17 );
152
172
Page <Comment > pageTwo = pageOne .next ();
153
173
assertThat (pageTwo ).isNotNull ();
@@ -206,24 +226,22 @@ void singlePageOfEvents() {
206
226
.andExpect (method (HttpMethod .GET ))
207
227
.andExpect (basicAuth ())
208
228
.andRespond (withResource ("events-page-one.json" ));
209
- Page <Event > events = this .gitHub .getEvents (new Issue (null , null , "eventsUrl" , null , null , null , null , null ));
229
+ Page <Event > events = this .gitHub .getEvents (new Issue (null , null , "/ eventsUrl" , null , null , null , null , null ));
210
230
assertThat (events .getContent ()).hasSize (12 );
211
231
assertThat (events .next ()).isNull ();
212
232
}
213
233
214
234
@ Test
215
235
void multiplePagesOfEvents () {
216
- HttpHeaders headers = new HttpHeaders ();
217
- headers .set ("Link" , "<page-two>; rel=\" next\" " );
218
236
this .server .expect (requestTo ("/eventsUrl" ))
219
237
.andExpect (method (HttpMethod .GET ))
220
238
.andExpect (basicAuth ())
221
- .andRespond (withResource ("events-page-one.json" , "Link:<page-two>; rel=\" next\" " ));
239
+ .andRespond (withResource ("events-page-one.json" , "Link:</ page-two>; rel=\" next\" " ));
222
240
this .server .expect (requestTo ("/page-two" ))
223
241
.andExpect (method (HttpMethod .GET ))
224
242
.andExpect (basicAuth ())
225
243
.andRespond (withResource ("events-page-two.json" ));
226
- Page <Event > pageOne = this .gitHub .getEvents (new Issue (null , null , "eventsUrl" , null , null , null , null , null ));
244
+ Page <Event > pageOne = this .gitHub .getEvents (new Issue (null , null , "/ eventsUrl" , null , null , null , null , null ));
227
245
assertThat (pageOne .getContent ()).hasSize (12 );
228
246
Page <Event > pageTwo = pageOne .next ();
229
247
assertThat (pageTwo ).isNotNull ();
0 commit comments