|  | 
| 60 | 60 | 
 | 
| 61 | 61 | public class SessionReportingCoordinatorTest extends CrashlyticsTestCase { | 
| 62 | 62 | 
 | 
| 63 |  | -  private static String TEST_SESSION_ID = "testSession1"; | 
|  | 63 | +  private static final String TEST_SESSION_ID = "testSessionId"; | 
| 64 | 64 | 
 | 
| 65 | 65 |   @Mock private CrashlyticsReportDataCapture dataCapture; | 
| 66 | 66 |   @Mock private CrashlyticsReportPersistence reportPersistence; | 
| @@ -269,7 +269,8 @@ public void testNonFatalEvent_addsSortedKeysToEvent() throws Exception { | 
| 269 | 269 |     expectedCustomAttributes.add(customAttribute1); | 
| 270 | 270 |     expectedCustomAttributes.add(customAttribute2); | 
| 271 | 271 | 
 | 
| 272 |  | -    addKeysToUserMetadata(attributes); | 
|  | 272 | +    addCustomKeysToUserMetadata(attributes); | 
|  | 273 | +    addInternalKeysToUserMetadata(attributes); | 
| 273 | 274 | 
 | 
| 274 | 275 |     reportingCoordinator.onBeginSession(sessionId, timestamp); | 
| 275 | 276 |     reportingCoordinator.persistNonFatalEvent( | 
| @@ -357,7 +358,7 @@ public void testNonFatalEvent_mergesUserInfoKeysWithCustomKeys() throws Exceptio | 
| 357 | 358 |     attributes.put(testKey1, testValue1); | 
| 358 | 359 |     attributes.put(testKey2, testValue2); | 
| 359 | 360 | 
 | 
| 360 |  | -    addKeysToUserMetadata(attributes); | 
|  | 361 | +    addCustomKeysToUserMetadata(attributes); | 
| 361 | 362 | 
 | 
| 362 | 363 |     final String testValue1UserInfo = "testValue1"; | 
| 363 | 364 |     final String testKey3 = "testKey3"; | 
| @@ -441,7 +442,7 @@ public void testFatalEvent_addsSortedCustomKeysToEvent() throws Exception { | 
| 441 | 442 |     expectedCustomAttributes.add(customAttribute1); | 
| 442 | 443 |     expectedCustomAttributes.add(customAttribute2); | 
| 443 | 444 | 
 | 
| 444 |  | -    addKeysToUserMetadata(attributes); | 
|  | 445 | +    addCustomKeysToUserMetadata(attributes); | 
| 445 | 446 | 
 | 
| 446 | 447 |     reportingCoordinator.onBeginSession(sessionId, timestamp); | 
| 447 | 448 |     reportingCoordinator.persistFatalEvent(mockException, mockThread, sessionId, timestamp); | 
| @@ -479,7 +480,7 @@ public void testFatalEvent_addsSortedInternalKeysToEvent() throws Exception { | 
| 479 | 480 |     expectedCustomAttributes.add(customAttribute1); | 
| 480 | 481 |     expectedCustomAttributes.add(customAttribute2); | 
| 481 | 482 | 
 | 
| 482 |  | -    addKeysToUserMetadata(attributes); | 
|  | 483 | +    addInternalKeysToUserMetadata(attributes); | 
| 483 | 484 | 
 | 
| 484 | 485 |     reportingCoordinator.onBeginSession(sessionId, timestamp); | 
| 485 | 486 |     reportingCoordinator.persistFatalEvent(mockException, mockThread, sessionId, timestamp); | 
| @@ -611,14 +612,21 @@ public void testRemoveAllReports_deletesPersistedReports() { | 
| 611 | 612 |     verify(reportPersistence).deleteAllReports(); | 
| 612 | 613 |   } | 
| 613 | 614 | 
 | 
| 614 |  | -  private void addKeysToUserMetadata(Map<String, String> customKeys) throws Exception { | 
|  | 615 | +  private void addCustomKeysToUserMetadata(Map<String, String> customKeys) throws Exception { | 
| 615 | 616 |     reportMetadata.setCustomKeys(customKeys); | 
| 616 | 617 |     for (Map.Entry<String, String> entry : customKeys.entrySet()) { | 
| 617 | 618 |       reportMetadata.setInternalKey(entry.getKey(), entry.getValue()); | 
| 618 | 619 |     } | 
| 619 | 620 |     crashlyticsWorkers.diskWrite.await(); | 
| 620 | 621 |   } | 
| 621 | 622 | 
 | 
|  | 623 | +  private void addInternalKeysToUserMetadata(Map<String, String> internalKeys) throws Exception { | 
|  | 624 | +    for (Map.Entry<String, String> entry : internalKeys.entrySet()) { | 
|  | 625 | +      reportMetadata.setInternalKey(entry.getKey(), entry.getValue()); | 
|  | 626 | +    } | 
|  | 627 | +    crashlyticsWorkers.diskWrite.await(); | 
|  | 628 | +  } | 
|  | 629 | + | 
| 622 | 630 |   private void mockEventInteractions() { | 
| 623 | 631 |     when(mockEvent.toBuilder()).thenReturn(mockEventBuilder); | 
| 624 | 632 |     when(mockEventBuilder.build()).thenReturn(mockEvent); | 
|  | 
0 commit comments