@Override
    public int size() {
        return eventHandler.size();
    }
@Test
    public void testInterruptedWithDeferredEvents() throws Exception {
        CompletableFuture<Void> cleanupFuture = new CompletableFuture<>();
        try (KafkaEventQueue queue = new KafkaEventQueue(Time.SYSTEM, logContext, "testInterruptedWithDeferredEvents", () -> cleanupFuture.complete(null))) {
            CompletableFuture<Thread> queueThread = new CompletableFuture<>();
            queue.append(() -> queueThread.complete(Thread.currentThread()));
            ExceptionTrapperEvent ieTrapper1 = new ExceptionTrapperEvent();
            ExceptionTrapperEvent ieTrapper2 = new ExceptionTrapperEvent();
            queue.scheduleDeferred("ie2",
                    __ -> OptionalLong.of(Time.SYSTEM.nanoseconds() + HOURS.toNanos(2)),
                    ieTrapper2);
            queue.scheduleDeferred("ie1",
                    __ -> OptionalLong.of(Time.SYSTEM.nanoseconds() + HOURS.toNanos(1)),
                    ieTrapper1);
            TestUtils.retryOnExceptionWithTimeout(30000, () -> assertEquals(2, queue.size()));
            queueThread.get().interrupt();
            cleanupFuture.get();
            assertEquals(InterruptedException.class, ieTrapper1.exception.get().getClass());
            assertEquals(InterruptedException.class, ieTrapper2.exception.get().getClass());
        }
    }