### Question:
ExecutorDispatcher implements InitializingBean { public Boolean dispatch(final ExecutionContext context) throws ExecuteException { ExecutorManager<Boolean> executorManager = this.executorManagers.get(context.getExecutorType()); if(executorManager == null){ throw new ExecuteException("no ExecutorManager for type : " + context.getExecutorType()); } Host host = hostManager.select(context); if (StringUtils.isEmpty(host.getAddress())) { throw new ExecuteException(String.format("fail to execute : %s due to no suitable worker , " + "current task need to %s worker group execute", context.getCommand(),context.getWorkerGroup())); } context.setHost(host); executorManager.beforeExecute(context); try { return executorManager.execute(context); } finally { executorManager.afterExecute(context); } } ExecutorDispatcher(); Boolean dispatch(final ExecutionContext context); @Override void afterPropertiesSet(); void register(ExecutorType type, ExecutorManager executorManager);  }### Answer:
@Test(expected = ExecuteException.class) public void testDispatchWithException() throws ExecuteException { ExecutionContext executionContext = ExecutionContextTestUtils.getExecutionContext(10000); executorDispatcher.dispatch(executionContext); }
@Test public void testDispatch() throws ExecuteException { int port = 30000; final NettyServerConfig serverConfig = new NettyServerConfig(); serverConfig.setListenPort(port); NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(serverConfig); nettyRemotingServer.registerProcessor(org.apache.dolphinscheduler.remote.command.CommandType.TASK_EXECUTE_REQUEST, Mockito.mock(TaskExecuteProcessor.class)); nettyRemotingServer.start(); workerConfig.setListenPort(port); workerRegistry.registry(); ExecutionContext executionContext = ExecutionContextTestUtils.getExecutionContext(port); executorDispatcher.dispatch(executionContext); workerRegistry.unRegistry(); }