SessionTracker extends AbstractChannelListener { @WorkerThread public void onActivityResumed() { AppCenterLog.debug(Analytics.LOG_TAG, "onActivityResumed"); mLastResumedTime = SystemClock.elapsedRealtime(); sendStartSessionIfNeeded(); } SessionTracker(Channel channel, String groupName); @Override void onPreparingLog(@NonNull Log log, @NonNull String groupName); @WorkerThread void onActivityResumed(); @WorkerThread void onActivityPaused(); void clearSessions();  }
@Test public void partiallyInvalidStorage() { Set<String> sessions = new LinkedHashSet<>(); sessions.add("100/10abd355-40a5-4b51-8071-cb5a4c338531/99"); sessions.add("200/invalid"); sessions.add("300/10abd355-40a5-4b51-8071-cb5a4c338533/garbage"); sessions.add("400"); sessions.add("500a/10abd355-40a5-4b51-8071-cb5a4c338535"); sessions.add("600/10abd355-40a5-4b51-8071-cb5a4c338533/599/extracontent"); sessions.add("700/10abd355-40a5-4b51-8071-cb5a4c338533"); sessions.add("800/"); sessions.add("900 sessions.add("999 when(SharedPreferencesManager.getStringSet(anyString())).thenReturn(sessions); mSessionTracker = new SessionTracker(mChannel, TEST_GROUP); mSessionTracker.onActivityResumed(); sessions = SharedPreferencesManager.getStringSet("sessions"); assertNotNull(sessions); assertEquals(6, sessions.size()); assertTrue(sessions.contains("100/10abd355-40a5-4b51-8071-cb5a4c338531/99")); assertFalse(sessions.contains("200/invalid")); assertFalse(sessions.contains("300/10abd355-40a5-4b51-8071-cb5a4c338533")); assertFalse(sessions.contains("400")); assertFalse(sessions.contains("500a/10abd355-40a5-4b51-8071-cb5a4c338535")); assertTrue(sessions.contains("600/10abd355-40a5-4b51-8071-cb5a4c338533/599")); assertTrue(sessions.contains("700/10abd355-40a5-4b51-8071-cb5a4c338533/700")); assertTrue(sessions.contains("800 assertTrue(sessions.contains("900 assertFalse(sessions.contains("999 }