### Question:
ProcessGroupCmdExecutor extends PlainAsyncCmdExecutor { @Override public ProcessGroupExecution<String> launchCommand(final String command, final Map<String, String> environmentVariables, final File workDir) { final SingleProcessExecution<String> execution = super.launchCommand(command, environmentVariables, workDir); return new ProcessGroupExecution<>(execution.process, execution.result, plainCmdExecutor); } ProcessGroupCmdExecutor(final Executor executor,
                                   final CmdExecutor modelCmdExecutor,
                                   final CmdExecutor plainCmdExecutor); @Override ProcessGroupExecution<String> launchCommand(final String command,
                                                       final Map<String, String> environmentVariables,
                                                       final File workDir);  }### Answer:
@Test public void cancelShouldTryToKillAllProcessesWithinRootProcessGroup() throws InterruptedException, IOException { final Process process = Runtime.getRuntime().exec(SLEEP_5); when(innerCmdExecutor.launchCommand(eq(COMMAND), any(), any())) .thenReturn(process); final Execution<String> execution = asyncCmdExecutor.launchCommand(COMMAND); Thread.sleep(SECOND); assertTrue(process.isAlive()); assertFalse(execution.isDone()); execution.cancel(); Thread.sleep(SECOND); verify(innerCmdExecutor).executeCommand(startsWith(DEFAULT_PROCESSES_KILL_COMMAND.replaceAll("\\%s", ""))); }