@Override public void onPreparingLog(@NonNull Log log, @NonNull String groupName) { /* * Since we enqueue start session logs, skip them to avoid infinite loop. * Also skip start service log as it's always sent and should not trigger a session. */ if (log instanceof StartSessionLog || log instanceof StartServiceLog) { return; } /* * If the log has already specified a timestamp, try correlating with a past session. * Note that it can also find the current session but that's ok: in that case that means * its a log that will be associated to current session but won't trigger expiration logic. */ Date timestamp = log.getTimestamp(); if (timestamp != null) { SessionContext.SessionInfo pastSession = SessionContext.getInstance().getSessionAt(timestamp.getTime()); if (pastSession != null) { log.setSid(pastSession.getSessionId()); } } /* If the log does not have a timestamp yet, then we just correlate with current session. */ else { /* Set current session identifier. */ log.setSid(mSid); /* Record queued time only if the log is using current session. */ mLastQueuedLogTime = SystemClock.elapsedRealtime(); } }
when(log2.getTimestamp()).thenReturn(new Date(123L)); channel.enqueue(log2, "", DEFAULTS); verify(log2, never()).setDevice(any(Device.class));
if (log.getTimestamp() == null) { log.setTimestamp(new Date());
dest.setTimestamp(src.getTimestamp());
Log log = mock(Log.class); when(log.getDevice()).thenReturn(device); when(log.getTimestamp()).thenReturn(timestamp); when(log.getUserId()).thenReturn("alice");