Skip to content

Commit 16648c0

Browse files
committed
Explicitly differentiate between internal and external keys in the SessionReportingCoordinatorTest
1 parent abd31d3 commit 16648c0

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/internal/common/SessionReportingCoordinatorTest.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
public class SessionReportingCoordinatorTest extends CrashlyticsTestCase {
6262

63-
private static String TEST_SESSION_ID = "testSession1";
63+
private static final String TEST_SESSION_ID = "testSessionId";
6464

6565
@Mock private CrashlyticsReportDataCapture dataCapture;
6666
@Mock private CrashlyticsReportPersistence reportPersistence;
@@ -269,7 +269,8 @@ public void testNonFatalEvent_addsSortedKeysToEvent() throws Exception {
269269
expectedCustomAttributes.add(customAttribute1);
270270
expectedCustomAttributes.add(customAttribute2);
271271

272-
addKeysToUserMetadata(attributes);
272+
addCustomKeysToUserMetadata(attributes);
273+
addInternalKeysToUserMetadata(attributes);
273274

274275
reportingCoordinator.onBeginSession(sessionId, timestamp);
275276
reportingCoordinator.persistNonFatalEvent(
@@ -357,7 +358,7 @@ public void testNonFatalEvent_mergesUserInfoKeysWithCustomKeys() throws Exceptio
357358
attributes.put(testKey1, testValue1);
358359
attributes.put(testKey2, testValue2);
359360

360-
addKeysToUserMetadata(attributes);
361+
addCustomKeysToUserMetadata(attributes);
361362

362363
final String testValue1UserInfo = "testValue1";
363364
final String testKey3 = "testKey3";
@@ -441,7 +442,7 @@ public void testFatalEvent_addsSortedCustomKeysToEvent() throws Exception {
441442
expectedCustomAttributes.add(customAttribute1);
442443
expectedCustomAttributes.add(customAttribute2);
443444

444-
addKeysToUserMetadata(attributes);
445+
addCustomKeysToUserMetadata(attributes);
445446

446447
reportingCoordinator.onBeginSession(sessionId, timestamp);
447448
reportingCoordinator.persistFatalEvent(mockException, mockThread, sessionId, timestamp);
@@ -479,7 +480,7 @@ public void testFatalEvent_addsSortedInternalKeysToEvent() throws Exception {
479480
expectedCustomAttributes.add(customAttribute1);
480481
expectedCustomAttributes.add(customAttribute2);
481482

482-
addKeysToUserMetadata(attributes);
483+
addInternalKeysToUserMetadata(attributes);
483484

484485
reportingCoordinator.onBeginSession(sessionId, timestamp);
485486
reportingCoordinator.persistFatalEvent(mockException, mockThread, sessionId, timestamp);
@@ -611,14 +612,21 @@ public void testRemoveAllReports_deletesPersistedReports() {
611612
verify(reportPersistence).deleteAllReports();
612613
}
613614

614-
private void addKeysToUserMetadata(Map<String, String> customKeys) throws Exception {
615+
private void addCustomKeysToUserMetadata(Map<String, String> customKeys) throws Exception {
615616
reportMetadata.setCustomKeys(customKeys);
616617
for (Map.Entry<String, String> entry : customKeys.entrySet()) {
617618
reportMetadata.setInternalKey(entry.getKey(), entry.getValue());
618619
}
619620
crashlyticsWorkers.diskWrite.await();
620621
}
621622

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+
622630
private void mockEventInteractions() {
623631
when(mockEvent.toBuilder()).thenReturn(mockEventBuilder);
624632
when(mockEventBuilder.build()).thenReturn(mockEvent);

0 commit comments

Comments
 (0)