### Question:
HandlerRegistry { public <T> HandlerRegistry handleCommand(String commandName, CommandHandler<T> fn, Class<T> commandClass){ commandHandlers.add(new RegisteredCommandHandler<>(commandName, fn, commandClass)); return this; }  static HandlerRegistry register(); HandlerRegistry listenEvent(String eventName, EventHandler<T> fn, Class<T> eventClass); HandlerRegistry listenEvent(String eventName, EventHandler<T> handler); HandlerRegistry listenNotificationEvent(String eventName, EventHandler<T> fn, Class<T> eventClass); HandlerRegistry handleCommand(String commandName, CommandHandler<T> fn, Class<T> commandClass); HandlerRegistry handleCommand(String commandName, CommandHandler<T> fn); HandlerRegistry serveQuery(String resource, QueryHandler<T, R> handler); HandlerRegistry serveQuery(String resource, QueryHandler<T, R> handler, Class<R> queryClass);  }### Answer:
@Test public void handleCommandWithTypeInference() { SomeCommandHandler handler = new SomeCommandHandler(); registry.handleCommand(name, handler); assertThat(registry.getCommandHandlers()).anySatisfy(registered -> { assertThat(registered).extracting(RegisteredCommandHandler::getPath, RegisteredCommandHandler::getInputClass, RegisteredCommandHandler::getHandler) .containsExactly(name, SomeDataClass.class, handler); }).hasSize(1); }
@Test(expected = RuntimeException.class) public void handleCommandWithoutTypeShouldFail() { registry.handleCommand(name, (Command<SomeDataClass> message) -> Mono.empty()); }
@Test public void handleCommandWithLambda() { registry.handleCommand(name, (Command<SomeDataClass> message) -> Mono.empty(), SomeDataClass.class); assertThat(registry.getCommandHandlers()).anySatisfy(registered -> { assertThat(registered).extracting(RegisteredCommandHandler::getPath, RegisteredCommandHandler::getInputClass) .containsExactly(name, SomeDataClass.class); }).hasSize(1); }