Search in sources :

Example 46 with ObjectMapperProvider

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

the class ViewServiceUsesViewRequirementsTest method setUp.

@Before
public void setUp() throws Exception {
    final MongoJackObjectMapperProvider objectMapperProvider = new MongoJackObjectMapperProviderForTest(new ObjectMapper());
    this.viewService = new ViewService(mongodb.mongoConnection(), objectMapperProvider, clusterConfigService, viewRequirementsFactory, mock(EntityOwnershipService.class), mock(ViewSummaryService.class));
    when(viewRequirementsFactory.create(any(ViewDTO.class))).then(invocation -> new ViewRequirements(Collections.emptySet(), invocation.getArgument(0)));
}
Also used : MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 47 with ObjectMapperProvider

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

the class IndexFieldTypesServiceTest method setUp.

@Before
public void setUp() throws Exception {
    final MongoJackObjectMapperProvider objectMapperProvider = new MongoJackObjectMapperProvider(new ObjectMapper());
    final StreamService streamService = mock(StreamService.class);
    this.dbService = new IndexFieldTypesService(mongodb.mongoConnection(), streamService, objectMapperProvider);
}
Also used : StreamService(org.graylog2.streams.StreamService) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 48 with ObjectMapperProvider

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

the class ContentPackInstallationPersistenceServiceTest method setUp.

@Before
public void setUp() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    final MongoJackObjectMapperProvider mongoJackObjectMapperProvider = new MongoJackObjectMapperProvider(objectMapper);
    persistenceService = new ContentPackInstallationPersistenceService(mongoJackObjectMapperProvider, mongodb.mongoConnection());
}
Also used : 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 49 with ObjectMapperProvider

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

the class DBJobDefinitionServiceTest 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(TestEventProcessorParameters.class, TestEventProcessorParameters.TYPE_NAME));
    objectMapper.registerSubtypes(new NamedType(EventProcessorExecutionJob.Config.class, EventProcessorExecutionJob.TYPE_NAME));
    this.service = new DBJobDefinitionService(mongodb.mongoConnection(), new MongoJackObjectMapperProvider(objectMapper));
}
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) TestEventProcessorParameters(org.graylog.events.TestEventProcessorParameters) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Before(org.junit.Before)

Example 50 with ObjectMapperProvider

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

the class V20170110150100_FixAlertConditionsMigrationTest method setUp.

@Before
public void setUp() throws Exception {
    this.clusterConfigService = spy(new ClusterConfigServiceImpl(objectMapperProvider, mongodb.mongoConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), new ClusterEventBus()));
    final MongoConnection mongoConnection = spy(mongodb.mongoConnection());
    final MongoDatabase mongoDatabase = spy(mongoConnection.getMongoDatabase());
    when(mongoConnection.getMongoDatabase()).thenReturn(mongoDatabase);
    this.collection = spy(mongoDatabase.getCollection("streams"));
    when(mongoDatabase.getCollection("streams")).thenReturn(collection);
    this.migration = new V20170110150100_FixAlertConditionsMigration(mongoConnection, clusterConfigService);
}
Also used : ClusterConfigServiceImpl(org.graylog2.cluster.ClusterConfigServiceImpl) MongoConnection(org.graylog2.database.MongoConnection) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) ClusterEventBus(org.graylog2.events.ClusterEventBus) MongoDatabase(com.mongodb.client.MongoDatabase) 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