Search in sources :

Example 11 with EmailConfig

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

the class TestAlertManagerConfigController method testRemoveEmailFromReceiver.

@Test
public void testRemoveEmailFromReceiver() throws AlertManagerNoSuchElementException, AlertManagerConfigReadException, AlertManagerConfigUpdateException, AlertManagerResponseException, AlertManagerServerException {
    Mockito.when(client.reload()).thenReturn(Response.ok().build());
    EmailConfig emailConfig = new EmailConfig("team-X@example.se");
    Receiver receiver = new Receiver("team-X-mails");
    AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
    int index = alertManagerConfig.getReceivers().indexOf(receiver);
    Receiver updatedReceiver = alertManagerConfig.getReceivers().get(index);
    assert updatedReceiver.getEmailConfigs().contains(emailConfig);
    AlertManagerConfig config = alertManagerConfigController.removeEmailFromReceiver("team-X-mails", emailConfig);
    alertManagerConfigController.writeAndReload(config);
    alertManagerConfig = this.alertManagerConfigController.read();
    index = alertManagerConfig.getReceivers().indexOf(receiver);
    updatedReceiver = alertManagerConfig.getReceivers().get(index);
    assert !updatedReceiver.getEmailConfigs().contains(emailConfig);
}
Also used : AlertManagerConfig(io.hops.hopsworks.alerting.config.dto.AlertManagerConfig) EmailConfig(io.hops.hopsworks.alerting.config.dto.EmailConfig) Receiver(io.hops.hopsworks.alerting.config.dto.Receiver) Test(org.junit.Test)

Example 12 with EmailConfig

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

the class TestAlertManagerConfigController method testAddDuplicateEmailToReceiver.

@Test
public void testAddDuplicateEmailToReceiver() throws AlertManagerResponseException, AlertManagerServerException {
    Mockito.when(client.reload()).thenReturn(Response.ok().build());
    EmailConfig emailConfig = new EmailConfig("team-X@example.se");
    Assert.assertThrows(AlertManagerDuplicateEntryException.class, () -> {
        alertManagerConfigController.addEmailToReceiver("team-X-mails", emailConfig);
    });
}
Also used : EmailConfig(io.hops.hopsworks.alerting.config.dto.EmailConfig) Test(org.junit.Test)

Example 13 with EmailConfig

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

the class TestAlertManagerConfigController method testUpdateReceiverDuplicate.

@Test
public void testUpdateReceiverDuplicate() throws AlertManagerResponseException, AlertManagerServerException {
    Mockito.when(client.reload()).thenReturn(Response.ok().build());
    EmailConfig emailConfig = new EmailConfig("team-Y+alerts@example.org");
    List<EmailConfig> emailConfigList = new ArrayList<>();
    emailConfigList.add(emailConfig);
    Receiver receiver = new Receiver("team-X-mails").withEmailConfigs(emailConfigList);
    Assert.assertThrows(AlertManagerDuplicateEntryException.class, () -> {
        alertManagerConfigController.updateReceiver("team-Y-mails", receiver);
    });
}
Also used : EmailConfig(io.hops.hopsworks.alerting.config.dto.EmailConfig) ArrayList(java.util.ArrayList) Receiver(io.hops.hopsworks.alerting.config.dto.Receiver) Test(org.junit.Test)

Aggregations

EmailConfig (io.hops.hopsworks.alerting.config.dto.EmailConfig)13 Test (org.junit.Test)11 Receiver (io.hops.hopsworks.alerting.config.dto.Receiver)10 ArrayList (java.util.ArrayList)8 AlertManagerConfig (io.hops.hopsworks.alerting.config.dto.AlertManagerConfig)6 PagerdutyConfig (io.hops.hopsworks.alerting.config.dto.PagerdutyConfig)1 SlackConfig (io.hops.hopsworks.alerting.config.dto.SlackConfig)1 Entry (io.hops.hopsworks.api.alert.Entry)1 AlertReceiver (io.hops.hopsworks.persistence.entity.alertmanager.AlertReceiver)1