From ab446906534087e45fa4683d079357fc8207b3a8 Mon Sep 17 00:00:00 2001 From: yangyx <360508847@qq.com> Date: Wed, 10 Jul 2024 10:51:05 +0800 Subject: [PATCH] Add hive hook custom config unit test --- .../MetaStoreMappingFactoryImplTest.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/mapping/model/MetaStoreMappingFactoryImplTest.java b/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/mapping/model/MetaStoreMappingFactoryImplTest.java index 7bfc06c4..be91d32c 100644 --- a/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/mapping/model/MetaStoreMappingFactoryImplTest.java +++ b/waggle-dance-core/src/test/java/com/hotels/bdp/waggledance/mapping/model/MetaStoreMappingFactoryImplTest.java @@ -141,6 +141,23 @@ public void unreachableMetastoreClient() { @Test public void loadMetastoreFilterHookFromConfig() { + AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri()); + federatedMetaStore.setHiveMetastoreFilterHook(PrefixingMetastoreFilter.class.getName()); + MetaStoreMapping mapping = factory.newInstance(federatedMetaStore); + assertThat(mapping, is(notNullValue())); + assertThat(mapping.getMetastoreFilter(), instanceOf(PrefixingMetastoreFilter.class)); + } + + @Test + public void loadDefaultMetastoreFilterHook() { + AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri()); + MetaStoreMapping mapping = factory.newInstance(federatedMetaStore); + assertThat(mapping, is(notNullValue())); + assertThat(mapping.getMetastoreFilter(), instanceOf(DefaultMetaStoreFilterHookImpl.class)); + } + + @Test + public void loadMetastoreFilterHookWithCustomConfig() { AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri()); federatedMetaStore.setHiveMetastoreFilterHook(PrefixingMetastoreFilter.class.getName()); Map metaStoreConfigurationProperties = new HashMap<>(); @@ -149,7 +166,6 @@ public void loadMetastoreFilterHookFromConfig() { MetaStoreMapping mapping = factory.newInstance(federatedMetaStore); assertThat(mapping, is(notNullValue())); - MetaStoreFilterHook filterHook = mapping.getMetastoreFilter(); assertThat(filterHook, instanceOf(PrefixingMetastoreFilter.class)); @@ -165,12 +181,4 @@ public void loadMetastoreFilterHookFromConfig() { }catch (Exception e){ } } - - @Test - public void loadDefaultMetastoreFilterHook() { - AbstractMetaStore federatedMetaStore = newFederatedInstance("fed1", thrift.getThriftConnectionUri()); - MetaStoreMapping mapping = factory.newInstance(federatedMetaStore); - assertThat(mapping, is(notNullValue())); - assertThat(mapping.getMetastoreFilter(), instanceOf(DefaultMetaStoreFilterHookImpl.class)); - } }