use of com.fasterxml.jackson.databind.InjectableValues.Std in project druid by druid-io.
the class HashBucketShardSpecTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
mapper.registerSubtypes(new NamedType(HashBucketShardSpec.class, ShardSpec.Type.BUCKET_HASH));
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
final HashBucketShardSpec original = new HashBucketShardSpec(5, 12, ImmutableList.of("dim"), HashPartitionFunction.MURMUR3_32_ABS, mapper);
final String json = mapper.writeValueAsString(original);
ShardSpec shardSpec = mapper.readValue(json, ShardSpec.class);
Assert.assertEquals(ShardSpec.Type.BUCKET_HASH, shardSpec.getType());
final HashBucketShardSpec fromJson = (HashBucketShardSpec) shardSpec;
Assert.assertEquals(original, fromJson);
}
use of com.fasterxml.jackson.databind.InjectableValues.Std in project druid by druid-io.
the class HdfsFirehoseFactoryTest method createMapper.
private static ObjectMapper createMapper() {
final ObjectMapper mapper = new ObjectMapper();
new HdfsStorageDruidModule().getJacksonModules().forEach(mapper::registerModule);
mapper.setInjectableValues(new Std().addValue(Configuration.class, DEFAULT_CONFIGURATION).addValue(HdfsInputSourceConfig.class, DEFAULT_INPUT_SOURCE_CONFIG));
return mapper;
}
use of com.fasterxml.jackson.databind.InjectableValues.Std in project druid by druid-io.
the class DiscoveryDruidNodeTest method createObjectMapper.
private static ObjectMapper createObjectMapper(Collection<Class<? extends DruidService>> druidServicesToRegister) {
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.registerModules(new ServerModule().getJacksonModules());
// noinspection unchecked,rawtypes
mapper.registerSubtypes((Collection) druidServicesToRegister);
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
return mapper;
}
use of com.fasterxml.jackson.databind.InjectableValues.Std in project druid by druid-io.
the class HttpFirehoseFactoryTest method testSerde.
@Test
public void testSerde() throws IOException {
final HttpInputSourceConfig inputSourceConfig = new HttpInputSourceConfig(null);
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new Std().addValue(HttpInputSourceConfig.class, inputSourceConfig));
final DefaultPasswordProvider pwProvider = new DefaultPasswordProvider("testPassword");
final HttpFirehoseFactory factory = new HttpFirehoseFactory(ImmutableList.of(URI.create("http://foo/bar"), URI.create("http://foo/bar2")), 2048L, 1024L, 512L, 100L, 5, "testUser", pwProvider, inputSourceConfig);
final HttpFirehoseFactory outputFact = mapper.readValue(mapper.writeValueAsString(factory), HttpFirehoseFactory.class);
Assert.assertEquals(factory, outputFact);
}
Aggregations