NotificationListenerService implements ListenerService { @Override public <T extends Event> Stream<EventListenerSupplier<T>> findListeners(final SessionInfo sessionInfo, final Class<T> eventType) { return Stream.of(Target.values()) .map(target -> getEventListenerSupplier(sessionInfo, eventType, target)); }  @Override Stream<EventListenerSupplier<T>> findListeners(final SessionInfo sessionInfo,
            final Class<T> eventType);  }
@Test void noConfigs() { final ListenerService s = new NotificationListenerService(); assertThat(s.findListeners(SESSION, RoboZonkyTestingEvent.class)) .hasSize(1) .first() .returns(Optional.empty(), Supplier::get); }
@Test void noValidConfigs() { ListenerServiceLoader.registerConfiguration(SESSION, "invalid-url"); final ListenerService s = new NotificationListenerService(); assertThat(s.findListeners(SESSION, RoboZonkyTestingEvent.class)) .hasSize(1) .first() .returns(Optional.empty(), Supplier::get); }
@Test void validConfigs() throws IOException { final Path path = Files.createTempFile("robozonky-", ".cfg"); try (InputStream s = getClass().getResourceAsStream("listeners/notifications-enabled.cfg")) { Files.write(path, s.readAllBytes()); } ListenerServiceLoader.registerConfiguration(SESSION, path.toUri() .toURL()); final ListenerService s = new NotificationListenerService(); assertThat(s.findListeners(SESSION, RoboZonkyTestingEvent.class)) .hasSize(1) .first() .extracting(Supplier::get) .extracting(Optional::isPresent) .isEqualTo(true); }