Controller extends Bean<MODEL> { protected <RESULT> Task.Monitor<RESULT> runTask(final Task<RESULT> task) { return runTask(executorService, task, null); }  void onCreated(); @Override void onDestroy(); @Override MODEL getModel();  }
@Test public void should_post_wrapped_MvcGraphException_when_run_async_task() { Controller controller = new Controller() { @Override public Class modelType() { return null; } }; graph.inject(controller); boolean exceptionCaught = false; final MvcGraphException exp = new MvcGraphException(""); try { controller.runTask(new Task() { @Override public Object execute(Monitor monitor) throws Exception { throw exp; } }); } catch (Exception e) { exceptionCaught = true; Assert.assertTrue(e.getCause() == exp); } Assert.assertTrue(exceptionCaught); }
@Test public void should_post_wrapped_other_exception_when_run_async_task_without_callback() { Controller controller = new Controller() { @Override public Class modelType() { return null; } }; graph.inject(controller); boolean exceptionCaught = false; final Exception exp = new Exception(""); try { controller.runTask(new Task() { @Override public Object execute(Monitor monitor) throws Exception { throw exp; } }); } catch (Exception e) { exceptionCaught = true; Assert.assertTrue(e.getCause() == exp); } Assert.assertTrue(exceptionCaught); }