@@ -287,6 +287,27 @@ public void interceptorCanModifyRequest() {
287287 verify (1 , getRequestedFor (urlEqualTo ("/" )));
288288 }
289289
290+ @ Test
291+ public void interceptorCanModifyRequestURL () {
292+ String initialPath = "/" ;
293+ String modifiedPath = "/2" ;
294+
295+ stubFor (get (urlEqualTo (initialPath ))
296+ .willReturn (aResponse ().withStatus (404 )));
297+ stubFor (get (urlEqualTo (modifiedPath ))
298+ .willReturn (aResponse ().withStatus (200 ).withBody ("{\" foo\" :\" bar\" }" )));
299+
300+ BoxAPIConnection api = createConnectionWith (boxMockUrl ().toString ());
301+ api .setRequestInterceptor (request -> {
302+ request .setUrl (boxMockUrl (modifiedPath ));
303+ return null ;
304+ });
305+
306+ new BoxAPIRequest (api , boxMockUrl (), "GET" ).send ();
307+ verify (1 , getRequestedFor (urlEqualTo (modifiedPath )));
308+ verify (0 , getRequestedFor (urlEqualTo (initialPath )));
309+ }
310+
290311 @ Test
291312 public void addsAuthenticationHeaderByDefault () {
292313 stubFor (get (urlEqualTo ("/" ))
@@ -334,4 +355,12 @@ private URL boxMockUrl() {
334355 throw new RuntimeException (e );
335356 }
336357 }
358+
359+ private URL boxMockUrl (String path ) {
360+ try {
361+ return new URL (format ("https://localhost:%d%s" , wireMockRule .httpsPort (), path ));
362+ } catch (MalformedURLException e ) {
363+ throw new RuntimeException (e );
364+ }
365+ }
337366}
0 commit comments