Search in sources :

Example 51 with ObjectMapperProvider

use of org.graylog2.shared.bindings.providers.ObjectMapperProvider in project graylog2-server by Graylog2.

the class EventDtoTest method deserializeWithESTimestamps.

@Test
public void deserializeWithESTimestamps() throws Exception {
    // Checks that the EventDto is using the "ESMongoDateTimeDeserializer" deserializer to be able
    // to parse our ES timestamps.
    final URL eventString = Resources.getResource(getClass(), "aggregation-event-from-elasticsearch.json");
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    final EventDto eventDto = objectMapper.readValue(eventString, EventDto.class);
    assertThat(eventDto.eventTimestamp()).isEqualTo(DateTime.parse("2019-08-21T07:48:01.326Z"));
    assertThat(eventDto.processingTimestamp()).isEqualTo(DateTime.parse("2019-09-25T10:35:57.116Z"));
    assertThat(eventDto.timerangeStart()).get().isEqualTo(DateTime.parse("2019-08-21T07:47:41.213Z"));
    assertThat(eventDto.timerangeEnd()).get().isEqualTo(DateTime.parse("2019-08-21T07:48:41.212Z"));
}
Also used : URL(java.net.URL) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Test(org.junit.Test)

Example 52 with ObjectMapperProvider

use of org.graylog2.shared.bindings.providers.ObjectMapperProvider 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)

Example 53 with ObjectMapperProvider

use of org.graylog2.shared.bindings.providers.ObjectMapperProvider in project graylog2-server by Graylog2.

the class DBEventProcessorServiceTest method setUp.

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

Example 54 with ObjectMapperProvider

use of org.graylog2.shared.bindings.providers.ObjectMapperProvider in project graylog2-server by Graylog2.

the class SearchExecutorTest method setUp.

@Before
public void setUp() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    this.searchExecutor = new SearchExecutor(searchDomain, searchJobService, queryEngine, searchExecutionGuard, objectMapper);
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Before(org.junit.Before)

Aggregations

ObjectMapperProvider (org.graylog2.shared.bindings.providers.ObjectMapperProvider)45 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)38 Before (org.junit.Before)32 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)24 Test (org.junit.Test)18 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)7 RotationStrategyConfig (org.graylog2.plugin.indexer.rotation.RotationStrategyConfig)7 ClusterEventBus (org.graylog2.events.ClusterEventBus)5 JobSchedulerTestClock (org.graylog.events.JobSchedulerTestClock)4 ClusterConfigServiceImpl (org.graylog2.cluster.ClusterConfigServiceImpl)4 ChainingClassLoader (org.graylog2.shared.plugins.ChainingClassLoader)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 TestEventProcessorConfig (org.graylog.events.TestEventProcessorConfig)3 DBEventDefinitionService (org.graylog.events.processor.DBEventDefinitionService)3 IntervalJobSchedule (org.graylog.scheduler.schedule.IntervalJobSchedule)3 MongoConnection (org.graylog2.database.MongoConnection)3 AutoValueSubtypeResolver (org.graylog2.jackson.AutoValueSubtypeResolver)3 StreamService (org.graylog2.streams.StreamService)3 Mockito.mock (org.mockito.Mockito.mock)3 ImmutableMap (com.google.common.collect.ImmutableMap)2