Search in sources :

Example 6 with StatusInfo

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"));
}
Also used : Serializable(java.io.Serializable) StatusInfo(de.codecentric.boot.admin.model.StatusInfo) Application(de.codecentric.boot.admin.model.Application) Map(java.util.Map) Test(org.junit.Test)

Example 7 with StatusInfo

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"));
}
Also used : Serializable(java.io.Serializable) StatusInfo(de.codecentric.boot.admin.model.StatusInfo) Application(de.codecentric.boot.admin.model.Application) Test(org.junit.Test)

Example 8 with StatusInfo

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"));
}
Also used : Serializable(java.io.Serializable) StatusInfo(de.codecentric.boot.admin.model.StatusInfo) Application(de.codecentric.boot.admin.model.Application) ResourceAccessException(org.springframework.web.client.ResourceAccessException) Test(org.junit.Test)

Example 9 with StatusInfo

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));
}
Also used : StatusInfo(de.codecentric.boot.admin.model.StatusInfo) URI(java.net.URI) Test(org.junit.Test)

Example 10 with StatusInfo

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));
}
Also used : StatusInfo(de.codecentric.boot.admin.model.StatusInfo) URI(java.net.URI) Test(org.junit.Test)

Aggregations

StatusInfo (de.codecentric.boot.admin.model.StatusInfo)16 Test (org.junit.Test)15 ClientApplicationStatusChangedEvent (de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent)5 Application (de.codecentric.boot.admin.model.Application)5 URI (java.net.URI)5 Serializable (java.io.Serializable)3 HashMap (java.util.HashMap)2 HttpEntity (org.springframework.http.HttpEntity)2 Info (de.codecentric.boot.admin.model.Info)1 Map (java.util.Map)1 ResourceAccessException (org.springframework.web.client.ResourceAccessException)1