### Question:
DefaultCommandExecutor implements CommandExecutor, ApplicationContextAware, InitializingBean { @Override public <R, T> Mono<T> execute(Class<? extends Command<R, T>> commandClass, R request) { return Mono.fromCallable(() -> applicationContext.getBean(commandClass)) .doOnNext(command -> validateRequestIfNeeded(request, command)) .flatMap(command -> doExecute(command, request)); }  @Override void afterPropertiesSet(); @Override Mono<T> execute(Class<? extends Command<R, T>> commandClass, R request);  }### Answer:
@Test void testExecuteSuccess() { StepVerifier.create(commandExecutor.execute(MyCommand.class, "Eko")) .expectNext("Hello Eko") .verifyComplete(); }
@Test void testExecuteObjectSuccess() { StepVerifier.create(commandExecutor.execute(HelloCommand.class, HelloCommandRequest.builder().name("Eko").build())) .expectNext(HelloCommandResponse.builder().response("Hello Eko").build()) .verifyComplete(); }
@Test void testValidationError() { StepVerifier.create(commandExecutor.execute(HelloCommand.class, HelloCommandRequest.builder().name("").build())) .expectError(ConstraintViolationException.class) .verify(); }