### Question:
WebsocketProcessorEventsSource { @EventListener public void on(EventProcessorStatusUpdate event) { updates.set(true); } @Autowired  WebsocketProcessorEventsSource(SimpMessagingTemplate websocket);  WebsocketProcessorEventsSource(Runnable updatesConsumer); @Scheduled(initialDelayString = "${axoniq.axonserver.websocket-update.initial-delay:10000}", fixedRateString = "${axoniq.axonserver.websocket-update.rate:1000}") void applyIfUpdates(); @EventListener void on(EventProcessorStatusUpdate event);  }### Answer:
@Test public void on() throws InterruptedException { AtomicInteger triggers = new AtomicInteger(); WebsocketProcessorEventsSource testSubject = new WebsocketProcessorEventsSource(() -> { triggers.incrementAndGet(); }); ScheduledFuture<?> scheduler = Executors.newSingleThreadScheduledExecutor() .scheduleAtFixedRate(testSubject::applyIfUpdates, 10, 10, TimeUnit.MILLISECONDS); testSubject.on(new EventProcessorEvents.EventProcessorStatusUpdate(null)); testSubject.on(new EventProcessorEvents.EventProcessorStatusUpdate(null)); testSubject.on(new EventProcessorEvents.EventProcessorStatusUpdate(null)); testSubject.on(new EventProcessorEvents.EventProcessorStatusUpdate(null)); testSubject.on(new EventProcessorEvents.EventProcessorStatusUpdate(null)); Thread.sleep(20); assertEquals(1, triggers.get()); testSubject.on(new EventProcessorEvents.EventProcessorStatusUpdate(null)); Thread.sleep(15); assertEquals(2, triggers.get()); scheduler.cancel(false); }
@Test public void onExecption() throws InterruptedException { AtomicInteger triggers = new AtomicInteger(); WebsocketProcessorEventsSource testSubject = new WebsocketProcessorEventsSource(() -> { if (triggers.getAndIncrement() == 5) { throw new IllegalArgumentException("Failed"); } }); ScheduledFuture<?> scheduler = Executors.newSingleThreadScheduledExecutor() .scheduleAtFixedRate(testSubject::applyIfUpdates, 50, 50, TimeUnit.MILLISECONDS); for (int run = 0; run < 10; run++) { IntStream.range(0, 1000).parallel().forEach(i -> testSubject .on(new EventProcessorEvents.EventProcessorStatusUpdate(null))); Thread.sleep(100); } assertEquals(10, triggers.get()); scheduler.cancel(false); }