use of io.hops.hopsworks.alerting.config.dto.EmailConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testAddDuplicateReceiver.
@Test
public void testAddDuplicateReceiver() throws AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
List<EmailConfig> emailConfigList = new ArrayList<>();
emailConfigList.add(new EmailConfig("ermias@kth.se"));
Receiver receiver = new Receiver("team-X-mails").withEmailConfigs(emailConfigList);
Assert.assertThrows(AlertManagerDuplicateEntryException.class, () -> {
alertManagerConfigController.addReceiver(receiver);
});
}
use of io.hops.hopsworks.alerting.config.dto.EmailConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testUpdateReceiverRollbackServerException.
@Test
public void testUpdateReceiverRollbackServerException() throws AlertManagerResponseException, AlertManagerServerException, AlertManagerConfigReadException {
Mockito.when(client.reload()).thenThrow(AlertManagerServerException.class);
List<EmailConfig> emailConfigList = new ArrayList<>();
emailConfigList.add(new EmailConfig("team-Z+alerts@example.org"));
Receiver receiver = new Receiver("team-Z-email").withEmailConfigs(emailConfigList);
Assert.assertThrows(AlertManagerServerException.class, () -> {
AlertManagerConfig config = alertManagerConfigController.addReceiver(receiver);
alertManagerConfigController.writeAndReload(config);
});
AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
assert !alertManagerConfig.getReceivers().contains(receiver);
}
use of io.hops.hopsworks.alerting.config.dto.EmailConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testUpdateReceiver.
@Test
public void testUpdateReceiver() throws AlertManagerConfigUpdateException, AlertManagerDuplicateEntryException, AlertManagerNoSuchElementException, AlertManagerConfigReadException, 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-Y-mail").withEmailConfigs(emailConfigList);
AlertManagerConfig config = alertManagerConfigController.updateReceiver("team-Y-mails", receiver);
alertManagerConfigController.writeAndReload(config);
AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
int index = alertManagerConfig.getReceivers().indexOf(receiver);
assert index > -1;
Receiver updatedReceiver = alertManagerConfig.getReceivers().get(index);
assert updatedReceiver.getEmailConfigs().contains(emailConfig);
}
use of io.hops.hopsworks.alerting.config.dto.EmailConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testAddEmailValidation.
@Test
public void testAddEmailValidation() throws AlertManagerResponseException, AlertManagerServerException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
EmailConfig emailConfig = new EmailConfig();
Assert.assertThrows(IllegalArgumentException.class, () -> {
alertManagerConfigController.addEmailToReceiver("team-X-mails", emailConfig);
});
}
use of io.hops.hopsworks.alerting.config.dto.EmailConfig in project hopsworks by logicalclocks.
the class TestAlertManagerConfigController method testAddEmailToReceiver.
@Test
public void testAddEmailToReceiver() throws AlertManagerConfigUpdateException, AlertManagerDuplicateEntryException, AlertManagerNoSuchElementException, AlertManagerResponseException, AlertManagerServerException, AlertManagerConfigReadException {
Mockito.when(client.reload()).thenReturn(Response.ok().build());
EmailConfig emailConfig = new EmailConfig("team-X+alerts@example.org");
Receiver receiver = new Receiver("team-X-mails");
AlertManagerConfig config = alertManagerConfigController.addEmailToReceiver("team-X-mails", emailConfig);
alertManagerConfigController.writeAndReload(config);
AlertManagerConfig alertManagerConfig = this.alertManagerConfigController.read();
int index = alertManagerConfig.getReceivers().indexOf(receiver);
Receiver updatedReceiver = alertManagerConfig.getReceivers().get(index);
assert updatedReceiver.getEmailConfigs().contains(emailConfig);
}
Aggregations