use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SchemaRegistryBasedProtobufBytesDecoderTest method testUrl.
@Test
public void testUrl() throws Exception {
String json = "{\"url\":\"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 testParseHeader.
@Test
public void testParseHeader() throws JsonProcessingException {
String json = "{\"url\":\"http://localhost\",\"type\":\"schema_registry\",\"config\":{},\"headers\":{\"druid.dynamic.config.provider\":{\"type\":\"mapString\", \"config\":{\"registry.header.prop.2\":\"value.2\", \"registry.header.prop.3\":\"value.3\"}},\"registry.header.prop.1\":\"value.1\",\"registry.header.prop.2\":\"value.4\"}}";
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, String> header = DynamicConfigProviderUtils.extraConfigAndSetStringMap(decoder.getHeaders(), SchemaRegistryBasedProtobufBytesDecoder.DRUID_DYNAMIC_CONFIG_PROVIDER_KEY, new DefaultObjectMapper());
// Then
Assert.assertEquals(3, header.size());
Assert.assertEquals("value.1", header.get("registry.header.prop.1"));
Assert.assertEquals("value.2", header.get("registry.header.prop.2"));
Assert.assertEquals("value.3", header.get("registry.header.prop.3"));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class PollingLookupSerDeserTest method testSerDeser.
@Test
public void testSerDeser() throws IOException {
ObjectMapper mapper = new DefaultObjectMapper();
PollingLookupFactory pollingLookupFactory = new PollingLookupFactory(Period.ZERO, dataFetcher, cacheFactory);
mapper.registerSubtypes(MockDataFetcher.class);
mapper.registerSubtypes(PollingLookupFactory.class);
Assert.assertEquals(pollingLookupFactory, mapper.readerFor(LookupExtractorFactory.class).readValue(mapper.writeValueAsString(pollingLookupFactory)));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class ZtestPostAggregatorTest method testSerde.
@Test
public void testSerde() throws Exception {
DefaultObjectMapper mapper = new DefaultObjectMapper();
ZtestPostAggregator postAggregator1 = mapper.readValue(mapper.writeValueAsString(ztestPostAggregator), ZtestPostAggregator.class);
Assert.assertEquals(ztestPostAggregator, postAggregator1);
Assert.assertArrayEquals(ztestPostAggregator.getCacheKey(), postAggregator1.getCacheKey());
Assert.assertEquals(ztestPostAggregator.getDependentFields(), postAggregator1.getDependentFields());
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class PvaluefromZscorePostAggregatorTest method testSerde.
@Test
public void testSerde() throws Exception {
DefaultObjectMapper mapper = new DefaultObjectMapper();
PvaluefromZscorePostAggregator postAggregator1 = mapper.readValue(mapper.writeValueAsString(pvaluefromZscorePostAggregator), PvaluefromZscorePostAggregator.class);
Assert.assertEquals(pvaluefromZscorePostAggregator, postAggregator1);
Assert.assertArrayEquals(pvaluefromZscorePostAggregator.getCacheKey(), postAggregator1.getCacheKey());
Assert.assertEquals(pvaluefromZscorePostAggregator.getDependentFields(), postAggregator1.getDependentFields());
}
Aggregations