NotificationBus { protected boolean isNotificationRegistered(Class<?> notification) { Lock lock = rwLock.readLock(); try { lock.lock(); if (registeredNotifications.containsKey(notification)) { return true; } Boolean result = cacheOfImpliedNotifications.get(notification); if (result != null) { return result; } } finally { lock.unlock(); } return isParentOfNotificationRegistered(notification); } protected  NotificationBus(Class<N> notificationClass); void clearAllHandlers(); void broadcast(N notification); void clearThread(); @Override String toString(); static final String NOTIFICATION_BUS_ID; }
@Test public void testIsNotificationRegistered() { NotificationBus<Notification> bus = new TestBus(); NotificationHandler handler = new NotificationHandler(); bus.addHandler(handler); Assertions.assertTrue(bus.isNotificationRegistered(Notification.class)); Assertions.assertTrue(bus.isNotificationRegistered(TestOneNotification.class)); Assertions.assertTrue(bus.hasCorrectType(Notification.class)); Assertions.assertTrue(bus.hasCorrectType(TestOneNotification.class)); bus.broadcast(new TestOneNotification()); Assertions.assertTrue(handler.handled); }