use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class AlertServiceImplTest method loadRecentOfStreamsFiltersByStream.
@Test
@MongoDBFixtures("multiple-alerts.json")
public void loadRecentOfStreamsFiltersByStream() throws Exception {
final List<Alert> alerts = alertService.loadRecentOfStreams(ImmutableList.of("5666df42bee80072613ce14d", "5666df42bee80072613ce14f"), new DateTime(0L, DateTimeZone.UTC), 300);
assertThat(alerts.size()).isEqualTo(2);
assertThat(alerts.get(0).getStreamId()).isNotEqualTo(STREAM_ID);
assertThat(alerts.get(1).getStreamId()).isNotEqualTo(STREAM_ID);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class AlertServiceImplTest method nonIntervalAlertShouldNotRepeatNotifications.
@Test
@MongoDBFixtures("non-interval-alert.json")
public void nonIntervalAlertShouldNotRepeatNotifications() throws Exception {
final AlertCondition alertCondition = mock(AlertCondition.class);
when(alertCondition.shouldRepeatNotifications()).thenReturn(true);
final Alert alert = alertService.load(ALERT_ID, STREAM_ID);
assertThat(alertService.shouldRepeatNotifications(alertCondition, alert)).isFalse();
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class AlertServiceImplTest method loadRecentOfStreamsLimitsResults.
@Test
@MongoDBFixtures("multiple-alerts.json")
public void loadRecentOfStreamsLimitsResults() throws Exception {
final List<Alert> alerts = alertService.loadRecentOfStreams(ImmutableList.of("5666df42bee80072613ce14d", "5666df42bee80072613ce14e", "5666df42bee80072613ce14f"), new DateTime(0L, DateTimeZone.UTC), 1);
assertThat(alerts.size()).isEqualTo(1);
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class AlertServiceImplTest method shouldRepeatNotificationsWhenOptionIsEnabled.
@Test
@MongoDBFixtures("unresolved-alert.json")
public void shouldRepeatNotificationsWhenOptionIsEnabled() throws Exception {
final AlertCondition alertCondition = mock(AlertCondition.class);
when(alertCondition.shouldRepeatNotifications()).thenReturn(true);
final Alert alert = alertService.load(ALERT_ID, STREAM_ID);
assertThat(alertService.shouldRepeatNotifications(alertCondition, alert)).isTrue();
}
use of org.graylog.testing.mongodb.MongoDBFixtures in project graylog2-server by Graylog2.
the class NodeServiceImplTest method testRegisterServerWithExistingNode.
@Test
@MongoDBFixtures("NodeServiceImplTest-one-node.json")
public void testRegisterServerWithExistingNode() throws Exception {
final Node node1 = nodeService.byNodeId(nodeId);
assertThat(node1.getNodeId()).describedAs("There should be one existing node").isEqualTo(NODE_ID);
nodeService.registerServer(nodeId.toString(), true, TRANSPORT_URI, LOCAL_CANONICAL_HOSTNAME);
@SuppressWarnings("deprecation") final DBCollection collection = mongodb.mongoConnection().getDatabase().getCollection("nodes");
assertThat(collection.count()).describedAs("There should only be one node").isEqualTo(1);
final Node node2 = nodeService.byNodeId(nodeId);
assertThat(node2).isNotNull();
assertThat(node2.getHostname()).isEqualTo(LOCAL_CANONICAL_HOSTNAME);
assertThat(node2.getTransportAddress()).isEqualTo(TRANSPORT_URI.toString());
assertThat(node2.isLeader()).isTrue();
}
Aggregations