Skip to content

Commit 8392a43

Browse files
authored
fix: Fix File Request Copy method to return valid data (#1320)
1 parent e2d407d commit 8392a43

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/main/java/com/box/sdk/BoxFileRequest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public BoxFileRequest.Info copyInfo(String folderId) {
6363
request.setBody(body.toString());
6464
try (BoxJSONResponse response = request.send()) {
6565
JsonObject jsonObject = Json.parse(response.getJSON()).asObject();
66-
return new Info(jsonObject, this.getAPI().getBaseAppUrl());
66+
String id = jsonObject.get("id").asString();
67+
return new BoxFileRequest(this.getAPI(), id).new Info(jsonObject, this.getAPI().getBaseAppUrl());
6768
}
6869
}
6970

@@ -91,8 +92,8 @@ public BoxFileRequest.Info copyInfo(BoxFileRequest.Info info, String folderId) {
9192
request.setBody(body.toString());
9293
try (BoxJSONResponse response = request.send()) {
9394
JsonObject jsonObject = Json.parse(response.getJSON()).asObject();
94-
info.update(jsonObject);
95-
return new Info(jsonObject, this.getAPI().getBaseAppUrl());
95+
String id = jsonObject.get("id").asString();
96+
return new BoxFileRequest(this.getAPI(), id).new Info(jsonObject, this.getAPI().getBaseAppUrl());
9697
}
9798
}
9899

@@ -199,7 +200,7 @@ public Info(String json) {
199200
/**
200201
* Constructs an Info object using an already parsed JSON object.
201202
*
202-
* @param jsonObject the parsed JSON object.
203+
* @param jsonObject the parsed JSON object.
203204
* @param fileRequestBaseUrl Request base URL
204205
*/
205206
Info(JsonObject jsonObject, String fileRequestBaseUrl) {

src/test/Fixtures/BoxFileRequest/CopyFileRequest200.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "42037322",
2+
"id": "82037344",
33
"type": "file-request",
44
"created_at": "2020-09-28T10:53:43-08:00",
55
"created_by": {

src/test/java/com/box/sdk/BoxFileRequestTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
66
import static java.lang.String.format;
77
import static org.junit.Assert.assertEquals;
8+
import static org.junit.Assert.assertNotEquals;
89

910
import com.eclipsesource.json.JsonObject;
1011
import com.github.tomakehurst.wiremock.client.WireMock;
@@ -99,6 +100,7 @@ public void copyFileRequestSucceeds() {
99100
assertEquals(fileRequestInfo.getDescription(), description);
100101
assertEquals(fileRequestInfo.getIsDescriptionRequired(), true);
101102
assertEquals(fileRequestInfo.getStatus(), status);
103+
assertNotEquals(fileRequestInfo.getID(), fileRequestID);
102104
}
103105

104106
@Test

0 commit comments

Comments
 (0)