Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private ServerTemplateImpl(Builder builder) {
try {
this.cache.set(ServerTemplateData.fromJSON(initialTemplate));
} catch (FirebaseRemoteConfigException e) {
e.printStackTrace();
throw new IllegalArgumentException("Unable to parse JSON string.", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import com.google.api.core.ApiFuture;
import com.google.firebase.FirebaseApp;
Expand Down Expand Up @@ -188,20 +189,17 @@ public void testEvaluateWithoutDefaultValueReturnsEmptyString()
public void testEvaluateWithInvalidCacheValueThrowsException()
throws FirebaseRemoteConfigException {
KeysAndValues defaultConfig = new KeysAndValues.Builder().build();
KeysAndValues context = new KeysAndValues.Builder().build();
String invalidJsonString = "abc";
ServerTemplate template =
new ServerTemplateImpl.Builder(null)
.defaultConfig(defaultConfig)
.cachedTemplate(invalidJsonString)
.build();

FirebaseRemoteConfigException error =
assertThrows(FirebaseRemoteConfigException.class, () -> template.evaluate(context));

assertEquals(
"No Remote Config Server template in cache. Call load() before " + "calling evaluate().",
Comment thread
rathovarun1032 marked this conversation as resolved.
error.getMessage());
IllegalArgumentException error = assertThrows(
IllegalArgumentException.class,
() -> new ServerTemplateImpl.Builder(null)
.defaultConfig(defaultConfig)
.cachedTemplate(invalidJsonString)
.build());

assertEquals("Unable to parse JSON string.", error.getMessage());
// Verify the cause is the original FirebaseRemoteConfigException
assertTrue(error.getCause() instanceof FirebaseRemoteConfigException);
}

@Test
Expand Down
Loading