@Override
    public Path mkdir(final Path folder, final TransferStatus status) throws BackgroundException {
        try {
            if(new SimplePathPredicate(DriveHomeFinderService.SHARED_DRIVES_NAME).test(folder.getParent())) {
                final TeamDrive execute = session.getClient().teamdrives().create(
                        new UUIDRandomStringService().random(), new TeamDrive().setName(folder.getName())
                ).execute();
                return folder.withAttributes(new PathAttributes(folder.attributes()).withFileId(execute.getId()));
            }
            else {
                try {
                    if(!new DriveAttributesFinderFeature(session, fileid).find(folder).isHidden()) {
                        throw new ConflictException(folder.getAbsolute());
                    }
                }
                catch(NotfoundException e) {
                    // Ignore
                }
                // Identified by the special folder MIME type application/vnd.google-apps.folder
                final Drive.Files.Create insert = session.getClient().files().create(new File()
                        .setName(folder.getName())
                        .setMimeType("application/vnd.google-apps.folder")
                        .setParents(Collections.singletonList(fileid.getFileId(folder.getParent()))));
                final File execute = insert
                        .setFields(DriveAttributesFinderFeature.DEFAULT_FIELDS)
                        .setSupportsAllDrives(new HostPreferences(session.getHost()).getBoolean("googledrive.teamdrive.enable")).execute();
                fileid.cache(folder, execute.getId());
                return folder.withAttributes(new DriveAttributesFinderFeature(session, fileid).toAttributes(execute));
            }
        }
        catch(IOException e) {
            throw new DriveExceptionMappingService(fileid).map("Cannot create folder {0}", e, folder);
        }
    }
@Test
    public void testMkdir() throws Exception {
        final DriveFileIdProvider fileid = new DriveFileIdProvider(session);
        final Path folder = new DriveDirectoryFeature(session, fileid).mkdir(
                new Path(DriveHomeFinderService.MYDRIVE_FOLDER, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final Path test = new DriveDirectoryFeature(session, fileid).mkdir(
                new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final String id = test.attributes().getFileId();
        assertNotNull(test.attributes().getFileId());
        assertTrue(new DefaultFindFeature(session).find(test));
        assertThrows(ConflictException.class, () -> new DriveDirectoryFeature(session, fileid).mkdir(test, new TransferStatus()));
        new DriveTrashFeature(session, fileid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
        assertNull(test.attributes().getFileId());
        // Trashed
        assertFalse(new DriveFindFeature(session, fileid).find(test));
        assertFalse(new DefaultFindFeature(session).find(test));
        // When searching with version "2", find trashed file
        final Path trashed = new DriveListService(session, fileid).list(folder, new DisabledListProgressListener()).find(new SimplePathPredicate(test));
        assertNotNull(trashed);
        assertEquals(id, trashed.attributes().getFileId());
        assertTrue(new DefaultFindFeature(session).find(trashed));
        assertTrue(new DriveFindFeature(session, fileid).find(trashed));
        new DriveDeleteFeature(session, fileid).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }