Search in sources :

Example 6 with ClusterEventBus

use of org.graylog2.events.ClusterEventBus 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());
}
Also used : DBCollection(com.mongodb.DBCollection) DebugEvent(org.graylog2.system.debug.DebugEvent) DBObject(com.mongodb.DBObject) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 7 with ClusterEventBus

use of org.graylog2.events.ClusterEventBus in project graylog2-server by Graylog2.

the class ClusterEventPeriodicalTest method setUpService.

@Before
public void setUpService() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(TIME.getMillis());
    this.mongoConnection = mongoRule.getMongoConnection();
    MongoJackObjectMapperProvider provider = new MongoJackObjectMapperProvider(objectMapper);
    when(nodeId.toString()).thenReturn("ID");
    this.clusterEventPeriodical = new ClusterEventPeriodical(provider, mongoRule.getMongoConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), serverEventBus, clusterEventBus);
}
Also used : MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) Before(org.junit.Before)

Example 8 with ClusterEventBus

use of org.graylog2.events.ClusterEventBus in project graylog2-server by Graylog2.

the class ClusterConfigServiceImplTest method setUpService.

@Before
public void setUpService() throws Exception {
    DateTimeUtils.setCurrentMillisFixed(TIME.getMillis());
    this.mongoConnection = mongoRule.getMongoConnection();
    MongoJackObjectMapperProvider provider = new MongoJackObjectMapperProvider(objectMapper);
    when(nodeId.toString()).thenReturn("ID");
    this.clusterConfigService = new ClusterConfigServiceImpl(provider, mongoRule.getMongoConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), clusterEventBus);
}
Also used : MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) Before(org.junit.Before)

Example 9 with ClusterEventBus

use of org.graylog2.events.ClusterEventBus in project graylog2-server by Graylog2.

the class DashboardWidgetsResourceTest method verifyWidgetUpdatedEvent.

private void verifyWidgetUpdatedEvent(String widgetId) {
    final ArgumentCaptor<WidgetUpdatedEvent> widgetUpdatedEventCaptor = ArgumentCaptor.forClass(WidgetUpdatedEvent.class);
    verify(clusterEventBus).post(widgetUpdatedEventCaptor.capture());
    final WidgetUpdatedEvent capturedEvent = widgetUpdatedEventCaptor.getValue();
    assert (capturedEvent.widgetId()).equals(widgetId);
}
Also used : WidgetUpdatedEvent(org.graylog2.dashboards.widgets.events.WidgetUpdatedEvent)

Example 10 with ClusterEventBus

use of org.graylog2.events.ClusterEventBus in project graylog2-server by Graylog2.

the class GrokResourceTest method setUp.

@Before
public void setUp() {
    final ClusterEventBus clusterBus = new ClusterEventBus();
    subscriber = new GrokPatternsChangedEventSubscriber();
    clusterBus.registerClusterEventSubscriber(subscriber);
    grokResource = new PermittedTestResource(grokPatternService, clusterBus);
}
Also used : ClusterEventBus(org.graylog2.events.ClusterEventBus) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)9 IndexSetConfig (org.graylog2.indexer.indexset.IndexSetConfig)6 Before (org.junit.Before)6 ClusterEventBus (org.graylog2.events.ClusterEventBus)5 ChainingClassLoader (org.graylog2.shared.plugins.ChainingClassLoader)5 Stream (org.graylog2.plugin.streams.Stream)4 ClusterConfigServiceImpl (org.graylog2.cluster.ClusterConfigServiceImpl)3 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)2 DBCollection (com.mongodb.DBCollection)2 DBObject (com.mongodb.DBObject)2 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)2 StreamsChangedEvent (org.graylog2.streams.events.StreamsChangedEvent)2 DebugEvent (org.graylog2.system.debug.DebugEvent)2 BasicDBObjectBuilder (com.mongodb.BasicDBObjectBuilder)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 List (java.util.List)1 WidgetUpdatedEvent (org.graylog2.dashboards.widgets.events.WidgetUpdatedEvent)1 MongoConnection (org.graylog2.database.MongoConnection)1 DefaultIndexSetConfig (org.graylog2.indexer.indexset.DefaultIndexSetConfig)1 IndexSetCreatedEvent (org.graylog2.indexer.indexset.events.IndexSetCreatedEvent)1