@Test
public void test() throws InterruptedException {
Batcher<TransactionBatch> batcher = mock(Batcher.class);
TransactionBatch batch = mock(TransactionBatch.class);
Remover<String> remover = mock(Remover.class);
ImmutableSession immortalSession = mock(ImmutableSession.class);
ImmutableSession expiringSession = mock(ImmutableSession.class);
ImmutableSession canceledSession = mock(ImmutableSession.class);
SessionMetaData immortalMetaData = mock(SessionMetaData.class);
SessionMetaData shortTimeoutMetaData = mock(SessionMetaData.class);
SessionMetaData longTimeoutMetaData = mock(SessionMetaData.class);
String immortalSessionId = "immortal";
String expiringSessionId = "expiring";
String canceledSessionId = "canceled";
when(batcher.createBatch()).thenReturn(batch);
when(immortalSession.isValid()).thenReturn(true);
when(expiringSession.isValid()).thenReturn(true);
when(canceledSession.isValid()).thenReturn(true);
when(immortalSession.getMetaData()).thenReturn(immortalMetaData);
when(expiringSession.getMetaData()).thenReturn(shortTimeoutMetaData);
when(canceledSession.getMetaData()).thenReturn(longTimeoutMetaData);
when(immortalMetaData.getMaxInactiveInterval(TimeUnit.MILLISECONDS)).thenReturn(0L);
when(shortTimeoutMetaData.getMaxInactiveInterval(TimeUnit.MILLISECONDS)).thenReturn(1L);
when(longTimeoutMetaData.getMaxInactiveInterval(TimeUnit.MILLISECONDS)).thenReturn(10000L);
Date now = new Date();
when(shortTimeoutMetaData.getLastAccessedTime()).thenReturn(now);
when(longTimeoutMetaData.getLastAccessedTime()).thenReturn(now);
when(immortalSession.getId()).thenReturn(immortalSessionId);
when(expiringSession.getId()).thenReturn(expiringSessionId);
when(canceledSession.getId()).thenReturn(canceledSessionId);
try (Scheduler scheduler = new SessionExpirationScheduler(batcher, remover)) {
scheduler.schedule(immortalSession);
scheduler.schedule(canceledSession);
scheduler.schedule(expiringSession);