### Question:
MultiLangDaemon { int submitRunnerAndWait(final MultiLangDaemonConfig config, final MultiLangRunner runner) { ExecutorService executorService = config.getExecutorService(); Future<Integer> future = executorService.submit(runner); try { return future.get(); } catch (InterruptedException | ExecutionException e) { log.error("Encountered an error while running daemon", e); } return 1; }  static void main(final String[] args);  }### Answer:
@Test public void testSuccessfulSubmitRunnerAndWait() throws Exception { int expectedExitCode = 0; MultiLangDaemon.MultiLangRunner runner = new MultiLangDaemon.MultiLangRunner(scheduler); when(config.getExecutorService()).thenReturn(executorService); when(executorService.submit(eq(runner))).thenReturn(futureInteger); when(futureInteger.get()).thenReturn(expectedExitCode); int exitCode = daemon.submitRunnerAndWait(config, runner); assertThat(exitCode, equalTo(expectedExitCode)); }
@Test public void testErrorSubmitRunnerAndWait() throws Exception { int expectedExitCode = 1; MultiLangDaemon.MultiLangRunner runner = new MultiLangDaemon.MultiLangRunner(scheduler); when(config.getExecutorService()).thenReturn(executorService); when(executorService.submit(eq(runner))).thenReturn(futureInteger); when(futureInteger.get()).thenThrow(ExecutionException.class); int exitCode = daemon.submitRunnerAndWait(config, runner); assertThat(exitCode, equalTo(expectedExitCode)); }