use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class FormattedEmailAlertSenderTest method buildBodyContainsInfoMessageIfWebInterfaceURLIsIncomplete.
@Test
public void buildBodyContainsInfoMessageIfWebInterfaceURLIsIncomplete() throws Exception {
final EmailConfiguration configuration = new EmailConfiguration() {
@Override
public URI getWebInterfaceUri() {
return URI.create("");
}
};
this.emailAlertSender = new FormattedEmailAlertSender(configuration, mockNotificationService, mockNodeId, templateEngine);
Stream stream = mock(Stream.class);
when(stream.getId()).thenReturn("123456");
when(stream.getTitle()).thenReturn("Stream Title");
AlertCondition alertCondition = mock(AlertCondition.class);
AlertCondition.CheckResult checkResult = mock(AbstractAlertCondition.CheckResult.class);
when(checkResult.getTriggeredAt()).thenReturn(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC));
when(checkResult.getTriggeredCondition()).thenReturn(alertCondition);
String body = emailAlertSender.buildBody(stream, checkResult, Collections.<Message>emptyList());
assertThat(body).contains("Stream URL: Please configure 'transport_email_web_interface_url' in your Graylog configuration file.");
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class AlarmCallbackFactoryTest method testCreateByAlarmCallbackConfiguration.
@Test
public void testCreateByAlarmCallbackConfiguration() throws Exception {
AlarmCallbackConfiguration configuration = mock(AlarmCallbackConfiguration.class);
when(configuration.getType()).thenReturn(DummyAlarmCallback.class.getCanonicalName());
AlarmCallback alarmCallback = alarmCallbackFactory.create(configuration);
assertNotNull(alarmCallback);
assertTrue(alarmCallback instanceof DummyAlarmCallback);
assertEquals(dummyAlarmCallback, alarmCallback);
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class EmailAlarmCallbackTest method checkConfigurationFailsWithoutSender.
@Test
public void checkConfigurationFailsWithoutSender() throws Exception {
final Map<String, Object> configMap = ImmutableMap.of("subject", "Graylog alert", "body", "foobar", "user_receivers", Collections.emptyList(), "email_receivers", Collections.emptyList());
final Configuration configuration = new Configuration(configMap);
alarmCallback.initialize(configuration);
when(emailConfiguration.getFromEmail()).thenReturn("");
expectedException.expect(ConfigurationException.class);
expectedException.expectMessage("Sender or subject are missing or invalid.");
alarmCallback.checkConfiguration();
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class EmailAlarmCallbackTest method checkConfigurationSucceedsWithValidConfiguration.
@Test
public void checkConfigurationSucceedsWithValidConfiguration() throws Exception {
final Map<String, Object> configMap = ImmutableMap.of("sender", "graylog@example.org", "subject", "Graylog alert", "body", "foobar", "user_receivers", Collections.emptyList(), "email_receivers", Collections.emptyList());
final Configuration configuration = new Configuration(configMap);
alarmCallback.initialize(configuration);
alarmCallback.checkConfiguration();
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class HTTPAlarmCallbackTest method checkConfigurationSucceedsWithValidConfiguration.
@Test
public void checkConfigurationSucceedsWithValidConfiguration() throws Exception {
final Map<String, Object> configMap = ImmutableMap.of("url", "http://example.com/");
final Configuration configuration = new Configuration(configMap);
alarmCallback.initialize(configuration);
alarmCallback.checkConfiguration();
}
Aggregations