### Question:
MoveFiles extends AsyncTask<ArrayList<String>, String, Boolean> { @Override protected Boolean doInBackground(ArrayList<String>... strings) { paths = strings[0]; if (files.size() == 0) return true; for (ArrayList<HybridFileParcelable> filesCurrent : files) { totalBytes += FileUtils.getTotalBytes(filesCurrent, context); } HybridFile destination = new HybridFile(mode, paths.get(0)); destinationSize = destination.getUsableSpace(); for (int i = 0; i < paths.size(); i++) { for (HybridFileParcelable baseFile : files.get(i)) { String destPath = paths.get(i) + "/" + baseFile.getName(context); if (!isMoveOperationValid(baseFile, new HybridFile(mode, paths.get(i)))) { Log.w( getClass().getSimpleName(), "Some files failed to be moved", new RuntimeException()); invalidOperation = true; continue; } switch (mode) { case SMB: try { SmbFile source = new SmbFile(baseFile.getPath()); SmbFile dest = new SmbFile(destPath); source.renameTo(dest); } catch (MalformedURLException e) { e.printStackTrace(); return false; } catch (SmbException e) { e.printStackTrace(); return false; } break; case FILE: File dest = new File(destPath); File source = new File(baseFile.getPath()); if (!source.renameTo(dest)) { if (mainFrag != null && mainFrag.getMainActivity().isRootExplorer()) { try { if (!RootUtils.rename(baseFile.getPath(), destPath)) return false; } catch (ShellNotRunningException e) { e.printStackTrace(); return false; } } else return false; } break; case DROPBOX: case BOX: case ONEDRIVE: case GDRIVE: DataUtils dataUtils = DataUtils.getInstance(); CloudStorage cloudStorage = dataUtils.getAccount(mode); if (baseFile.getMode() == mode) { try { cloudStorage.move( CloudUtil.stripPath(mode, baseFile.getPath()), CloudUtil.stripPath(mode, destPath)); } catch (Exception e) { return false; } } else { return false; } default: return false; } } } return true; } MoveFiles(
      ArrayList<ArrayList<HybridFileParcelable>> files,
      MainFragment ma,
      Context context,
      OpenMode mode); @Override void onPostExecute(Boolean movedCorrectly); static HashSet<OpenMode> getOperationSupportedFileSystem();  }### Answer:
@Test @Ignore("Not yet for CI testing until pass") public void testMoveFilesUsingSftp() throws Exception { File sourceFile = new File(sshServerRoot, "testfile.bin"); SecureRandom rnd = new SecureRandom(); byte[] randomBytes = new byte[32]; rnd.nextBytes(randomBytes); IOUtils.copy(new ByteArrayInputStream(randomBytes), new FileOutputStream(sourceFile)); ArrayList<HybridFileParcelable> filesToCopy = new ArrayList<>(); HybridFileParcelable file = new HybridFileParcelable( "ssh: file.generateMode(ApplicationProvider.getApplicationContext()); filesToCopy.add(file); ArrayList<ArrayList<HybridFileParcelable>> filesToCopyPerFolder = new ArrayList<>(); filesToCopyPerFolder.add(filesToCopy); MoveFiles task = new MoveFiles( filesToCopyPerFolder, null, ApplicationProvider.getApplicationContext(), OpenMode.FILE); ArrayList<String> paths = new ArrayList<>(); paths.add(Environment.getExternalStorageDirectory().getAbsolutePath()); task.doInBackground(paths); assertFalse(sourceFile.exists()); assertTrue(new File(Environment.getExternalStorageDirectory(), "testfile.bin").exists()); }