use of de.codecentric.boot.admin.model.StatusInfo in project spring-boot-admin by codecentric.
the class SlackNotifierTest method test_onApplicationEvent_resolve_with_given_message.
@Test
public void test_onApplicationEvent_resolve_with_given_message() {
StatusInfo infoDown = StatusInfo.ofDown();
StatusInfo infoUp = StatusInfo.ofUp();
notifier.setMessage(message);
notifier.setChannel(channel);
notifier.setIcon(icon);
notifier.notify(getEvent(infoDown, infoUp));
Object expected = expectedMessage("good", user, icon, channel, message);
verify(restTemplate).postForEntity(any(URI.class), eq(expected), eq(Void.class));
}
use of de.codecentric.boot.admin.model.StatusInfo in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method refresh.
@Test
public void refresh() throws Exception {
// Given application is already reegistered and has status and info.
StatusInfo status = StatusInfo.ofUp();
Info info = Info.from(singletonMap("foo", "bar"));
Application app = Application.create("abc").withHealthUrl("http://localhost:8080/health").withStatusInfo(status).withInfo(info).build();
String id = idGenerator.generateId(app);
store.save(Application.copyOf(app).withId(id).build());
// When application registers second time
Application registered = registry.register(Application.create("abc").withHealthUrl("http://localhost:8080/health").build());
// Then info and status are retained
assertThat(registered.getInfo(), sameInstance(info));
assertThat(registered.getStatusInfo(), sameInstance(status));
}
use of de.codecentric.boot.admin.model.StatusInfo in project spring-boot-admin by codecentric.
the class HipchatNotifierTest method test_onApplicationEvent_resolve.
@Test
public void test_onApplicationEvent_resolve() {
StatusInfo infoDown = StatusInfo.ofDown();
StatusInfo infoUp = StatusInfo.ofUp();
@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((Void) null));
notifier.notify(new ClientApplicationStatusChangedEvent(Application.create("App").withId("-id-").withHealthUrl("http://health").build(), infoDown, infoUp));
assertThat(httpRequest.getValue().getHeaders()).containsEntry("Content-Type", asList("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");
}
use of de.codecentric.boot.admin.model.StatusInfo 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() {
StatusInfo infoDown = StatusInfo.ofDown();
StatusInfo infoUp = StatusInfo.ofUp();
notifier.setMessage("TEST");
notifier.notify(getEvent(infoDown, infoUp));
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.model.StatusInfo in project spring-boot-admin by codecentric.
the class LetsChatNotifierTest method test_onApplicationEvent_resolve.
@Test
public void test_onApplicationEvent_resolve() {
StatusInfo infoDown = StatusInfo.ofDown();
StatusInfo infoUp = StatusInfo.ofUp();
notifier.notify(getEvent(infoDown, infoUp));
HttpEntity<?> expected = expectedMessage(standardMessage(infoUp.getStatus(), appName, id));
verify(restTemplate).exchange(eq(URI.create(String.format("%s/rooms/%s/messages", host, room))), eq(HttpMethod.POST), eq(expected), eq(Void.class));
}
Aggregations