### Question:
UNIXUtils { public static void changeOwnershipOfDirectory( final String dir, final String user, final Executor executor ) throws IOException { final CommandLine commandLine = new CommandLine(SUDO) .addArgument("chown") .addArgument("-R") .addArgument(user) .addArgument(dir); executor.execute(commandLine); } private  UNIXUtils(); static synchronized void createUser(
        final String user,
        @Nullable final String group,
        final Executor executor
    ); static void changeOwnershipOfDirectory(
        final String dir,
        final String user,
        final Executor executor
    );  }### Answer:
@Test void testChangeOwnershipOfDirectoryMethodSuccess() throws IOException { final String user = "user"; final String dir = "dir"; final ArgumentCaptor<CommandLine> argumentCaptor = ArgumentCaptor.forClass(CommandLine.class); final List<String> command = Arrays.asList("sudo", "chown", "-R", user, dir); UNIXUtils.changeOwnershipOfDirectory(dir, user, executor); Mockito.verify(this.executor).execute(argumentCaptor.capture()); Assertions.assertThat(argumentCaptor.getValue().toStrings()).containsExactlyElementsOf(command); }
@Test void testChangeOwnershipOfDirectoryMethodFailure() throws IOException { final String user = "user"; final String dir = "dir"; Mockito.when(this.executor.execute(Mockito.any(CommandLine.class))).thenThrow(new IOException()); Assertions.assertThatIOException().isThrownBy(() -> UNIXUtils.changeOwnershipOfDirectory(dir, user, executor)); }