@Test public void message_invokesWebhook() throws Exception { notifier.onApplicationEvent(mock(ApplicationReadyEvent.class)); webhook.enqueue(new MockResponse()); String json = notifierConfig.objectMapper().writeValueAsString(newMappedMetricData()); kafka.helper().produceStrings(notifierConfig.getKafkaTopic(), json); RecordedRequest webhookRequest = webhook.takeRequest(); Assertions.assertThat(webhookRequest.getMethod()) .isEqualTo("POST"); Assertions.assertThat(webhookRequest.getBody().readUtf8()) .isEqualTo(json); }
@Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); }
Notifier implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); } }
Notifier implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); } @Autowired  Notifier(NotifierConfig notifierConfig, ObjectMapper objectMapper, RestTemplate restTemplate); }
Notifier implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); } @Autowired  Notifier(NotifierConfig notifierConfig, ObjectMapper objectMapper, RestTemplate restTemplate); @PreDestroy void stopLooperThread(); @Override void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent); }
Notifier implements ApplicationListener<ApplicationReadyEvent> { @Override public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { if (!running.compareAndSet(false, true)) return; Thread notifyLoop = new Thread(this::loopUntilShutdown); notifyLoop.setName("adaptivealerting notify loop"); notifyLoop.setDaemon(true); notifyLoop.start(); } @Autowired  Notifier(NotifierConfig notifierConfig, ObjectMapper objectMapper, RestTemplate restTemplate); @PreDestroy void stopLooperThread(); @Override void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent);  }