### Question:
QsubCmdExecutor implements CmdExecutor { @Override public String executeCommand(final String originalCommand, final Map<String, String> environmentVariables, final File workDir, final String username) { log.info("Executing command '{}' using qsub", originalCommand); Path outputLog = null; Path errorLog = null; Path originalCommandScript = null; try { outputLog = createFile("qsub-output", ".log"); errorLog = createFile("qsub-error", ".log"); originalCommandScript = createFile("qsub-script", ".sh"); Files.write(originalCommandScript, Collections.singleton(originalCommand)); final String qsubCommand = String.format( qsubTemplate, outputLog.toAbsolutePath().toString(), errorLog.toAbsolutePath().toString(), originalCommandScript.toAbsolutePath().toString() ); cmdExecutor.executeCommand(qsubCommand, environmentVariables, workDir, username); return Files.lines(outputLog).collect(Collectors.joining("\n")); } catch (CmdExecutionException | IOException e) { throw new CmdExecutionException(String.format( "Qsub execution of original command '%s' went bad", originalCommand), e); } finally { Stream.of(outputLog, errorLog, originalCommandScript) .filter(Objects::nonNull) .map(Path::toFile) .forEach(File::delete); } }  @Override String executeCommand(final String originalCommand,
                                 final Map<String, String> environmentVariables,
                                 final File workDir,
                                 final String username); @Override Process launchCommand(final String originalCommand,
                                 final Map<String, String> environmentVariables,
                                 final File workDir,
                                 final String username);  }### Answer:
@Test public void executorShouldDelegateCallToInnerExecutor() { qsubCmdExecutor.executeCommand(COMMAND); verify(innerExecutor).executeCommand(any(), eq(Collections.emptyMap()), eq(null), eq(null)); }
@Test public void executorShouldCallQsubTemplateCommandInsteadOfTheOriginalOne() { qsubCmdExecutor.executeCommand(COMMAND); verify(innerExecutor).executeCommand(matches(QSUB_TEMPLATE_PATTERN), eq(Collections.emptyMap()), eq(null), eq(null)); }