-
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 collaboration notify parameter (#545)
Fixed a bug where the `notify` parameter when creating a collab was placed in a header instead of the query string. Also did some opportunistic refactoring to consolidate collab creation API call logic in one place in the BoxCollaboration class to avoid duplicate code. Fixes #544
- Loading branch information
Matt Willer
authored
Feb 1, 2018
1 parent
f34ad26
commit ebcef04
Showing
5 changed files
with
118 additions
and
68 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
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 |
---|---|---|
|
@@ -1107,6 +1107,42 @@ public void setCollectionsWithInfoSucceeds() { | |
uploadedFile.delete(); | ||
} | ||
|
||
@Test | ||
@Category(UnitTest.class) | ||
public void collaborateWithOptionalParamsSendsCorrectRequest() { | ||
|
||
final String fileID = "983745"; | ||
final String collaboratorLogin = "[email protected]"; | ||
final BoxCollaboration.Role collaboratorRole = BoxCollaboration.Role.VIEWER; | ||
|
||
BoxAPIConnection api = new BoxAPIConnection(""); | ||
api.setRequestInterceptor(new JSONRequestInterceptor() { | ||
@Override | ||
public BoxJSONResponse onJSONRequest(BoxJSONRequest request, JsonObject body) { | ||
Assert.assertEquals( | ||
"https://api.box.com/2.0/collaborations?notify=true", | ||
request.getUrl().toString()); | ||
Assert.assertEquals("POST", request.getMethod()); | ||
|
||
Assert.assertEquals(fileID, body.get("item").asObject().get("id").asString()); | ||
Assert.assertEquals("file", body.get("item").asObject().get("type").asString()); | ||
Assert.assertEquals(collaboratorLogin, body.get("accessible_by").asObject().get("login").asString()); | ||
Assert.assertEquals("user", body.get("accessible_by").asObject().get("type").asString()); | ||
Assert.assertEquals(collaboratorRole.toJSONString(), body.get("role").asString()); | ||
|
||
return new BoxJSONResponse() { | ||
@Override | ||
public String getJSON() { | ||
return "{\"type\":\"collaboration\",\"id\":\"98763245\"}"; | ||
} | ||
}; | ||
} | ||
}); | ||
|
||
BoxFile file = new BoxFile(api, fileID); | ||
BoxCollaboration.Info collabInfo = file.collaborate(collaboratorLogin, collaboratorRole, true, true); | ||
} | ||
|
||
@Test | ||
@Category(IntegrationTest.class) | ||
public void uploadSessionCommitFlowSuccess() throws Exception { | ||
|
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 |
---|---|---|
|
@@ -934,6 +934,42 @@ public void addCollaborationsWithAttributesSucceeds() { | |
folder.delete(false); | ||
} | ||
|
||
@Test | ||
@Category(UnitTest.class) | ||
public void collaborateWithOptionalParamsSendsCorrectRequest() { | ||
|
||
final String folderID = "983745"; | ||
final String collaboratorLogin = "[email protected]"; | ||
final BoxCollaboration.Role collaboratorRole = BoxCollaboration.Role.VIEWER; | ||
|
||
BoxAPIConnection api = new BoxAPIConnection(""); | ||
api.setRequestInterceptor(new JSONRequestInterceptor() { | ||
@Override | ||
public BoxJSONResponse onJSONRequest(BoxJSONRequest request, JsonObject body) { | ||
Assert.assertEquals( | ||
"https://api.box.com/2.0/collaborations?notify=true", | ||
request.getUrl().toString()); | ||
Assert.assertEquals("POST", request.getMethod()); | ||
|
||
Assert.assertEquals(folderID, body.get("item").asObject().get("id").asString()); | ||
Assert.assertEquals("folder", body.get("item").asObject().get("type").asString()); | ||
Assert.assertEquals(collaboratorLogin, body.get("accessible_by").asObject().get("login").asString()); | ||
Assert.assertEquals("user", body.get("accessible_by").asObject().get("type").asString()); | ||
Assert.assertEquals(collaboratorRole.toJSONString(), body.get("role").asString()); | ||
|
||
return new BoxJSONResponse() { | ||
@Override | ||
public String getJSON() { | ||
return "{\"type\":\"collaboration\",\"id\":\"98763245\"}"; | ||
} | ||
}; | ||
} | ||
}); | ||
|
||
BoxFolder folder = new BoxFolder(api, folderID); | ||
BoxCollaboration.Info collabInfo = folder.collaborate(collaboratorLogin, collaboratorRole, true, true); | ||
} | ||
|
||
@Test | ||
@Category(IntegrationTest.class) | ||
public void getCollaborationsHasCorrectCollaborations() { | ||
|