Search in sources :

Example 1 with DBEventDefinitionService

use of org.graylog.events.processor.DBEventDefinitionService in project graylog2-server by Graylog2.

the class LegacyAlertConditionMigratorTest method setUp.

@Before
public void setUp() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    objectMapper.registerSubtypes(new NamedType(AggregationEventProcessorConfig.class, AggregationEventProcessorConfig.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(AggregationEventProcessorParameters.class, AggregationEventProcessorConfig.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(EventProcessorExecutionJob.Config.class, EventProcessorExecutionJob.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(EventProcessorExecutionJob.Data.class, EventProcessorExecutionJob.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(IntervalJobSchedule.class, IntervalJobSchedule.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(PersistToStreamsStorageHandler.Config.class, PersistToStreamsStorageHandler.Config.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(PersistToStreamsStorageHandler.Config.class, PersistToStreamsStorageHandler.Config.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(LegacyAlarmCallbackEventNotificationConfig.class, LegacyAlarmCallbackEventNotificationConfig.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(EventNotificationExecutionJob.Config.class, EventNotificationExecutionJob.TYPE_NAME));
    final MongoJackObjectMapperProvider mongoJackObjectMapperProvider = new MongoJackObjectMapperProvider(objectMapper);
    final MongoConnection mongoConnection = mongodb.mongoConnection();
    final JobSchedulerTestClock clock = new JobSchedulerTestClock(DateTime.now(DateTimeZone.UTC));
    final DBJobDefinitionService jobDefinitionService = new DBJobDefinitionService(mongoConnection, mongoJackObjectMapperProvider);
    final DBJobTriggerService jobTriggerService = new DBJobTriggerService(mongoConnection, mongoJackObjectMapperProvider, mock(NodeId.class), clock, Duration.minutes(5));
    notificationService = new DBNotificationService(mongoConnection, mongoJackObjectMapperProvider, mock(EntityOwnershipService.class));
    this.eventDefinitionService = new DBEventDefinitionService(mongoConnection, mongoJackObjectMapperProvider, mock(DBEventProcessorStateService.class), mock(EntityOwnershipService.class));
    this.eventDefinitionHandler = spy(new EventDefinitionHandler(eventDefinitionService, jobDefinitionService, jobTriggerService, clock));
    this.notificationResourceHandler = spy(new NotificationResourceHandler(notificationService, jobDefinitionService, eventDefinitionService, eventNotificationFactories));
    this.userService = mock(UserService.class);
    when(userService.getRootUser()).thenReturn(Optional.empty());
    this.migrator = new LegacyAlertConditionMigrator(mongoConnection, eventDefinitionHandler, notificationResourceHandler, notificationService, userService, CHECK_INTERVAL);
}
Also used : JobSchedulerTestClock(org.graylog.events.JobSchedulerTestClock) UserService(org.graylog2.shared.users.UserService) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) AggregationEventProcessorConfig(org.graylog.events.processor.aggregation.AggregationEventProcessorConfig) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) DBEventDefinitionService(org.graylog.events.processor.DBEventDefinitionService) AggregationEventProcessorConfig(org.graylog.events.processor.aggregation.AggregationEventProcessorConfig) NotificationResourceHandler(org.graylog.events.notifications.NotificationResourceHandler) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) AggregationEventProcessorParameters(org.graylog.events.processor.aggregation.AggregationEventProcessorParameters) IntervalJobSchedule(org.graylog.scheduler.schedule.IntervalJobSchedule) DBNotificationService(org.graylog.events.notifications.DBNotificationService) DBJobTriggerService(org.graylog.scheduler.DBJobTriggerService) NodeId(org.graylog2.plugin.system.NodeId) DBJobDefinitionService(org.graylog.scheduler.DBJobDefinitionService) EventDefinitionHandler(org.graylog.events.processor.EventDefinitionHandler) MongoConnection(org.graylog2.database.MongoConnection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 2 with DBEventDefinitionService

use of org.graylog.events.processor.DBEventDefinitionService in project graylog2-server by Graylog2.

the class NotificationFacadeTest method setUp.

@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
    objectMapper.registerSubtypes(EmailEventNotificationConfig.class, EmailEventNotificationConfigEntity.class, HttpEventNotificationConfigEntity.class, HTTPEventNotificationConfig.class);
    jobDefinitionService = mock(DBJobDefinitionService.class);
    stateService = mock(DBEventProcessorStateService.class);
    eventDefinitionService = new DBEventDefinitionService(mongodb.mongoConnection(), mapperProvider, stateService, mock(EntityOwnershipService.class));
    notificationService = new DBNotificationService(mongodb.mongoConnection(), mapperProvider, mock(EntityOwnershipService.class));
    notificationResourceHandler = new NotificationResourceHandler(notificationService, jobDefinitionService, eventDefinitionService, Maps.newHashMap());
    facade = new NotificationFacade(objectMapper, notificationResourceHandler, notificationService, userService);
}
Also used : DBNotificationService(org.graylog.events.notifications.DBNotificationService) DBJobDefinitionService(org.graylog.scheduler.DBJobDefinitionService) DBEventDefinitionService(org.graylog.events.processor.DBEventDefinitionService) DBEventProcessorStateService(org.graylog.events.processor.DBEventProcessorStateService) NotificationResourceHandler(org.graylog.events.notifications.NotificationResourceHandler) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Example 3 with DBEventDefinitionService

use of org.graylog.events.processor.DBEventDefinitionService in project graylog2-server by Graylog2.

the class AggregationEventProcessorConfigTest method setUp.

@Before
public void setUp() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    objectMapper.registerSubtypes(new NamedType(AggregationEventProcessorConfig.class, AggregationEventProcessorConfig.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(TemplateFieldValueProvider.Config.class, TemplateFieldValueProvider.Config.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(PersistToStreamsStorageHandler.Config.class, PersistToStreamsStorageHandler.Config.TYPE_NAME));
    final MongoJackObjectMapperProvider mapperProvider = new MongoJackObjectMapperProvider(objectMapper);
    this.dbService = new DBEventDefinitionService(mongodb.mongoConnection(), mapperProvider, stateService, mock(EntityOwnershipService.class));
    this.clock = new JobSchedulerTestClock(DateTime.now(DateTimeZone.UTC));
}
Also used : JobSchedulerTestClock(org.graylog.events.JobSchedulerTestClock) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) DBEventDefinitionService(org.graylog.events.processor.DBEventDefinitionService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Before(org.junit.Before)

Example 4 with DBEventDefinitionService

use of org.graylog.events.processor.DBEventDefinitionService in project graylog2-server by Graylog2.

the class V20200102140000_UnifyEventSeriesIdTestIT method setUp.

@Before
public void setUp() throws Exception {
    final ObjectMapperProvider objectMapperProvider = new ObjectMapperProvider();
    final ObjectMapper objectMapper = objectMapperProvider.get();
    objectMapper.registerSubtypes(new NamedType(AggregationEventProcessorConfig.class, AggregationEventProcessorConfig.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(TemplateFieldValueProvider.Config.class, TemplateFieldValueProvider.Config.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(PersistToStreamsStorageHandler.Config.class, PersistToStreamsStorageHandler.Config.TYPE_NAME));
    final MongoJackObjectMapperProvider mapperProvider = new MongoJackObjectMapperProvider(objectMapper);
    eventDefinitionService = new DBEventDefinitionService(mongodb.mongoConnection(), mapperProvider, dbEventProcessorStateService, mock(EntityOwnershipService.class));
    migration = new V20200102140000_UnifyEventSeriesId(clusterConfigService, eventDefinitionService, objectMapperProvider);
}
Also used : NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) AggregationEventProcessorConfig(org.graylog.events.processor.aggregation.AggregationEventProcessorConfig) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) DBEventDefinitionService(org.graylog.events.processor.DBEventDefinitionService) AggregationEventProcessorConfig(org.graylog.events.processor.aggregation.AggregationEventProcessorConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Before(org.junit.Before)

Example 5 with DBEventDefinitionService

use of org.graylog.events.processor.DBEventDefinitionService in project graylog2-server by Graylog2.

the class EventDefinitionFacadeTest method setUp.

@Before
@SuppressForbidden("Using Executors.newSingleThreadExecutor() is okay in tests")
public void setUp() throws Exception {
    objectMapper.registerSubtypes(AggregationEventProcessorConfig.class, PersistToStreamsStorageHandler.Config.class, TemplateFieldValueProvider.Config.class, AggregationEventProcessorConfigEntity.class);
    stateService = mock(DBEventProcessorStateService.class);
    jobDefinitionService = mock(DBJobDefinitionService.class);
    jobTriggerService = mock(DBJobTriggerService.class);
    jobSchedulerClock = mock(JobSchedulerClock.class);
    eventDefinitionService = new DBEventDefinitionService(mongodb.mongoConnection(), mapperProvider, stateService, entityOwnershipService);
    eventDefinitionHandler = new EventDefinitionHandler(eventDefinitionService, jobDefinitionService, jobTriggerService, jobSchedulerClock);
    Set<PluginMetaData> pluginMetaData = new HashSet<>();
    facade = new EventDefinitionFacade(objectMapper, eventDefinitionHandler, pluginMetaData, jobDefinitionService, eventDefinitionService, userService);
}
Also used : PersistToStreamsStorageHandler(org.graylog.events.processor.storage.PersistToStreamsStorageHandler) TemplateFieldValueProvider(org.graylog.events.fields.providers.TemplateFieldValueProvider) DBJobTriggerService(org.graylog.scheduler.DBJobTriggerService) JobSchedulerClock(org.graylog.scheduler.clock.JobSchedulerClock) PluginMetaData(org.graylog2.plugin.PluginMetaData) DBJobDefinitionService(org.graylog.scheduler.DBJobDefinitionService) DBEventDefinitionService(org.graylog.events.processor.DBEventDefinitionService) EventDefinitionHandler(org.graylog.events.processor.EventDefinitionHandler) DBEventProcessorStateService(org.graylog.events.processor.DBEventProcessorStateService) HashSet(java.util.HashSet) Before(org.junit.Before) SuppressForbidden(org.graylog2.shared.SuppressForbidden)

Aggregations

DBEventDefinitionService (org.graylog.events.processor.DBEventDefinitionService)5 Before (org.junit.Before)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)3 DBJobDefinitionService (org.graylog.scheduler.DBJobDefinitionService)3 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)3 ObjectMapperProvider (org.graylog2.shared.bindings.providers.ObjectMapperProvider)3 JobSchedulerTestClock (org.graylog.events.JobSchedulerTestClock)2 DBNotificationService (org.graylog.events.notifications.DBNotificationService)2 NotificationResourceHandler (org.graylog.events.notifications.NotificationResourceHandler)2 DBEventProcessorStateService (org.graylog.events.processor.DBEventProcessorStateService)2 EventDefinitionHandler (org.graylog.events.processor.EventDefinitionHandler)2 AggregationEventProcessorConfig (org.graylog.events.processor.aggregation.AggregationEventProcessorConfig)2 DBJobTriggerService (org.graylog.scheduler.DBJobTriggerService)2 SuppressForbidden (org.graylog2.shared.SuppressForbidden)2 HashSet (java.util.HashSet)1 TemplateFieldValueProvider (org.graylog.events.fields.providers.TemplateFieldValueProvider)1 AggregationEventProcessorParameters (org.graylog.events.processor.aggregation.AggregationEventProcessorParameters)1 PersistToStreamsStorageHandler (org.graylog.events.processor.storage.PersistToStreamsStorageHandler)1 JobSchedulerClock (org.graylog.scheduler.clock.JobSchedulerClock)1