Skip to content

Commit 15fcbb3

Browse files
committed
Merge pull request #113 from gcurtis/fix-path-collections
Parse path collections as BoxFolder.Info
2 parents 46b1291 + e102d46 commit 15fcbb3

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public abstract class Info extends BoxResource.Info {
131131
private Date modifiedAt;
132132
private String description;
133133
private long size;
134-
private List<BoxFolder> pathCollection;
134+
private List<BoxFolder.Info> pathCollection;
135135
private BoxUser.Info createdBy;
136136
private BoxUser.Info modifiedBy;
137137
private Date trashedAt;
@@ -237,7 +237,7 @@ public long getSize() {
237237
* Gets the path of folders to the item, starting at the root.
238238
* @return the path of folders to the item.
239239
*/
240-
public List<BoxFolder> getPathCollection() {
240+
public List<BoxFolder.Info> getPathCollection() {
241241
return this.pathCollection;
242242
}
243243

@@ -417,14 +417,15 @@ protected void parseJSONMember(JsonObject.Member member) {
417417
}
418418
}
419419

420-
private List<BoxFolder> parsePathCollection(JsonObject jsonObject) {
420+
private List<BoxFolder.Info> parsePathCollection(JsonObject jsonObject) {
421421
int count = jsonObject.get("total_count").asInt();
422-
List<BoxFolder> pathCollection = new ArrayList<BoxFolder>(count);
422+
List<BoxFolder.Info> pathCollection = new ArrayList<BoxFolder.Info>(count);
423423
JsonArray entries = jsonObject.get("entries").asArray();
424424
for (JsonValue value : entries) {
425425
JsonObject entry = value.asObject();
426426
String id = entry.get("id").asString();
427-
pathCollection.add(new BoxFolder(getAPI(), id));
427+
BoxFolder folder = new BoxFolder(getAPI(), id);
428+
pathCollection.add(folder.new Info(entry));
428429
}
429430

430431
return pathCollection;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ public void getFolderInfoReturnsCorrectInfo() {
147147
String actualCreatedByID = info.getCreatedBy().getID();
148148
String actualParentFolderID = info.getParent().getID();
149149
String actualParentFolderName = info.getParent().getName();
150-
List<BoxFolder> actualPathCollection = info.getPathCollection();
150+
List<BoxFolder.Info> actualPathCollection = info.getPathCollection();
151151

152152
assertThat(expectedName, equalTo(actualName));
153153
assertThat(expectedCreatedByID, equalTo(actualCreatedByID));
154154
assertThat(expectedParentFolderID, equalTo(actualParentFolderID));
155155
assertThat(expectedParentFolderName, equalTo(actualParentFolderName));
156-
assertThat(actualPathCollection, hasItem(rootFolder));
156+
assertThat(actualPathCollection, hasItem(Matchers.<BoxFolder.Info>hasProperty("ID", equalTo("0"))));
157157
assertThat(info.getPermissions(), is(equalTo(EnumSet.allOf(BoxFolder.Permission.class))));
158158
assertThat(info.getItemStatus(), is(equalTo("active")));
159159

0 commit comments

Comments
 (0)