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);
}
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);
});
}
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);
});
}
Aggregations