use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class DruidServiceTestUtils method newJsonMapper.
public static ObjectMapper newJsonMapper() {
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.registerModules(new ServerModule().getJacksonModules());
return mapper;
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class ProtobufInputFormatTest method setUp.
@Before
public void setUp() {
timestampSpec = new TimestampSpec("timestamp", "iso", null);
dimensionsSpec = new DimensionsSpec(Lists.newArrayList(new StringDimensionSchema("event"), new StringDimensionSchema("id"), new StringDimensionSchema("someOtherId"), new StringDimensionSchema("isValid")));
flattenSpec = new JSONPathSpec(true, Lists.newArrayList(new JSONPathFieldSpec(JSONPathFieldType.ROOT, "eventType", "eventType"), new JSONPathFieldSpec(JSONPathFieldType.PATH, "foobar", "$.foo.bar"), new JSONPathFieldSpec(JSONPathFieldType.PATH, "bar0", "$.bar[0].bar")));
decoder = new FileBasedProtobufBytesDecoder("prototest.desc", "ProtoTestEvent");
for (Module jacksonModule : new ProtobufExtensionsModule().getJacksonModules()) {
jsonMapper.registerModule(jacksonModule);
}
jsonMapper.setInjectableValues(new InjectableValues.Std().addValue(ObjectMapper.class, new DefaultObjectMapper()));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SchemaRegistryBasedProtobufBytesDecoderTest method testParseConfig.
@Test
public void testParseConfig() throws JsonProcessingException {
String json = "{\"url\":\"http://localhost\",\"type\":\"schema_registry\",\"config\":{\"druid.dynamic.config.provider\":{\"type\":\"mapString\", \"config\":{\"registry.config.prop.2\":\"value.2\", \"registry.config.prop.3\":\"value.3\"}},\"registry.config.prop.1\":\"value.1\",\"registry.config.prop.2\":\"value.4\"},\"headers\":{}}";
ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues.Std().addValue(ObjectMapper.class, new DefaultObjectMapper()));
SchemaRegistryBasedProtobufBytesDecoder decoder;
decoder = (SchemaRegistryBasedProtobufBytesDecoder) mapper.readerFor(ProtobufBytesDecoder.class).readValue(json);
Map<String, ?> heaeder = DynamicConfigProviderUtils.extraConfigAndSetObjectMap(decoder.getConfig(), SchemaRegistryBasedProtobufBytesDecoder.DRUID_DYNAMIC_CONFIG_PROVIDER_KEY, new DefaultObjectMapper());
// Then
Assert.assertEquals(3, heaeder.size());
Assert.assertEquals("value.1", heaeder.get("registry.config.prop.1"));
Assert.assertEquals("value.2", heaeder.get("registry.config.prop.2"));
Assert.assertEquals("value.3", heaeder.get("registry.config.prop.3"));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SchemaRegistryBasedProtobufBytesDecoderTest method testMultipleUrls.
@Test
public void testMultipleUrls() throws Exception {
String json = "{\"urls\":[\"http://localhost\"],\"type\": \"schema_registry\"}";
ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues.Std().addValue(ObjectMapper.class, new DefaultObjectMapper()));
SchemaRegistryBasedProtobufBytesDecoder decoder;
decoder = (SchemaRegistryBasedProtobufBytesDecoder) mapper.readerFor(ProtobufBytesDecoder.class).readValue(json);
// Then
Assert.assertNotEquals(decoder.hashCode(), 0);
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SchemaRegistryBasedProtobufBytesDecoderTest method testConfig.
@Test
public void testConfig() throws Exception {
String json = "{\"url\":\"http://localhost\",\"type\": \"schema_registry\", \"config\":{}}";
ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues.Std().addValue(ObjectMapper.class, new DefaultObjectMapper()));
SchemaRegistryBasedProtobufBytesDecoder decoder;
decoder = (SchemaRegistryBasedProtobufBytesDecoder) mapper.readerFor(ProtobufBytesDecoder.class).readValue(json);
// Then
Assert.assertNotEquals(decoder.hashCode(), 0);
}
Aggregations