use of org.graylog.events.notifications.NotificationGracePeriodService in project graylog2-server by Graylog2.
the class NotificationGracePeriodServiceTest method emptyKey.
@Test
public void emptyKey() {
final NotificationGracePeriodService notificationGracePeriodService = new NotificationGracePeriodService();
when(settings.gracePeriodMs()).thenReturn(10L);
when(definition.notificationSettings()).thenReturn(settings);
when(definition.id()).thenReturn("1234");
final Event event = new TestEvent();
event.setKeyTuple(ImmutableList.of());
final Event event2 = new TestEvent();
event.setKeyTuple(ImmutableList.of());
event2.setEventTimestamp(event.getEventTimestamp().plus(1L));
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event)).isFalse();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event2)).isTrue();
}
use of org.graylog.events.notifications.NotificationGracePeriodService in project graylog2-server by Graylog2.
the class NotificationGracePeriodServiceTest method falseWithDisabledGracePeriod.
@Test
public void falseWithDisabledGracePeriod() {
final NotificationGracePeriodService notificationGracePeriodService = new NotificationGracePeriodService();
when(settings.gracePeriodMs()).thenReturn(0L);
when(definition.notificationSettings()).thenReturn(settings);
when(definition.id()).thenReturn("1234");
final Event event = new TestEvent();
event.setKeyTuple(ImmutableList.of("testkey"));
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event)).isFalse();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event)).isFalse();
}
use of org.graylog.events.notifications.NotificationGracePeriodService in project graylog2-server by Graylog2.
the class NotificationGracePeriodServiceTest method differentKey.
@Test
public void differentKey() {
final NotificationGracePeriodService notificationGracePeriodService = new NotificationGracePeriodService();
when(settings.gracePeriodMs()).thenReturn(10L);
when(definition.notificationSettings()).thenReturn(settings);
when(definition.id()).thenReturn("1234");
final Event event = new TestEvent();
event.setKeyTuple(ImmutableList.of("testkey"));
final Event event2 = new TestEvent();
event2.setKeyTuple(ImmutableList.of("otherkey"));
event2.setEventTimestamp(event.getEventTimestamp().plus(1L));
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event)).isFalse();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event2)).isFalse();
}
use of org.graylog.events.notifications.NotificationGracePeriodService in project graylog2-server by Graylog2.
the class NotificationGracePeriodServiceTest method withinGracePeriod.
@Test
public void withinGracePeriod() {
final NotificationGracePeriodService notificationGracePeriodService = new NotificationGracePeriodService();
when(settings.gracePeriodMs()).thenReturn(10L);
when(definition.notificationSettings()).thenReturn(settings);
when(definition.id()).thenReturn("1234");
final Event event = new TestEvent();
event.setKeyTuple(ImmutableList.of("testkey"));
final Event event2 = new TestEvent();
event2.setKeyTuple(ImmutableList.of("testkey"));
event2.setEventTimestamp(event.getEventTimestamp().plus(5L));
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event)).isFalse();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event2)).isTrue();
}
use of org.graylog.events.notifications.NotificationGracePeriodService in project graylog2-server by Graylog2.
the class NotificationGracePeriodServiceTest method outsideGracePeriod.
@Test
public void outsideGracePeriod() {
final NotificationGracePeriodService notificationGracePeriodService = new NotificationGracePeriodService();
when(settings.gracePeriodMs()).thenReturn(10L);
when(definition.notificationSettings()).thenReturn(settings);
when(definition.id()).thenReturn("1234");
final Event event = new TestEvent();
event.setKeyTuple(ImmutableList.of("testkey"));
final Event event2 = new TestEvent();
event2.setKeyTuple(ImmutableList.of("testkey"));
event2.setEventTimestamp(event.getEventTimestamp().plus(11L));
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event)).isFalse();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event2)).isFalse();
}
Aggregations