use of org.graylog2.events.ClusterEventBus in project graylog2-server by Graylog2.
the class MongoIndexSetServiceTest method setUp.
@Before
public void setUp() throws Exception {
clusterEventBus = new ClusterEventBus();
clusterConfigService = new ClusterConfigServiceImpl(objectMapperProvider, mongoRule.getMongoConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), clusterEventBus);
indexSetService = new MongoIndexSetService(mongoRule.getMongoConnection(), objectMapperProvider, streamService, clusterConfigService, clusterEventBus);
}
use of org.graylog2.events.ClusterEventBus 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