AdbFileOperations { @NotNull public ListenableFuture<Void> createNewDirectoryRunAs(@NotNull String parentPath, @NotNull String directoryName, @Nullable String runAs) { return myExecutor.executeAsync(() -> { if (directoryName.contains(AdbPathUtil.FILE_SEPARATOR)) { throw AdbShellCommandException.create("Directory name \"%s\" contains invalid characters", directoryName); } String remotePath = AdbPathUtil.resolve(parentPath, directoryName); String command = getCommand(runAs, "mkdir ").withEscapedPath(remotePath).build(); AdbShellCommandResult commandResult = AdbShellCommandsUtil.executeCommand(myDevice, command); commandResult.throwIfError(); return null; }); } AdbFileOperations(@NotNull IDevice device, @NotNull AdbDeviceCapabilities deviceCapabilities, @NotNull Executor taskExecutor); @NotNull ListenableFuture<Void> createNewFile(@NotNull String parentPath, @NotNull String fileName); @NotNull ListenableFuture<Void> createNewFileRunAs(@NotNull String parentPath, @NotNull String fileName, @Nullable String runAs); @NotNull ListenableFuture<Void> createNewDirectory(@NotNull String parentPath, @NotNull String directoryName); @NotNull ListenableFuture<Void> createNewDirectoryRunAs(@NotNull String parentPath, @NotNull String directoryName, @Nullable String runAs); ListenableFuture<List<String>> listPackages(); ListenableFuture<List<PackageInfo>> listPackageInfo(); @NotNull ListenableFuture<Void> deleteFile(@NotNull String path); @NotNull ListenableFuture<Void> deleteFileRunAs(@NotNull String path, @Nullable String runAs); @NotNull ListenableFuture<Void> deleteRecursive(@NotNull String path); @NotNull ListenableFuture<Void> deleteRecursiveRunAs(@NotNull String path, @Nullable String runAs); @NotNull ListenableFuture<Void> copyFile(@NotNull String source, @NotNull String destination); @NotNull ListenableFuture<Void> copyFileRunAs(@NotNull String source, @NotNull String destination, @Nullable String runAs); @NotNull ListenableFuture<String> createTempFile(@NotNull String tempPath); @SuppressWarnings({"SameParameterValue", "WeakerAccess"}) @NotNull ListenableFuture<String> createTempFileRunAs(@NotNull String tempDirectoy, @Nullable String runAs); @NotNull ListenableFuture<Void> touchFileAsDefaultUser(@NotNull String remotePath);  }
@Test public void testCreateNewDirectoryRunAsSuccess() throws Exception { AdbFileOperations fileOperations = setupMockDevice(); Void result = waitForFuture(fileOperations.createNewDirectoryRunAs("/data/data/com.example.rpaquay.myapplication", "foo-dir", "com.example.rpaquay.myapplication")); assertThat(result).isNull(); }