Search in sources :

Example 26 with ObjectMapperProvider

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

the class V20161215163900_MoveIndexSetDefaultConfigTest method setUp.

@Before
public void setUp() throws Exception {
    this.clusterConfigService = spy(new ClusterConfigServiceImpl(objectMapperProvider, mongodb.mongoConnection(), nodeId, new ChainingClassLoader(getClass().getClassLoader()), new ClusterEventBus()));
    this.collection = mongodb.mongoConnection().getMongoDatabase().getCollection("index_sets");
    this.migration = new V20161215163900_MoveIndexSetDefaultConfig(mongodb.mongoConnection(), clusterConfigService);
}
Also used : ClusterConfigServiceImpl(org.graylog2.cluster.ClusterConfigServiceImpl) ChainingClassLoader(org.graylog2.shared.plugins.ChainingClassLoader) ClusterEventBus(org.graylog2.events.ClusterEventBus) Before(org.junit.Before)

Example 27 with ObjectMapperProvider

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

the class EncryptedValueTest method setUp.

@BeforeEach
void setUp(MongoDBTestService mongodb) {
    encryptedValueService = new EncryptedValueService("1234567890abcdef");
    this.objectMapper = new ObjectMapperProvider(ObjectMapperProvider.class.getClassLoader(), Collections.emptySet(), encryptedValueService, GRNRegistry.createWithBuiltinTypes()).get();
    this.dbService = new TestService(mongodb.mongoConnection(), new MongoJackObjectMapperProvider(objectMapper));
}
Also used : MongoDBTestService(org.graylog.testing.mongodb.MongoDBTestService) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) MongoJackObjectMapperProvider(org.graylog2.bindings.providers.MongoJackObjectMapperProvider) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 28 with ObjectMapperProvider

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

the class DBProcessingStatusServiceTest method setUp.

@Before
public void setUp() throws Exception {
    when(nodeId.toString()).thenReturn(NODE_ID);
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    final MongoJackObjectMapperProvider mapperProvider = new MongoJackObjectMapperProvider(objectMapper);
    clock = spy(new JobSchedulerTestClock(DateTime.parse("2019-01-01T00:00:00.000Z")));
    updateThreshold = spy(Duration.minutes(1));
    dbService = new DBProcessingStatusService(mongodb.mongoConnection(), nodeId, clock, updateThreshold, 1, mapperProvider, baseConfiguration);
    db = JacksonDBCollection.wrap(mongodb.mongoConnection().getDatabase().getCollection(DBProcessingStatusService.COLLECTION_NAME), ProcessingStatusDto.class, ObjectId.class, mapperProvider.get());
}
Also used : JobSchedulerTestClock(org.graylog.events.JobSchedulerTestClock) ObjectId(org.bson.types.ObjectId) 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 29 with ObjectMapperProvider

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

the class DeletionRetentionStrategyConfigTest method testDeserialization.

@Test
public void testDeserialization() throws IOException {
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    final String json = "{ \"type\": \"org.graylog2.indexer.retention.strategies.DeletionRetentionStrategyConfig\", \"max_number_of_indices\": 23}";
    final RetentionStrategyConfig config = objectMapper.readValue(json, RetentionStrategyConfig.class);
    assertThat(config).isInstanceOf(DeletionRetentionStrategyConfig.class);
    assertThat(((DeletionRetentionStrategyConfig) config).maxNumberOfIndices()).isEqualTo(23);
}
Also used : RetentionStrategyConfig(org.graylog2.plugin.indexer.retention.RetentionStrategyConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Test(org.junit.Test)

Example 30 with ObjectMapperProvider

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

the class TimeBasedRotationStrategyConfigTest method testDeserialization.

@Test
public void testDeserialization() throws IOException {
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    final String json = "{ \"type\": \"org.graylog2.indexer.rotation.strategies.TimeBasedRotationStrategyConfig\", \"rotation_period\": \"P1D\", \"max_rotation_period\": \"P99D\" }";
    final RotationStrategyConfig config = objectMapper.readValue(json, RotationStrategyConfig.class);
    assertThat(config).isInstanceOf(TimeBasedRotationStrategyConfig.class);
    assertThat(((TimeBasedRotationStrategyConfig) config).rotationPeriod()).isEqualTo(Period.days(1));
    assertThat(((TimeBasedRotationStrategyConfig) config).maxRotationPeriod()).isEqualTo(Period.days(99));
}
Also used : RotationStrategyConfig(org.graylog2.plugin.indexer.rotation.RotationStrategyConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Test(org.junit.Test)

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