use of org.graylog2.system.debug.DebugEvent in project graylog2-server by Graylog2.
the class ClusterEventPeriodicalTest method publishClusterEventHandlesAutoValueCorrectly.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void publishClusterEventHandlesAutoValueCorrectly() throws Exception {
DBCollection collection = mongoConnection.getDatabase().getCollection(ClusterEventPeriodical.COLLECTION_NAME);
DebugEvent event = DebugEvent.create("Node ID", "Test");
assertThat(collection.count()).isEqualTo(0L);
clusterEventPeriodical.publishClusterEvent(event);
verify(clusterEventBus, never()).post(any());
assertThat(collection.count()).isEqualTo(1L);
DBObject dbObject = collection.findOne();
assertThat((String) dbObject.get("producer")).isEqualTo(nodeId.toString());
assertThat((String) dbObject.get("event_class")).isEqualTo(DebugEvent.class.getCanonicalName());
}
use of org.graylog2.system.debug.DebugEvent in project graylog2-server by Graylog2.
the class ClusterEventPeriodicalTest method runHandlesAutoValueCorrectly.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void runHandlesAutoValueCorrectly() throws Exception {
final DebugEvent event = DebugEvent.create("Node ID", TIME, "test");
DBObject dbObject = new BasicDBObjectBuilder().add("timestamp", TIME.getMillis()).add("producer", "TEST-PRODUCER").add("consumers", Collections.emptyList()).add("event_class", DebugEvent.class.getCanonicalName()).add("payload", objectMapper.convertValue(event, Map.class)).get();
final DBCollection collection = mongoConnection.getDatabase().getCollection(ClusterEventPeriodical.COLLECTION_NAME);
collection.save(dbObject);
assertThat(collection.count()).isEqualTo(1L);
clusterEventPeriodical.run();
assertThat(collection.count()).isEqualTo(1L);
@SuppressWarnings("unchecked") final List<String> consumers = (List<String>) collection.findOne().get("consumers");
assertThat(consumers).containsExactly(nodeId.toString());
verify(serverEventBus, times(1)).post(event);
verify(clusterEventBus, never()).post(event);
}
Aggregations