KafkaConfig extends Config { @Override protected void validate() { if (!handlerAdded) throw new Error("kafka is configured, but no producer/consumer added, please remove unnecessary config, name=" + name); }  void uri(String uri); MessagePublisher<T> publish(Class<T> messageClass); MessagePublisher<T> publish(String topic, Class<T> messageClass); void subscribe(String topic, Class<T> messageClass, MessageHandler<T> handler); void subscribe(String topic, Class<T> messageClass, BulkMessageHandler<T> handler); void groupId(String groupId); void poolSize(int poolSize); void maxProcessTime(Duration maxProcessTime); void longConsumerDelayThreshold(Duration threshold); void maxPoll(int maxRecords, int maxBytes); void minPoll(int minBytes, Duration maxWaitTime);  }
@Test void validate() { assertThatThrownBy(() -> config.validate()) .hasMessageContaining("no producer/consumer added"); }