Search in sources :

Example 6 with StreamService

use of org.graylog2.streams.StreamService in project graylog2-server by Graylog2.

the class V20161125161400_AlertReceiversMigrationTest method setUp.

@Before
public void setUp() throws Exception {
    final MongoConnection mongoConnection = mock(MongoConnection.class);
    final DB database = mock(DB.class);
    when(mongoConnection.getDatabase()).thenReturn(database);
    when(database.getCollection(eq("streams"))).thenReturn(dbCollection);
    this.alertReceiversMigration = new V20161125161400_AlertReceiversMigration(clusterConfigService, streamService, alarmCallbackConfigurationService, mongoConnection);
}
Also used : MongoConnection(org.graylog2.database.MongoConnection) DB(com.mongodb.DB) Before(org.junit.Before)

Example 7 with StreamService

use of org.graylog2.streams.StreamService in project graylog2-server by Graylog2.

the class V20161116172200_CreateDefaultStreamMigrationTest method upgrade.

@Test
public void upgrade() throws Exception {
    final ArgumentCaptor<Stream> streamArgumentCaptor = ArgumentCaptor.forClass(Stream.class);
    when(streamService.load("000000000000000000000001")).thenThrow(NotFoundException.class);
    when(indexSetRegistry.getDefault()).thenReturn(indexSet);
    migration.upgrade();
    verify(streamService).save(streamArgumentCaptor.capture());
    final Stream stream = streamArgumentCaptor.getValue();
    assertThat(stream.getTitle()).isEqualTo("All messages");
    assertThat(stream.getDisabled()).isFalse();
    assertThat(stream.getMatchingType()).isEqualTo(StreamImpl.MatchingType.DEFAULT);
}
Also used : Stream(org.graylog2.plugin.streams.Stream) Test(org.junit.Test)

Example 8 with StreamService

use of org.graylog2.streams.StreamService in project graylog2-server by Graylog2.

the class V20161122174500_AssignIndexSetsToStreamsMigrationTest method upgradeWhenAlreadyCompleted.

@Test
public void upgradeWhenAlreadyCompleted() throws Exception {
    final IndexSetConfig indexSetConfig = mock(IndexSetConfig.class);
    when(indexSetService.findAll()).thenReturn(Collections.singletonList(indexSetConfig));
    when(indexSetConfig.id()).thenReturn("abc123");
    when(clusterConfigService.get(V20161122174500_AssignIndexSetsToStreamsMigration.MigrationCompleted.class)).thenReturn(V20161122174500_AssignIndexSetsToStreamsMigration.MigrationCompleted.create("1", Collections.emptySet(), Collections.emptySet()));
    migration.upgrade();
    verify(streamService, never()).save(any(Stream.class));
    verify(clusterConfigService, never()).write(any(V20161122174500_AssignIndexSetsToStreamsMigration.MigrationCompleted.class));
    verify(clusterEventBus, never()).post(any(StreamsChangedEvent.class));
}
Also used : IndexSetConfig(org.graylog2.indexer.indexset.IndexSetConfig) StreamsChangedEvent(org.graylog2.streams.events.StreamsChangedEvent) Stream(org.graylog2.plugin.streams.Stream) Test(org.junit.Test)

Example 9 with StreamService

use of org.graylog2.streams.StreamService 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);
}
Also used : ClusterConfigServiceImpl(org.graylog2.cluster.ClusterConfigServiceImpl) ClusterEventBus(org.graylog2.events.ClusterEventBus) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) Before(org.junit.Before)

Aggregations

Stream (org.graylog2.plugin.streams.Stream)5 Test (org.junit.Test)5 IndexSetConfig (org.graylog2.indexer.indexset.IndexSetConfig)4 Before (org.junit.Before)4 MetricRegistry (com.codahale.metrics.MetricRegistry)1 DB (com.mongodb.DB)1 ZonedDateTime (java.time.ZonedDateTime)1 Configuration (org.graylog2.Configuration)1 ClusterConfigServiceImpl (org.graylog2.cluster.ClusterConfigServiceImpl)1 MongoConnection (org.graylog2.database.MongoConnection)1 ClusterEventBus (org.graylog2.events.ClusterEventBus)1 User (org.graylog2.plugin.database.users.User)1 ChainingClassLoader (org.graylog2.shared.plugins.ChainingClassLoader)1 StreamsChangedEvent (org.graylog2.streams.events.StreamsChangedEvent)1 DateTime (org.joda.time.DateTime)1