SearchConfig extends Config { @Override protected void validate() { if (search.hosts == null) throw new Error("search host must be configured, name=" + name); if (!typeAdded) throw new Error("search is configured but no type added, please remove unnecessary config, name=" + name); }  void host(String host); void slowOperationThreshold(Duration threshold); void maxResultWindow(int maxResultWindow); void timeout(Duration timeout); void type(Class<T> documentClass);  }
@Test void validate() { assertThatThrownBy(() -> config.validate()) .hasMessageContaining("search host must be configured"); config.host("localhost"); assertThatThrownBy(() -> config.validate()) .hasMessageContaining("search is configured but no type added"); }