|
18 | 18 |
|
19 | 19 | import static org.junit.Assert.assertEquals; |
20 | 20 | import static org.junit.Assert.assertThrows; |
| 21 | +import static org.junit.Assert.assertTrue; |
21 | 22 |
|
22 | 23 | import com.google.api.core.ApiFuture; |
23 | 24 | import com.google.firebase.FirebaseApp; |
@@ -188,20 +189,17 @@ public void testEvaluateWithoutDefaultValueReturnsEmptyString() |
188 | 189 | public void testEvaluateWithInvalidCacheValueThrowsException() |
189 | 190 | throws FirebaseRemoteConfigException { |
190 | 191 | KeysAndValues defaultConfig = new KeysAndValues.Builder().build(); |
191 | | - KeysAndValues context = new KeysAndValues.Builder().build(); |
192 | 192 | String invalidJsonString = "abc"; |
193 | | - ServerTemplate template = |
194 | | - new ServerTemplateImpl.Builder(null) |
195 | | - .defaultConfig(defaultConfig) |
196 | | - .cachedTemplate(invalidJsonString) |
197 | | - .build(); |
198 | | - |
199 | | - FirebaseRemoteConfigException error = |
200 | | - assertThrows(FirebaseRemoteConfigException.class, () -> template.evaluate(context)); |
201 | | - |
202 | | - assertEquals( |
203 | | - "No Remote Config Server template in cache. Call load() before " + "calling evaluate().", |
204 | | - error.getMessage()); |
| 193 | + IllegalArgumentException error = assertThrows( |
| 194 | + IllegalArgumentException.class, |
| 195 | + () -> new ServerTemplateImpl.Builder(null) |
| 196 | + .defaultConfig(defaultConfig) |
| 197 | + .cachedTemplate(invalidJsonString) |
| 198 | + .build()); |
| 199 | + |
| 200 | + assertEquals("Unable to parse JSON string.", error.getMessage()); |
| 201 | + // Verify the cause is the original FirebaseRemoteConfigException |
| 202 | + assertTrue(error.getCause() instanceof FirebaseRemoteConfigException); |
205 | 203 | } |
206 | 204 |
|
207 | 205 | @Test |
|
0 commit comments