File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,6 +140,11 @@ void unlockAccessToken() {
140140 this .wrappedConnection .unlockAccessToken ();
141141 }
142142
143+ @ Override
144+ public RequestInterceptor getRequestInterceptor () {
145+ return this .wrappedConnection .getRequestInterceptor ();
146+ }
147+
143148 /**
144149 * Gets the shared link used for accessing shared items.
145150 *
Original file line number Diff line number Diff line change 1+ package com .box .sdk ;
2+
3+ import com .eclipsesource .json .JsonObject ;
4+ import org .hamcrest .CoreMatchers ;
5+ import org .hamcrest .MatcherAssert ;
6+ import org .junit .Test ;
7+
8+ import java .util .Collections ;
9+
10+ public class BoxItemTest {
11+ @ Test
12+ public void shouldUseRequestInterceptor () {
13+ String itemType = "file" ;
14+ String itemId = "some_id" ;
15+ BoxAPIConnection api = new BoxAPIConnection ("" );
16+ api .setRequestInterceptor (request -> {
17+ if ("https://api.box.com/2.0/shared_items" .equals (request .getUrl ().toString ())) {
18+ JsonObject body = new JsonObject ();
19+ body .add ("type" , itemType );
20+ body .add ("id" , itemId );
21+ return new BoxJSONResponse (
22+ 200 ,
23+ request .getMethod (),
24+ request .getUrl ().toString (),
25+ Collections .emptyMap (),
26+ body
27+ );
28+ }
29+ return null ;
30+ });
31+
32+ BoxItem .Info item = BoxItem .getSharedItem (api , "some_link" );
33+ MatcherAssert .assertThat (item .getType (), CoreMatchers .is (itemType ));
34+ MatcherAssert .assertThat (item .getID (), CoreMatchers .is (itemId ));
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments