use of com.fasterxml.jackson.databind.InjectableValues.Std in project druid by druid-io.
the class ImmutableDruidDataSourceTest method testSerde.
@Test
public void testSerde() throws IOException {
final DataSegment segment = getTestSegment();
final ImmutableDruidDataSource dataSource = getImmutableDruidDataSource(segment);
final ObjectMapper objectMapper = new DefaultObjectMapper().setInjectableValues(new Std().addValue(PruneSpecsHolder.class, PruneSpecsHolder.DEFAULT));
final String json = objectMapper.writeValueAsString(dataSource);
ImmutableDruidDataSourceTestUtils.assertEquals(dataSource, objectMapper.readValue(json, ImmutableDruidDataSource.class));
}
use of com.fasterxml.jackson.databind.InjectableValues.Std in project druid by druid-io.
the class SegmentManagerThreadSafetyTest method setup.
@Before
public void setup() throws IOException {
segmentPuller = new TestSegmentPuller();
objectMapper = new DefaultObjectMapper().registerModule(new SimpleModule().registerSubtypes(new NamedType(LocalLoadSpec.class, "local"), new NamedType(TestSegmentizerFactory.class, "test"))).setInjectableValues(new Std().addValue(LocalDataSegmentPuller.class, segmentPuller));
indexIO = new IndexIO(objectMapper, () -> 0);
segmentCacheDir = temporaryFolder.newFolder();
segmentDeepStorageDir = temporaryFolder.newFolder();
segmentCacheManager = new SegmentLocalCacheManager(new SegmentLoaderConfig() {
@Override
public List<StorageLocationConfig> getLocations() {
return Collections.singletonList(new StorageLocationConfig(segmentCacheDir, null, null));
}
}, objectMapper);
segmentManager = new SegmentManager(new SegmentLocalCacheLoader(segmentCacheManager, indexIO, objectMapper));
exec = Execs.multiThreaded(NUM_THREAD, "SegmentManagerThreadSafetyTest-%d");
EmittingLogger.registerEmitter(new NoopServiceEmitter());
}
use of com.fasterxml.jackson.databind.InjectableValues.Std in project druid by druid-io.
the class BuildingHashBasedNumberedShardSpecTest method testSerde.
@Test
public void testSerde() throws JsonProcessingException {
mapper.registerSubtypes(new NamedType(BuildingHashBasedNumberedShardSpec.class, ShardSpec.Type.BUILDING_HASHED));
mapper.setInjectableValues(new Std().addValue(ObjectMapper.class, mapper));
final BuildingHashBasedNumberedShardSpec original = new BuildingHashBasedNumberedShardSpec(3, 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.BUILDING_HASHED, shardSpec.getType());
final BuildingHashBasedNumberedShardSpec fromJson = (BuildingHashBasedNumberedShardSpec) shardSpec;
Assert.assertEquals(original, fromJson);
}
use of com.fasterxml.jackson.databind.InjectableValues.Std in project druid by druid-io.
the class BuildingSingleDimensionShardSpecTest method setupObjectMapper.
private static ObjectMapper setupObjectMapper() {
final ObjectMapper mapper = ShardSpecTestUtils.initObjectMapper();
mapper.registerSubtypes(new NamedType(BuildingSingleDimensionShardSpec.class, ShardSpec.Type.BUILDING_SINGLE_DIM));
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 JdbcExtractionNamespaceTest method testSerde.
@Test
public void testSerde() throws IOException {
final JdbcAccessSecurityConfig securityConfig = new JdbcAccessSecurityConfig();
final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace(derbyConnectorRule.getMetadataConnectorConfig(), TABLE_NAME, KEY_NAME, VAL_NAME, tsColumn, "some filter", new Period(10), null, securityConfig);
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new Std().addValue(JdbcAccessSecurityConfig.class, securityConfig));
final ExtractionNamespace extractionNamespace2 = mapper.readValue(mapper.writeValueAsBytes(extractionNamespace), ExtractionNamespace.class);
Assert.assertEquals(extractionNamespace, extractionNamespace2);
}
Aggregations