use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class SlackNotifierTest method test_onApplicationEvent_trigger.
@Test
public void test_onApplicationEvent_trigger() {
notifier.setChannel(channel);
notifier.setIcon(icon);
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(INSTANCE.getId(), INSTANCE.getVersion(), StatusInfo.ofUp()))).verifyComplete();
clearInvocations(restTemplate);
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(INSTANCE.getId(), INSTANCE.getVersion(), StatusInfo.ofDown()))).verifyComplete();
Object expected = expectedMessage("danger", user, icon, channel, standardMessage("DOWN"));
verify(restTemplate).postForEntity(any(URI.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 LetsChatNotifierTest 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();
HttpEntity<?> expected = expectedMessage(standardMessage("UP"));
verify(restTemplate).exchange(eq(URI.create(String.format("%s/rooms/%s/messages", host, room))), eq(HttpMethod.POST), eq(expected), eq(Void.class));
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class LetsChatNotifierTest method test_onApplicationEvent_resolve_with_custom_message.
@Test
public void test_onApplicationEvent_resolve_with_custom_message() {
notifier.setMessage("TEST");
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();
HttpEntity<?> expected = expectedMessage("TEST");
verify(restTemplate).exchange(eq(URI.create(String.format("%s/rooms/%s/messages", host, room))), eq(HttpMethod.POST), eq(expected), eq(Void.class));
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class MicrosoftTeamsNotifierTest method test_getStatusChangedMessage_parsesThemeColorFromSpelExpression.
@Test
void test_getStatusChangedMessage_parsesThemeColorFromSpelExpression() {
notifier.setThemeColor("#{event.type == 'STATUS_CHANGED' ? (event.statusInfo.status=='UP' ? 'green' : 'red') : 'blue'}");
Message message = notifier.getStatusChangedMessage(instance, notifier.createEvaluationContext(new InstanceStatusChangedEvent(instance.getId(), 1L, StatusInfo.ofUp()), instance));
assertThat(message.getThemeColor()).isEqualTo("green");
}
use of de.codecentric.boot.admin.server.domain.events.InstanceStatusChangedEvent in project spring-boot-admin by codecentric.
the class TelegramNotifierTest method test_onApplicationEvent_trigger.
@Test
public void test_onApplicationEvent_trigger() {
StatusInfo infoDown = StatusInfo.ofDown();
@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.ofUp()))).verifyComplete();
StepVerifier.create(notifier.notify(new InstanceStatusChangedEvent(instance.getId(), instance.getVersion(), infoDown))).verifyComplete();
verify(restTemplate).getForObject(eq("https://telegram.com/bot--token-/sendmessage?chat_id={chat_id}&text={text}" + "&parse_mode={parse_mode}&disable_notification={disable_notification}"), eq(Void.class), eq(getParameters("DOWN")));
}
Aggregations