private void disableNotifications(ServerNotificationManager notificationManager, Map<String, Class<? extends Notification>> eventMap, Map<String, Class<? extends NotificationListener>> interfaceMap) throws InitialisationException { for (NotificationConfig<?, ?> disabledNotification : disabledNotifications) { final Supplier<InitialisationException> noNotificationExceptionSupplier = () -> new InitialisationException(createStaticMessage("No notification '%s' declared in this applications plugins to disable. Expected one of %s", disabledNotification.getEventName(), eventMap.keySet().toString()), this); if (disabledNotification.isInterfaceExplicitlyConfigured()) { notificationManager .disableInterface(getInterfaceClass(disabledNotification, interfaceMap).orElseThrow(noNotificationExceptionSupplier)); } if (disabledNotification.isEventExplicitlyConfigured()) { notificationManager .disableType(getEventClass(disabledNotification, eventMap).orElseThrow(noNotificationExceptionSupplier)); } } }
@Test public void testDynamicResponseToDisablingInterfaces() throws ClassNotFoundException { registerDefaultEvents(); registerDefaultListeners(); assertStandardEventsEnabled(); // now disable listener 1 manager.disableInterface(Listener1.class); assertFalse("via subclass, but no listener", manager.isNotificationEnabled(Event1.class)); assertFalse("disabled", manager.isNotificationEnabled(SubEvent1.class)); assertFalse("via superclass, but no listener", manager.isNotificationEnabled(SubSubEvent1.class)); assertTrue("direct", manager.isNotificationEnabled(Event2.class)); assertTrue("via superclass", manager.isNotificationEnabled(SubEvent2.class)); assertFalse("not specified at all", manager.isNotificationEnabled(Event3.class)); }
private void disableNotifications(ServerNotificationManager notificationManager, Map<String, Class<? extends Notification>> eventMap, Map<String, Class<? extends NotificationListener>> interfaceMap) throws InitialisationException { for (NotificationConfig<?, ?> disabledNotification : disabledNotifications) { final Supplier<InitialisationException> noNotificationExceptionSupplier = () -> new InitialisationException(createStaticMessage("No notification '%s' declared in this applications plugins to disable. Expected one of %s", disabledNotification.getEventName(), eventMap.keySet().toString()), this); if (disabledNotification.isInterfaceExplicitlyConfigured()) { notificationManager .disableInterface(getInterfaceClass(disabledNotification, interfaceMap).orElseThrow(noNotificationExceptionSupplier)); } if (disabledNotification.isEventExplicitlyConfigured()) { notificationManager .disableType(getEventClass(disabledNotification, eventMap).orElseThrow(noNotificationExceptionSupplier)); } } }
@Test public void testDynamicResponseToDisablingInterfaces() throws ClassNotFoundException { registerDefaultEvents(); registerDefaultListeners(); assertStandardEventsEnabled(); // now disable listener 1 manager.disableInterface(Listener1.class); assertFalse("via subclass, but no listener", manager.isNotificationEnabled(Event1.class)); assertFalse("disabled", manager.isNotificationEnabled(SubEvent1.class)); assertFalse("via superclass, but no listener", manager.isNotificationEnabled(SubSubEvent1.class)); assertTrue("direct", manager.isNotificationEnabled(Event2.class)); assertTrue("via superclass", manager.isNotificationEnabled(SubEvent2.class)); assertFalse("not specified at all", manager.isNotificationEnabled(Event3.class)); }