TimedMessageListTrap implements Subscriber { public ImmutableList<TimedMessage<T>> getCapturedNotifications() { return ImmutableList.copyOf(trappedNotifications); } private  TimedMessageListTrap(Class<T> type, TimeProvider timeProvider, EventSchedulerType schedulerType); static TimedMessageListTrap<T> createAndSubscribe(Class<T> type, TimeProvider timeProvider, EventSchedulerType schedulerType); @Subscribe void anyNotificationOfType(T n); ImmutableList<TimedMessage<T>> getCapturedNotifications(); @Override EventSchedulerType getSchedulerType();  }
@Test public void getCapturedNotifications() { TimedMessageListTrap<TestNotification> trap = TimedMessageListTrap.createAndSubscribe(TestNotification.class, new MockTimeProvider(), TestSchedulerType.TEST_SCHEDULER_TYPE); NotificationRouter.get().broadcast(new TestNotification()); NotificationRouter.get().broadcast(new TestNotification()); NotificationRouter.get().broadcast(new TestNotification()); Assertions.assertEquals(3, trap.getCapturedNotifications().size(), "Expected 3 Notifications"); Assertions.assertEquals(0.0, trap.getCapturedNotifications().get(0).time, 0.1); Assertions.assertEquals(1.0, trap.getCapturedNotifications().get(1).time, 0.1); Assertions.assertEquals(2.0, trap.getCapturedNotifications().get(2).time, 0.1); }