-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
SharedLinkAPIConnection
uses request interceptor
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.box.sdk; | ||
|
||
import com.eclipsesource.json.JsonObject; | ||
import org.hamcrest.CoreMatchers; | ||
import org.hamcrest.MatcherAssert; | ||
import org.junit.Test; | ||
|
||
import java.util.Collections; | ||
|
||
public class BoxItemTest { | ||
@Test | ||
public void shouldUseRequestInterceptor() { | ||
String itemType = "file"; | ||
String itemId = "some_id"; | ||
BoxAPIConnection api = new BoxAPIConnection(""); | ||
api.setRequestInterceptor(request -> { | ||
if ("https://api.box.com/2.0/shared_items".equals(request.getUrl().toString())) { | ||
JsonObject body = new JsonObject(); | ||
body.add("type", itemType); | ||
body.add("id", itemId); | ||
return new BoxJSONResponse( | ||
200, | ||
request.getMethod(), | ||
request.getUrl().toString(), | ||
Collections.emptyMap(), | ||
body | ||
); | ||
} | ||
return null; | ||
}); | ||
|
||
BoxItem.Info item = BoxItem.getSharedItem(api, "some_link"); | ||
MatcherAssert.assertThat(item.getType(), CoreMatchers.is(itemType)); | ||
MatcherAssert.assertThat(item.getID(), CoreMatchers.is(itemId)); | ||
} | ||
} |