Search in sources :

Example 6 with SlackConfig

use of io.hops.hopsworks.alerting.config.dto.SlackConfig in project hopsworks by logicalclocks.

the class TestAlertManagerConfigController method testAddSlackToReceiver.

@Test
public void testAddSlackToReceiver() throws AlertManagerConfigUpdateException, AlertManagerDuplicateEntryException, AlertManagerNoSuchElementException, AlertManagerConfigReadException, AlertManagerResponseException, AlertManagerServerException {
    Mockito.when(client.reload()).thenReturn(Response.ok().build());
    SlackConfig slackConfig = new SlackConfig("https://hooks.slack.com/services/1234567890/0987654321", "#general").withIconEmoji("https://gravatar.com/avatar/e3fb1c1d58b043af5e3a6a645b7f569f").withTitle("{{ template \"hopsworks.title\" . }}").withText("{{ template \"hopsworks.text\" . }}");
    Receiver receiver = new Receiver("slack_general");
    AlertManagerConfig config = alertManagerConfigController.addSlackToReceiver("slack_general", slackConfig);
    alertManagerConfigController.writeAndReload(config);
    AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
    int index = alertManagerConfig.getReceivers().indexOf(receiver);
    Receiver updatedReceiver = alertManagerConfig.getReceivers().get(index);
    assert updatedReceiver.getSlackConfigs().contains(slackConfig);
}
Also used : SlackConfig(io.hops.hopsworks.alerting.config.dto.SlackConfig) AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig) Receiver(io.hops.hopsworks.alerting.config.dto.Receiver) Test(org.junit.Test)

Aggregations

SlackConfig (io.hops.hopsworks.alerting.config.dto.SlackConfig)6 Test (org.junit.Test)5 Receiver (io.hops.hopsworks.alerting.config.dto.Receiver)4 AlertManagerConfig (io.hops.hopsworks.alerting.config.dto.AlertManagerConfig)3 ArrayList (java.util.ArrayList)2 EmailConfig (io.hops.hopsworks.alerting.config.dto.EmailConfig)1 PagerdutyConfig (io.hops.hopsworks.alerting.config.dto.PagerdutyConfig)1 AlertReceiver (io.hops.hopsworks.persistence.entity.alertmanager.AlertReceiver)1