Search in sources :

Example 6 with ObjectMapperProvider

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

the class MessageCountRotationStrategyConfigTest method testDeserialization.

@Test
public void testDeserialization() throws IOException {
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    final String json = "{ \"type\": \"org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategyConfig\", \"max_docs_per_index\": 1000 }";
    final RotationStrategyConfig config = objectMapper.readValue(json, RotationStrategyConfig.class);
    assertThat(config).isInstanceOf(MessageCountRotationStrategyConfig.class);
    assertThat(((MessageCountRotationStrategyConfig) config).maxDocsPerIndex()).isEqualTo(1000);
}
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)

Example 7 with ObjectMapperProvider

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

the class MessageCountRotationStrategyConfigTest method testSerialization.

@Test
public void testSerialization() throws JsonProcessingException {
    final RotationStrategyConfig config = MessageCountRotationStrategyConfig.create(1000);
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    final String json = objectMapper.writeValueAsString(config);
    final Object document = Configuration.defaultConfiguration().jsonProvider().parse(json);
    assertThat((String) JsonPath.read(document, "$.type")).isEqualTo("org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategyConfig");
    assertThat((Integer) JsonPath.read(document, "$.max_docs_per_index")).isEqualTo(1000);
}
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)

Example 8 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\" }";
    final RotationStrategyConfig config = objectMapper.readValue(json, RotationStrategyConfig.class);
    assertThat(config).isInstanceOf(TimeBasedRotationStrategyConfig.class);
    assertThat(((TimeBasedRotationStrategyConfig) config).rotationPeriod()).isEqualTo(Period.days(1));
}
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)

Example 9 with ObjectMapperProvider

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

the class HTTPAlarmCallbackTest method setUp.

@Before
public void setUp() throws Exception {
    httpClient = new OkHttpClient();
    objectMapper = new ObjectMapperProvider().get();
    alarmCallback = new HTTPAlarmCallback(httpClient, objectMapper);
    server = new MockWebServer();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MockWebServer(okhttp3.mockwebserver.MockWebServer) ObjectMapperProvider(org.graylog2.shared.bindings.providers.ObjectMapperProvider) Before(org.junit.Before)

Example 10 with ObjectMapperProvider

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

the class BundleServiceTest method setUp.

@Before
public void setUp() throws Exception {
    final ObjectMapper objectMapper = new ObjectMapperProvider().get();
    bundleService = new BundleService(new MongoJackObjectMapperProvider(objectMapper), mongoRule.getMongoConnection(), bundleImporterProvider, bundleExporterProvider);
}
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)

Aggregations

ObjectMapperProvider (org.graylog2.shared.bindings.providers.ObjectMapperProvider)16 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)14 Test (org.junit.Test)12 Before (org.junit.Before)8 RotationStrategyConfig (org.graylog2.plugin.indexer.rotation.RotationStrategyConfig)6 MongoJackObjectMapperProvider (org.graylog2.bindings.providers.MongoJackObjectMapperProvider)3 ClusterConfigServiceImpl (org.graylog2.cluster.ClusterConfigServiceImpl)3 ClusterEventBus (org.graylog2.events.ClusterEventBus)3 ChainingClassLoader (org.graylog2.shared.plugins.ChainingClassLoader)3 RetentionStrategyConfig (org.graylog2.plugin.indexer.retention.RetentionStrategyConfig)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 EventBus (com.google.common.eventbus.EventBus)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 Map (java.util.Map)1 OkHttpClient (okhttp3.OkHttpClient)1 MockWebServer (okhttp3.mockwebserver.MockWebServer)1 DeleteIndexTemplateRequest (org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)1 DeleteIndexTemplateResponse (org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse)1 GetIndexTemplatesResponse (org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse)1 IndicesAdminClient (org.elasticsearch.client.IndicesAdminClient)1