@@ -238,16 +238,16 @@ public void testCustomKeysMergedWithEventKeys() throws Exception {
238238 UserMetadata metadata = crashlyticsCore .getController ().getUserMetadata ();
239239
240240 Map <String , String > keysAndValues = new HashMap <>();
241- keysAndValues .put ("1 " , "value" );
242- keysAndValues .put ("2 " , "value" );
243- keysAndValues .put ("3 " , "value" );
241+ keysAndValues .put ("customKey1 " , "value" );
242+ keysAndValues .put ("customKey2 " , "value" );
243+ keysAndValues .put ("customKey3 " , "value" );
244244
245245 metadata .setCustomKeys (keysAndValues );
246246 crashlyticsWorkers .common .await ();
247247
248248 Map <String , String > eventKeysAndValues = new HashMap <>();
249- eventKeysAndValues .put ("4 " , "eventValue" );
250- eventKeysAndValues .put ("5 " , "eventValue" );
249+ eventKeysAndValues .put ("eventKey1 " , "eventValue" );
250+ eventKeysAndValues .put ("eventKey2 " , "eventValue" );
251251
252252 // Tests reading custom keys with event keys.
253253 assertEquals (keysAndValues .size (), metadata .getCustomKeys ().size ());
@@ -261,20 +261,20 @@ public void testCustomKeysMergedWithEventKeys() throws Exception {
261261 assertEquals (keysAndValues .size (), metadata .getCustomKeys (Map .of ()).size ());
262262
263263 // Tests additional event keys.
264- eventKeysAndValues .put ("6 " , "eventValue" );
265- eventKeysAndValues .put ("7 " , "eventValue" );
264+ eventKeysAndValues .put ("eventKey3 " , "eventValue" );
265+ eventKeysAndValues .put ("eventKey4 " , "eventValue" );
266266 assertEquals (
267267 keysAndValues .size () + eventKeysAndValues .size (),
268268 metadata .getCustomKeys (eventKeysAndValues ).size ());
269269
270270 // Tests overriding custom key with event keys.
271- keysAndValues .put ("7 " , "value" );
271+ keysAndValues .put ("eventKey1 " , "value" );
272272 metadata .setCustomKeys (keysAndValues );
273273 crashlyticsWorkers .common .await ();
274274
275- assertEquals ("value" , metadata .getCustomKeys ().get ("7 " ));
276- assertEquals ("value" , metadata .getCustomKeys (Map .of ()).get ("7 " ));
277- assertEquals ("eventValue" , metadata .getCustomKeys (eventKeysAndValues ).get ("7 " ));
275+ assertEquals ("value" , metadata .getCustomKeys ().get ("eventKey1 " ));
276+ assertEquals ("value" , metadata .getCustomKeys (Map .of ()).get ("eventKey1 " ));
277+ assertEquals ("eventValue" , metadata .getCustomKeys (eventKeysAndValues ).get ("eventKey1 " ));
278278
279279 // Test the event key behavior when the count of custom keys is max.
280280 for (int i = keysAndValues .size (); i < UserMetadata .MAX_ATTRIBUTES ; ++i ) {
@@ -287,9 +287,13 @@ public void testCustomKeysMergedWithEventKeys() throws Exception {
287287
288288 assertEquals (UserMetadata .MAX_ATTRIBUTES , metadata .getCustomKeys ().size ());
289289
290- assertEquals ("value" , metadata .getCustomKeys ().get ("7" ));
291- assertEquals ("value" , metadata .getCustomKeys (Map .of ()).get ("7" ));
292- assertEquals ("eventValue" , metadata .getCustomKeys (eventKeysAndValues ).get ("7" ));
290+ // Tests event keys override global custom keys when the key exists.
291+ assertEquals ("value" , metadata .getCustomKeys ().get ("eventKey1" ));
292+ assertEquals ("value" , metadata .getCustomKeys (Map .of ()).get ("eventKey1" ));
293+ assertEquals ("eventValue" , metadata .getCustomKeys (eventKeysAndValues ).get ("eventKey1" ));
294+
295+ // Test when event keys *don't* override global custom keys.
296+ assertNull (metadata .getCustomKeys (eventKeysAndValues ).get ("eventKey2" ));
293297 }
294298
295299 @ Test
0 commit comments