use of de.codecentric.boot.admin.model.StatusInfo in project spring-boot-admin by codecentric.
the class StatusUpdaterTest method test_update_down_noBody.
@Test
public void test_update_down_noBody() {
when(applicationOps.getHealth(any(Application.class))).thenReturn(ResponseEntity.status(503).body((Map<String, Serializable>) null));
updater.updateStatus(Application.create("foo").withId("id").withHealthUrl("health").build());
StatusInfo statusInfo = store.find("id").getStatusInfo();
assertThat(statusInfo.getStatus(), CoreMatchers.is("DOWN"));
assertThat(statusInfo.getDetails(), hasEntry("status", (Serializable) 503));
assertThat(statusInfo.getDetails(), hasEntry("error", (Serializable) "Service Unavailable"));
}
use of de.codecentric.boot.admin.model.StatusInfo in project spring-boot-admin by codecentric.
the class StatusUpdaterTest method test_update_down.
@Test
public void test_update_down() {
when(applicationOps.getHealth(any(Application.class))).thenReturn(ResponseEntity.status(503).body(Collections.<String, Serializable>singletonMap("foo", "bar")));
updater.updateStatus(Application.create("foo").withId("id").withHealthUrl("health").build());
StatusInfo statusInfo = store.find("id").getStatusInfo();
assertThat(statusInfo.getStatus(), CoreMatchers.is("DOWN"));
assertThat(statusInfo.getDetails(), hasEntry("foo", (Serializable) "bar"));
}
use of de.codecentric.boot.admin.model.StatusInfo in project spring-boot-admin by codecentric.
the class StatusUpdaterTest method test_update_offline.
@Test
public void test_update_offline() {
when(applicationOps.getHealth(any(Application.class))).thenThrow(new ResourceAccessException("error"));
Application app = Application.create("foo").withId("id").withHealthUrl("health").withStatusInfo(StatusInfo.ofUp()).build();
updater.updateStatus(app);
StatusInfo statusInfo = store.find("id").getStatusInfo();
assertThat(statusInfo.getStatus(), CoreMatchers.is("OFFLINE"));
assertThat(statusInfo.getDetails(), hasEntry("message", (Serializable) "error"));
assertThat(statusInfo.getDetails(), hasEntry("exception", (Serializable) "org.springframework.web.client.ResourceAccessException"));
}
use of de.codecentric.boot.admin.model.StatusInfo 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() {
StatusInfo infoDown = StatusInfo.ofDown();
StatusInfo infoUp = StatusInfo.ofUp();
String anotherUser = "another user";
notifier.setUsername(anotherUser);
notifier.setChannel(channel);
notifier.setIcon(icon);
notifier.notify(getEvent(infoDown, infoUp));
Object expected = expectedMessage("good", anotherUser, icon, channel, standardMessage(infoUp.getStatus(), appName, id));
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 SlackNotifierTest method test_onApplicationEvent_resolve.
@Test
public void test_onApplicationEvent_resolve() {
StatusInfo infoDown = StatusInfo.ofDown();
StatusInfo infoUp = StatusInfo.ofUp();
notifier.setChannel(channel);
notifier.setIcon(icon);
notifier.notify(getEvent(infoDown, infoUp));
Object expected = expectedMessage("good", user, icon, channel, standardMessage(infoUp.getStatus(), appName, id));
verify(restTemplate).postForEntity(any(URI.class), eq(expected), eq(Void.class));
}
Aggregations