FirebaseRemoteConfig implements RawBackgroundFunction { @Override public void accept(String json, Context context) { JsonObject body = gson.fromJson(json, JsonObject.class); if (body != null) { if (body.has("updateType")) { logger.info("Update type: " + body.get("updateType").getAsString()); } if (body.has("updateOrigin")) { logger.info("Origin: " + body.get("updateOrigin").getAsString()); } if (body.has("versionNumber")) { logger.info("Version: " + body.get("versionNumber").getAsString()); } } }  @Override void accept(String json, Context context);  }
@Test public void functionsFirebaseRemoteConfig_shouldShowUpdateType() { String jsonStr = gson.toJson(Map.of("updateType", "foo")); new FirebaseRemoteConfig().accept(jsonStr, null); Truth.assertThat(LOG_HANDLER.getStoredLogRecords().get(0).getMessage()).isEqualTo( "Update type: foo"); }
@Test public void functionsFirebaseRemoteConfig_shouldShowOrigin() { String jsonStr = gson.toJson(Map.of("updateOrigin", "foo")); new FirebaseRemoteConfig().accept(jsonStr, null); Truth.assertThat(LOG_HANDLER.getStoredLogRecords().get(0).getMessage()).isEqualTo( "Origin: foo"); }
@Test public void functionsFirebaseRemoteConfig_shouldShowVersion() { String jsonStr = gson.toJson(Map.of("versionNumber", 2)); new FirebaseRemoteConfig().accept(jsonStr, null); Truth.assertThat(LOG_HANDLER.getStoredLogRecords().get(0).getMessage()).isEqualTo("Version: 2"); }