From 4aacb868ebdcbdbaefaa26c4dc5942ea341bdc32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 3 Aug 2022 16:32:31 +0200 Subject: [PATCH] Align Hibernate Search's error messages and documentation for .enable/.active on ORM's --- .../ConfigEnabledFalseAndActiveTrueTest.java | 6 +++--- .../runtime/HibernateSearchElasticsearchRecorder.java | 8 +++++--- ...teSearchElasticsearchRuntimeConfigPersistenceUnit.java | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/src/test/java/io/quarkus/hibernate/search/orm/elasticsearch/test/configuration/ConfigEnabledFalseAndActiveTrueTest.java b/extensions/hibernate-search-orm-elasticsearch/deployment/src/test/java/io/quarkus/hibernate/search/orm/elasticsearch/test/configuration/ConfigEnabledFalseAndActiveTrueTest.java index 00722a3303d39b..27d173c0beefa2 100644 --- a/extensions/hibernate-search-orm-elasticsearch/deployment/src/test/java/io/quarkus/hibernate/search/orm/elasticsearch/test/configuration/ConfigEnabledFalseAndActiveTrueTest.java +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/src/test/java/io/quarkus/hibernate/search/orm/elasticsearch/test/configuration/ConfigEnabledFalseAndActiveTrueTest.java @@ -21,9 +21,9 @@ public class ConfigEnabledFalseAndActiveTrueTest { .assertException(throwable -> assertThat(throwable) .isInstanceOf(ConfigurationException.class) .hasMessageContainingAll( - "Hibernate Search activated explicitly, but Hibernate Search was disabled at build time", - "If you want Hibernate Search to be active at runtime, you must set 'quarkus.hibernate-search-orm.enabled' to 'true' at build time", - "If you don't want Hibernate Search to be active at runtime, you must leave 'quarkus.hibernate-search-orm.active' unset or set it to 'false'")); + "Hibernate Search activated explicitly for persistence unit '', but the Hibernate Search extension was disabled at build time", + "If you want Hibernate Search to be active for this persistence unit, you must set 'quarkus.hibernate-search-orm.enabled' to 'true' at build time", + "If you don't want Hibernate Search to be active for this persistence unit, you must leave 'quarkus.hibernate-search-orm.active' unset or set it to 'false'")); @Test public void test() { diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java index 1f692cd772cd9c..80619b2a2bcba4 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java @@ -83,10 +83,12 @@ public void checkNoExplicitActiveTrue(HibernateSearchElasticsearchRuntimeConfig String enabledPropertyKey = HibernateSearchElasticsearchRuntimeConfig.extensionPropertyKey("enabled"); String activePropertyKey = HibernateSearchElasticsearchRuntimeConfig.mapperPropertyKey(puName, "active"); throw new ConfigurationException( - "Hibernate Search activated explicitly, but Hibernate Search was disabled at build time." - + " If you want Hibernate Search to be active at runtime, you must set '" + enabledPropertyKey + "Hibernate Search activated explicitly for persistence unit '" + puName + + "', but the Hibernate Search extension was disabled at build time." + + " If you want Hibernate Search to be active for this persistence unit, you must set '" + + enabledPropertyKey + "' to 'true' at build time." - + " If you don't want Hibernate Search to be active at runtime, you must leave '" + + " If you don't want Hibernate Search to be active for this persistence unit, you must leave '" + activePropertyKey + "' unset or set it to 'false'.", Set.of(enabledPropertyKey, activePropertyKey)); diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfigPersistenceUnit.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfigPersistenceUnit.java index 2c0679be92d178..6979394ca30cc7 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfigPersistenceUnit.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfigPersistenceUnit.java @@ -23,13 +23,14 @@ public class HibernateSearchElasticsearchRuntimeConfigPersistenceUnit { /** - * Whether Hibernate Search should be active at runtime. + * Whether Hibernate Search should be active for this persistence unit at runtime. * * If Hibernate Search is not active, it won't index Hibernate ORM entities, - * and accessing the SearchMapping/SearchSession for search or other operation will not be possible. + * and accessing the SearchMapping/SearchSession of the relevant persistence unit + * for search or other operation will not be possible. * * Note that if Hibernate Search is disabled (i.e. `quarkus.hibernate-search-orm.enabled` is set to `false`), - * it won't be active, and setting this property to `true` will fail. + * it won't be active for any persistence unit, and setting this property to `true` will fail. * * @asciidoclet */