Search in sources :

Example 16 with StatusInfo

use of de.codecentric.boot.admin.model.StatusInfo in project spring-boot-admin by codecentric.

the class PagerdutyNotifierTest method test_onApplicationEvent_trigger.

@Test
public void test_onApplicationEvent_trigger() {
    StatusInfo infoDown = StatusInfo.ofDown();
    StatusInfo infoUp = StatusInfo.ofUp();
    notifier.notify(new ClientApplicationStatusChangedEvent(Application.create("App").withId("-id-").withHealthUrl("http://health").build(), infoUp, infoDown));
    Map<String, Object> expected = new HashMap<String, Object>();
    expected.put("service_key", "--service--");
    expected.put("incident_key", "App/-id-");
    expected.put("event_type", "trigger");
    expected.put("description", "App/-id- is DOWN");
    expected.put("client", "TestClient");
    expected.put("client_url", URI.create("http://localhost"));
    Map<String, Object> details = new HashMap<String, Object>();
    details.put("from", infoUp);
    details.put("to", infoDown);
    expected.put("details", details);
    Map<String, Object> context = new HashMap<String, Object>();
    context.put("type", "link");
    context.put("href", "http://health");
    context.put("text", "Application health-endpoint");
    expected.put("contexts", Arrays.asList(context));
    verify(restTemplate).postForEntity(eq(PagerdutyNotifier.DEFAULT_URI), eq(expected), eq(Void.class));
}
Also used : StatusInfo(de.codecentric.boot.admin.model.StatusInfo) HashMap(java.util.HashMap) ClientApplicationStatusChangedEvent(de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent) 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