2020
2121import static org .assertj .core .api .Assertions .assertThat ;
2222
23- import io .quarkus .test .junit .QuarkusMock ;
2423import io .quarkus .test .junit .QuarkusTest ;
2524import io .quarkus .test .junit .QuarkusTestProfile ;
2625import io .quarkus .test .junit .TestProfile ;
2726import jakarta .inject .Inject ;
28- import java .time .Clock ;
2927import java .util .Map ;
30- import org .apache .polaris .core .PolarisCallContext ;
31- import org .apache .polaris .core .PolarisDiagnostics ;
3228import org .apache .polaris .core .config .FeatureConfiguration ;
3329import org .apache .polaris .core .config .PolarisConfigurationStore ;
3430import org .apache .polaris .core .context .RealmContext ;
3531import org .apache .polaris .core .entity .CatalogEntity ;
36- import org .apache .polaris .core .persistence .MetaStoreManagerFactory ;
3732import org .apache .polaris .service .config .DefaultConfigurationStore ;
3833import org .apache .polaris .service .config .FeaturesConfiguration ;
3934import org .assertj .core .api .Assertions ;
@@ -73,12 +68,9 @@ public Map<String, String> getConfigOverrides() {
7368 }
7469 }
7570
76- private PolarisCallContext polarisContext ;
7771 private RealmContext realmContext ;
7872
79- @ Inject MetaStoreManagerFactory managerFactory ;
8073 @ Inject PolarisConfigurationStore configurationStore ;
81- @ Inject PolarisDiagnostics diagServices ;
8274 @ Inject FeaturesConfiguration featuresConfiguration ;
8375
8476 @ BeforeEach
@@ -89,60 +81,42 @@ public void before(TestInfo testInfo) {
8981 testInfo .getTestMethod ().map (java .lang .reflect .Method ::getName ).orElse ("test" ),
9082 System .nanoTime ());
9183 realmContext = () -> realmName ;
92- polarisContext =
93- new PolarisCallContext (
94- realmContext ,
95- managerFactory .getOrCreateSessionSupplier (realmContext ).get (),
96- diagServices ,
97- configurationStore ,
98- Clock .systemDefaultZone ());
99- }
100-
101- @ Test
102- public void testGetConfigurationWithNoRealmContext () {
103- Assertions .assertThatThrownBy (
104- () -> configurationStore .getConfiguration (polarisContext , "missingKeyWithoutDefault" ))
105- .isInstanceOf (IllegalStateException .class );
10684 }
10785
10886 @ Test
10987 public void testGetConfiguration () {
110- QuarkusMock .installMockForType (realmContext , RealmContext .class );
111- Object value = configurationStore .getConfiguration (polarisContext , "missingKeyWithoutDefault" );
88+ Object value = configurationStore .getConfiguration (realmContext , "missingKeyWithoutDefault" );
11289 assertThat (value ).isNull ();
11390 Object defaultValue =
114- configurationStore .getConfiguration (
115- polarisContext , "missingKeyWithDefault" , "defaultValue" );
91+ configurationStore .getConfiguration (realmContext , "missingKeyWithDefault" , "defaultValue" );
11692 assertThat (defaultValue ).isEqualTo ("defaultValue" );
11793
11894 // the falseByDefaultKey is set to false for all realms in Profile.getConfigOverrides
119- assertThat ((Boolean ) configurationStore .getConfiguration (polarisContext , falseByDefaultKey ))
95+ assertThat ((Boolean ) configurationStore .getConfiguration (realmContext , falseByDefaultKey ))
12096 .isFalse ();
12197 // the trueByDefaultKey is set to true for all realms in Profile.getConfigOverrides
122- assertThat ((Boolean ) configurationStore .getConfiguration (polarisContext , trueByDefaultKey ))
98+ assertThat ((Boolean ) configurationStore .getConfiguration (realmContext , trueByDefaultKey ))
12399 .isTrue ();
124100 }
125101
126102 @ Test
127103 public void testGetRealmConfiguration () {
128104 // check the realmOne configuration
129- QuarkusMock .installMockForType (realmOneContext , RealmContext .class );
130105 // the falseByDefaultKey is set to `false` for all realms, but overwrite with value `true` for
131106 // realmOne.
132- assertThat ((Boolean ) configurationStore .getConfiguration (polarisContext , falseByDefaultKey ))
107+ assertThat ((Boolean ) configurationStore .getConfiguration (realmOneContext , falseByDefaultKey ))
133108 .isTrue ();
134109 // the trueByDefaultKey is set to `false` for all realms, no overwrite for realmOne
135- assertThat ((Boolean ) configurationStore .getConfiguration (polarisContext , trueByDefaultKey ))
110+ assertThat ((Boolean ) configurationStore .getConfiguration (realmOneContext , trueByDefaultKey ))
136111 .isTrue ();
137112
138113 // check the realmTwo configuration
139- QuarkusMock .installMockForType (realmTwoContext , RealmContext .class );
140114 // the falseByDefaultKey is set to `false` for all realms, no overwrite for realmTwo
141- assertThat ((Boolean ) configurationStore .getConfiguration (polarisContext , falseByDefaultKey ))
115+ assertThat ((Boolean ) configurationStore .getConfiguration (realmTwoContext , falseByDefaultKey ))
142116 .isFalse ();
143117 // the trueByDefaultKey is set to `false` for all realms, and overwrite with value `false` for
144118 // realmTwo
145- assertThat ((Boolean ) configurationStore .getConfiguration (polarisContext , trueByDefaultKey ))
119+ assertThat ((Boolean ) configurationStore .getConfiguration (realmTwoContext , trueByDefaultKey ))
146120 .isFalse ();
147121 }
148122
@@ -167,28 +141,24 @@ void testGetConfigurationWithRealm() {
167141
168142 @ Test
169143 public void testInjectedConfigurationStore () {
170- QuarkusMock .installMockForType (realmContext , RealmContext .class );
171144 // the default value for trueByDefaultKey is `true`
172- boolean featureDefaultValue =
173- configurationStore .getConfiguration (polarisContext , trueByDefaultKey );
145+ Boolean featureDefaultValue =
146+ configurationStore .getConfiguration (realmContext , trueByDefaultKey );
174147 assertThat (featureDefaultValue ).isTrue ();
175148
176- QuarkusMock .installMockForType (realmTwoContext , RealmContext .class );
177149 // the value for falseByDefaultKey is `false`, and no realm override for realmTwo
178- boolean realmTwoValue = configurationStore .getConfiguration (polarisContext , falseByDefaultKey );
150+ Boolean realmTwoValue = configurationStore .getConfiguration (realmTwoContext , falseByDefaultKey );
179151 assertThat (realmTwoValue ).isFalse ();
180152
181153 // Now, realmOne override falseByDefaultKey to `True`
182- QuarkusMock .installMockForType (realmOneContext , RealmContext .class );
183- boolean realmOneValue = configurationStore .getConfiguration (polarisContext , falseByDefaultKey );
154+ Boolean realmOneValue = configurationStore .getConfiguration (realmOneContext , falseByDefaultKey );
184155 assertThat (realmOneValue ).isTrue ();
185156
186157 assertThat (configurationStore ).isInstanceOf (DefaultConfigurationStore .class );
187158 }
188159
189160 @ Test
190161 public void testInjectedFeaturesConfiguration () {
191- QuarkusMock .installMockForType (realmContext , RealmContext .class );
192162 assertThat (featuresConfiguration ).isInstanceOf (QuarkusResolvedFeaturesConfiguration .class );
193163
194164 assertThat (featuresConfiguration .defaults ())
@@ -209,7 +179,6 @@ public void testInjectedFeaturesConfiguration() {
209179
210180 @ Test
211181 public void testRegisterAndUseFeatureConfigurations () {
212- QuarkusMock .installMockForType (realmContext , RealmContext .class );
213182 String prefix = "testRegisterAndUseFeatureConfigurations" ;
214183
215184 FeatureConfiguration <Boolean > safeConfig =
0 commit comments