use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class MailNotifierTest method should_not_send_mail_when_disabled.
// The following tests are rather for AbstractNotifier
@Test
public void should_not_send_mail_when_disabled() {
notifier.setEnabled(false);
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofUp()))).verifyComplete();
verifyNoMoreInteractions(sender);
}
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_custom_template_with_additional_properties.
@Test
public void should_send_mail_using_custom_template_with_additional_properties() throws IOException, MessagingException {
notifier.setTemplate("/de/codecentric/boot/admin/server/notify/custom-mail.html");
notifier.getAdditionalProperties().put("customProperty", "HELLO WORLD!");
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofDown()))).verifyComplete();
ArgumentCaptor<MimeMessage> mailCaptor = ArgumentCaptor.forClass(MimeMessage.class);
verify(sender).send(mailCaptor.capture());
MimeMessage mail = mailCaptor.getValue();
String body = extractBody(mail.getDataHandler());
assertThat(body).isEqualTo(loadExpectedBody("expected-custom-mail"));
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class MailNotifierTest method should_not_send_on_wildcard_ignore.
@Test
public void should_not_send_on_wildcard_ignore() {
notifier.setIgnoreChanges(new String[] { "*:UP" });
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), StatusInfo.ofUp()))).verifyComplete();
verifyNoMoreInteractions(sender);
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class NotificationTriggerTest method should_resume_on_exceptopn.
@Test
public void should_resume_on_exceptopn() throws InterruptedException {
// given
this.trigger.start();
await().until(this.events::wasSubscribed);
when(this.notifier.notify(any())).thenReturn(Mono.error(new IllegalStateException("Test"))).thenReturn(Mono.empty());
// when exception for the first event is thrown and a subsequent event is fired
InstanceStatusChangedEvent event = new InstanceStatusChangedEvent(this.instance.getId(), this.instance.getVersion(), StatusInfo.ofDown());
this.events.next(event);
this.events.next(event);
// the notifier was after the exception
verify(this.notifier, times(2)).notify(event);
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class SlackNotifierTest method test_onApplicationEvent_resolve_with_given_user.
@Test
public void test_onApplicationEvent_resolve_with_given_user() {
String anotherUser = "another user";
notifier.setUsername(anotherUser);
notifier.setChannel(channel);
notifier.setIcon(icon);
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("good", anotherUser, icon, channel, standardMessage("UP"));
verify(restTemplate).postForEntity(any(URI.class), eq(expected), eq(Void.class));
}
Aggregations