BoxSDKService { public List<BoxFile> listFiles(String folderId) throws BoxSDKServiceException { try { BoxFolder folder = new BoxFolder(getBoxAPIConnection(), folderId); List<BoxFile> files = new ArrayList<>(); for (BoxItem.Info itemInfo : folder) { if (itemInfo instanceof BoxFile.Info) { BoxFile.Info fileInfo = (BoxFile.Info) itemInfo; files.add(fileInfo.getResource()); } } return files; } catch (BoxAPIException e) { String msg = "Can't list files in folder, id: " + folderId; logger.error(msg, e); throw new BoxSDKServiceException(msg, e); } }  BoxSDKServiceConfig getBoxSDKServiceConfig(); BoxAPIConnection getBoxAPIConnection(); BoxFolder getRootFolder(); BoxFolder createSharedFolder(String folderName); BoxFolder createSharedFolder(String folderName, String parentId); BoxFolder createFolderUnderRoot(String folderName); BoxFolder createFolder(String folderName, String parentId); BoxFile uploadFile(String folderId, String filename, String filecontent); List<BoxFile> listFiles(String folderId); BoxFileWithContent getFileContent(BoxFile file); String getFileContent(String fileId); String getBoxEmbedWidgetIFrame(BoxFolder boxFolder); BoxFolder getFolderWithName(String folderName); BoxFolder getFolderWithNameAndParentFolderId(String folderName, String parentFolderId); void deleteFolderAndItsContent(String folderId); void deleteFolderContentOlderThan(String folderId, DateTime olderThan); void addCommentToFile(String fileId, String comment);  }
@Test @Category(BoxSDKTest.class) public void testListFiles() throws Exception { BoxFolder createdFolder = boxSDKService.createFolder("testListFiles-" + new Date().getTime(), testFolder.getID()); boxSDKService.uploadFile(createdFolder.getID(), "file1.txt", "content of file1.txt"); boxSDKService.uploadFile(createdFolder.getID(), "file2.txt", "content of file2.txt"); List<BoxFile> listFiles = boxSDKService.listFiles(createdFolder.getID()); assertEquals("file1.txt", listFiles.get(0).getInfo().getName()); assertEquals("file2.txt", listFiles.get(1).getInfo().getName()); boxSDKService.uploadFile(createdFolder.getID(), "file2.txt", "v2 content of file2.txt"); listFiles = boxSDKService.listFiles(createdFolder.getID()); assertEquals("file1.txt", listFiles.get(0).getInfo().getName()); assertEquals("file2.txt", listFiles.get(1).getInfo().getName()); }