use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class MailNotifierTest method should_send_mail_using_default_template.
@Test
public void should_send_mail_using_default_template() throws IOException, MessagingException {
Map<String, Object> details = new HashMap<>();
details.put("Simple Value", 1234);
details.put("Complex Value", singletonMap("Nested Simple Value", "99!"));
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofDown(details)))).verifyComplete();
ArgumentCaptor<MimeMessage> mailCaptor = ArgumentCaptor.forClass(MimeMessage.class);
verify(sender).send(mailCaptor.capture());
MimeMessage mail = mailCaptor.getValue();
assertThat(mail.getSubject()).isEqualTo("application-name (cafebabe) is DOWN");
assertThat(mail.getRecipients(Message.RecipientType.TO)).containsExactly(new InternetAddress("foo@bar.com"));
assertThat(mail.getRecipients(Message.RecipientType.CC)).containsExactly(new InternetAddress("bar@foo.com"));
assertThat(mail.getFrom()).containsExactly(new InternetAddress("SBA <no-reply@example.com>"));
assertThat(mail.getDataHandler().getContentType()).isEqualTo("text/html;charset=UTF-8");
String body = extractBody(mail.getDataHandler());
assertThat(body).isEqualTo(loadExpectedBody("expected-default-mail"));
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class EndpointDetectionTriggerTest method should_detect_on_status_changed.
@Test
public void should_detect_on_status_changed() {
// when status-change event is emitted
this.events.next(new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofDown()));
// then should update
verify(this.detector, times(1)).detectEndpoints(this.instance.getId());
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class HazelcastNotificationTriggerTest method should_trigger_notifications.
@Test
void should_trigger_notifications() {
// given then notifier has subscribed to the events and no notification was sent
// before
this.sentNotifications.clear();
this.trigger.start();
await().until(this.events::wasSubscribed);
// when registered event is emitted
InstanceStatusChangedEvent event = new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofDown());
this.events.next(event);
// then should notify
verify(this.notifier, times(1)).notify(event);
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class MailNotifierTest method should_not_propagate_error.
@Test
public void should_not_propagate_error() {
Notifier notifier = new AbstractStatusChangeNotifier(repository) {
@Override
protected Mono<Void> doNotify(InstanceEvent event, Instance application) {
return Mono.error(new IllegalStateException("test"));
}
};
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofUp()))).verifyComplete();
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class MailNotifierTest method should_not_send_when_unknown_to_up.
@Test
public void should_not_send_when_unknown_to_up() {
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofUp()))).verifyComplete();
verifyNoMoreInteractions(sender);
}
Aggregations