ConfigSerializer implements MapSerializer<ImmutableConfig> { @Override public void serialize(Map<String, Object> map, ImmutableConfig config) { map.put("apiKey", config.getApiKey()); map.put("autoDetectErrors", config.getAutoDetectErrors()); map.put("autoTrackSessions", config.getAutoTrackSessions()); map.put("sendThreads", config.getSendThreads().toString()); map.put("discardClasses", config.getDiscardClasses()); map.put("projectPackages", config.getProjectPackages()); map.put("enabledReleaseStages", config.getEnabledReleaseStages()); map.put("releaseStage", config.getReleaseStage()); map.put("buildUuid", config.getBuildUuid()); if (config.getAppVersion() != null) { map.put("appVersion", config.getAppVersion()); } map.put("versionCode", config.getVersionCode()); map.put("type", config.getAppType()); map.put("persistUser", config.getPersistUser()); map.put("launchCrashThresholdMs", (int) config.getLaunchCrashThresholdMs()); map.put("maxBreadcrumbs", config.getMaxBreadcrumbs()); map.put("enabledBreadcrumbTypes", serializeBreadrumbTypes(config)); map.put("enabledErrorTypes", serializeErrorTypes(config)); map.put("endpoints", serializeEndpoints(config)); }  @Override void serialize(Map<String, Object> map, ImmutableConfig config);  }
@SuppressWarnings("unchecked") @Test public void serialize() { ConfigSerializer serializer = new ConfigSerializer(); Map<String, Object> map = new HashMap<>(); serializer.serialize(map, config); assertEquals("123456abcdeabcde", map.get("apiKey")); assertTrue((Boolean) map.get("autoDetectErrors")); assertTrue((Boolean) map.get("autoTrackSessions")); assertEquals("ALWAYS", map.get("sendThreads")); assertEquals(Collections.singleton("com.example.DiscardClass"), map.get("discardClasses")); assertEquals(Collections.singleton("production"), map.get("enabledReleaseStages")); assertEquals(Collections.singleton("com.example"), map.get("projectPackages")); assertEquals("production", map.get("releaseStage")); assertEquals("builduuid-123", map.get("buildUuid")); assertEquals("1.4.3", map.get("appVersion")); assertEquals(55, map.get("versionCode")); assertEquals("android", map.get("type")); assertTrue((Boolean) map.get("persistUser")); assertEquals(55, map.get("launchCrashThresholdMs")); assertEquals(22, map.get("maxBreadcrumbs")); assertEquals(Collections.singleton("manual"), map.get("enabledBreadcrumbTypes")); Map<String, Object> errorTypes = (Map<String, Object>) map.get("enabledErrorTypes"); assertTrue((Boolean) errorTypes.get("anrs")); assertTrue((Boolean) errorTypes.get("ndkCrashes")); assertTrue((Boolean) errorTypes.get("unhandledExceptions")); assertTrue((Boolean) errorTypes.get("unhandledRejections")); Map<String, Object> endpoints = (Map<String, Object>) map.get("endpoints"); assertEquals("https: assertEquals("https: }