use of org.graylog.events.event.TestEvent 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.event.TestEvent 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.event.TestEvent 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();
}
use of org.graylog.events.event.TestEvent in project graylog2-server by Graylog2.
the class NotificationGracePeriodServiceTest method insideOutsideInsideGracePeriod.
@Test
public void insideOutsideInsideGracePeriod() {
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(DateTime.now(UTC), "testkey");
final Event event2 = new TestEvent(event.getEventTimestamp().plus(5L), "testkey");
final Event event3 = new TestEvent(event2.getEventTimestamp().plus(6L), "testkey");
final Event event4 = new TestEvent(event3.getEventTimestamp().plus(6L), "testkey");
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event)).isFalse();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event2)).isTrue();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event3)).isFalse();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event4)).isTrue();
}
use of org.graylog.events.event.TestEvent in project graylog2-server by Graylog2.
the class NotificationGracePeriodServiceTest method differentNotification.
@Test
public void differentNotification() {
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(1L));
assertThat(notificationGracePeriodService.inGracePeriod(definition, "5678", event)).isFalse();
assertThat(notificationGracePeriodService.inGracePeriod(definition, "4242", event2)).isFalse();
}
Aggregations