MongoConfig extends Config { @Override protected void validate() { if (uri == null) throw new Error("mongo uri must be configured, name=" + name); if (!entityAdded) throw new Error("mongo is configured but no collection/view added, please remove unnecessary config, name=" + name); }  void uri(String uri); void poolSize(int minSize, int maxSize); void slowOperationThreshold(Duration threshold); void tooManyRowsReturnedThreshold(int threshold); void timeout(Duration timeout); void collection(Class<T> entityClass); void view(Class<T> viewClass);  }
@Test void validate() { assertThatThrownBy(() -> config.validate()) .hasMessageContaining("mongo uri must be configured"); config.uri = "mongodb: assertThatThrownBy(() -> config.validate()) .hasMessageContaining("no collection/view added"); }