Search in sources :

Example 11 with JobSchedulerTestClock

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

the class EventDefinitionHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    when(nodeId.toString()).thenReturn("abc-123");
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    objectMapper.registerSubtypes(new NamedType(TestEventProcessorConfig.class, TestEventProcessorConfig.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(TestEventProcessorParameters.class, TestEventProcessorParameters.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(EventNotificationExecutionJob.Data.class, EventNotificationExecutionJob.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(IntervalJobSchedule.class, IntervalJobSchedule.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(OnceJobSchedule.class, OnceJobSchedule.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(PersistToStreamsStorageHandler.Config.class, PersistToStreamsStorageHandler.Config.TYPE_NAME));
    final MongoJackObjectMapperProvider mapperProvider = new MongoJackObjectMapperProvider(objectMapper);
    this.clock = new JobSchedulerTestClock(DateTime.now(DateTimeZone.UTC));
    this.eventDefinitionService = spy(new DBEventDefinitionService(mongodb.mongoConnection(), mapperProvider, stateService, mock(EntityOwnershipService.class)));
    this.jobDefinitionService = spy(new DBJobDefinitionService(mongodb.mongoConnection(), mapperProvider));
    this.jobTriggerService = spy(new DBJobTriggerService(mongodb.mongoConnection(), mapperProvider, nodeId, clock, Duration.minutes(5)));
    this.handler = new EventDefinitionHandler(eventDefinitionService, jobDefinitionService, jobTriggerService, clock);
}
Also used : JobSchedulerTestClock(org.graylog.events.JobSchedulerTestClock) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) TestEventProcessorConfig(org.graylog.events.TestEventProcessorConfig) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) TestEventProcessorConfig(org.graylog.events.TestEventProcessorConfig) EntityOwnershipService(org.graylog.security.entities.EntityOwnershipService) IntervalJobSchedule(org.graylog.scheduler.schedule.IntervalJobSchedule) OnceJobSchedule(org.graylog.scheduler.schedule.OnceJobSchedule) DBJobTriggerService(org.graylog.scheduler.DBJobTriggerService) DBJobDefinitionService(org.graylog.scheduler.DBJobDefinitionService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TestEventProcessorParameters(org.graylog.events.TestEventProcessorParameters) Before(org.junit.Before)

Aggregations

JobSchedulerTestClock (org.graylog.events.JobSchedulerTestClock)11 Before (org.junit.Before)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)4 ObjectMapperProvider (org.graylog2.shared.bindings.providers.ObjectMapperProvider)4 Test (org.junit.Test)4 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)3 IntervalJobSchedule (org.graylog.scheduler.schedule.IntervalJobSchedule)3 MongoDBFixtures (org.graylog.testing.mongodb.MongoDBFixtures)3 DBEventDefinitionService (org.graylog.events.processor.DBEventDefinitionService)2 DBJobDefinitionService (org.graylog.scheduler.DBJobDefinitionService)2 DBJobTriggerService (org.graylog.scheduler.DBJobTriggerService)2 DateTime (org.joda.time.DateTime)2 ObjectId (org.bson.types.ObjectId)1 TestEventProcessorConfig (org.graylog.events.TestEventProcessorConfig)1 TestEventProcessorParameters (org.graylog.events.TestEventProcessorParameters)1 DBNotificationService (org.graylog.events.notifications.DBNotificationService)1 NotificationResourceHandler (org.graylog.events.notifications.NotificationResourceHandler)1 EventDefinitionHandler (org.graylog.events.processor.EventDefinitionHandler)1 AggregationEventProcessorConfig (org.graylog.events.processor.aggregation.AggregationEventProcessorConfig)1