UserProfileBridge implements LockReactBridge { private void put(String key, Map<String, Object> map, WritableMap into) { if (map == null || map.isEmpty()) { return; } final WritableMap writableMap = Arguments.createMap(); for (Map.Entry<String, Object> entry: map.entrySet()) { put(entry.getKey(), entry.getValue(), writableMap); } into.putMap(key, writableMap); } UserProfileBridge(@Nullable UserProfile profile); WritableMap toMap();  }
@Test public void shouldBridgeMetadata() throws Exception { final HashMap<String, Object> user = Maps.newHashMap(); user.put("first_name", "John"); user.put("last_name", "Doe"); user.put("friend_count", 14); final HashMap<String, Object> app = Maps.newHashMap(); app.put("subscription", "bronze"); final UserProfile profile = withMetadata(INFO_AUTH0_COM, user, app); final ReadableMap map = bridge(profile); assertThat(map.getString(EMAIL), equalTo(INFO_AUTH0_COM)); final ReadableMap userMetadata = map.getMap(USER_METADATA); assertThat(userMetadata.getString("first_name"), equalTo("John")); assertThat(userMetadata.getString("last_name"), equalTo("Doe")); assertThat(userMetadata.getInt("friend_count"), equalTo(14)); final ReadableMap appMetadata = map.getMap(APP_METADATA); assertThat(appMetadata.getString("subscription"), equalTo("bronze")); }