use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class EndpointDetectionTriggerTest method should_continue_detection_after_error.
@Test
public void should_continue_detection_after_error() throws InterruptedException {
// when status-change event is emitted and an error is emitted
when(this.detector.detectEndpoints(any())).thenReturn(Mono.error(IllegalStateException::new)).thenReturn(Mono.empty());
this.events.next(new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofDown()));
this.events.next(new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofUp()));
// then should update
verify(this.detector, times(2)).detectEndpoints(this.instance.getId());
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class DingTalkNotifierTest method test_onApplicationEvent_trigger.
@Test
public void test_onApplicationEvent_trigger() {
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofUp()))).verifyComplete();
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofDown()))).verifyComplete();
Object expected = expectedMessage(standardMessage("DOWN"));
verify(restTemplate).postForEntity(any(String.class), eq(expected), eq(Void.class));
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class DingTalkNotifierTest method test_onApplicationEvent_resolve.
@Test
public void test_onApplicationEvent_resolve() {
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofDown()))).verifyComplete();
clearInvocations(restTemplate);
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofUp()))).verifyComplete();
Object expected = expectedMessage(standardMessage("UP"));
verify(restTemplate).postForEntity(any(String.class), eq(expected), eq(Void.class));
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class HazelcastNotificationTriggerTest method should_not_trigger_notifications.
@Test
void should_not_trigger_notifications() {
// given the event is in the already sent notifications.
InstanceStatusChangedEvent event = new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofDown());
this.sentNotifications.put(event.getInstance(), event.getVersion());
this.trigger.start();
await().until(this.events::wasSubscribed);
// when registered event is emitted
this.events.next(event);
// then should not notify
verify(this.notifier, never()).notify(event);
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class HipchatNotifierTest method test_onApplicationEvent_resolve.
@Test
public void test_onApplicationEvent_resolve() {
@SuppressWarnings("unchecked") ArgumentCaptor<HttpEntity<Map<String, Object>>> httpRequest = ArgumentCaptor.forClass((Class<HttpEntity<Map<String, Object>>>) (Class<?>) HttpEntity.class);
when(restTemplate.postForEntity(isA(String.class), httpRequest.capture(), eq(Void.class))).thenReturn(ResponseEntity.ok().build());
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofDown()))).verifyComplete();
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofUp()))).verifyComplete();
assertThat(httpRequest.getValue().getHeaders()).containsEntry("Content-Type", Collections.singletonList("application/json"));
Map<String, Object> body = httpRequest.getValue().getBody();
assertThat(body).containsEntry("color", "green");
assertThat(body).containsEntry("message", "<strong>App</strong>/-id- is <strong>UP</strong>");
assertThat(body).containsEntry("notify", Boolean.TRUE);
assertThat(body).containsEntry("message_format", "html");
}
Aggregations