OneDriveAPI { public DriveItem createFolder(String parentId, String name, Calendar created) { if (parentId == null || parentId.isEmpty()) { parentId = getRootId(); } DriveItem folder = new DriveItem(); folder.name = name; folder.parentReference = new ItemReference(); folder.fileSystemInfo = new FileSystemInfo(); folder.fileSystemInfo.createdDateTime = created; folder.parentReference.id = parentId; folder.folder = new Folder(); return createFolderRequestWrapper(parentId, folder); } OneDriveAPI(String clientId, String clientSecret, String authCode, String redirectUrl);   OneDriveAPI(String clientId,
              String clientSecret,
              String accessToken,
              String refreshToken,
              long expirationTime,
              String redirectUrl); SharingLink createLink(String itemId, String type); void updateToken(OneDriveStoredToken newToken); void removeFolder(String fileId); void removeFile(String fileId); User getUser(); synchronized String getRootId(); synchronized String getUserId(); DriveItem createFolder(String parentId, String name, Calendar created); DriveItem copyFile(String parentId, String fileName, String fileId); DriveItem copyFolder(String parentId, String name, String folderId); OneDriveStoredToken getStoredToken(); @Deprecated String getNotificationUrl(); Subscription getSubscription(); DriveItem copy(String parentId, String fileName, String fileId, boolean isFile); IDriveItemCollectionPage getDriveItemCollectionPage(String folderId); @Deprecated List<DriveItem> getFiles(String folderId); ChangesIterator changes(String deltaToken); String getInsertUploadUrl(String parentId, String name, String conflictBehavior); DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior); DriveItem updateFileContent(String itemId, Calendar created, Calendar modified, InputStream inputStream); DeltaDriveFiles getAllFiles(); DriveItem updateFile(DriveItem driveItem); DriveItem getItem(String itemId); Drive getDrive(); String getBusinessPreviewLink(String itemId); SimpleChildIterator getSimpleChildIterator(Collection<HashSetCompatibleDriveItem> items); ChildIterator getChildIterator(String folderId); final static String SCOPES; }
@Test public void createFolderShouldReturnAprrortiateItem() { String rootId = graphClient.me().drive().root().buildRequest().get().id; String fileName = "f1.test"; Calendar created = Calendar.getInstance(); DriveItem item = oneDriveAPI.createFolder(rootId, fileName, created); assertEquals(rootId, item.parentReference.id); assertEquals(fileName, item.name); assertNotNull(item.folder); }
@Test public void createFolder() { String rootId = graphClient.me().drive().root().buildRequest().get().id; DriveItem expectedItem = oneDriveAPI.createFolder(rootId, "createdFile.test", Calendar.getInstance()); List<DriveItem> items = graphClient.me().drive().root().children().buildRequest().get().getCurrentPage(); DriveItem actualItem = items.get(0); assertEquals(1, items.size()); assertNotNull(actualItem.folder); assertEquals(expectedItem.id, actualItem.id); assertEquals(expectedItem.size, actualItem.size); assertEquals(expectedItem.name, actualItem.name); assertEquals(expectedItem.parentReference.id, actualItem.parentReference.id); assertEquals(expectedItem.id, actualItem.id); assertEquals(expectedItem.fileSystemInfo.createdDateTime.getTimeInMillis(), actualItem.fileSystemInfo.createdDateTime.getTimeInMillis()); assertEquals(expectedItem.fileSystemInfo.lastModifiedDateTime.getTimeInMillis(), actualItem.fileSystemInfo.lastModifiedDateTime.getTimeInMillis()); }