use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class MetadataStorageTablesConfigTest method testSerdeMetadataStorageTablesConfig.
@Test
public void testSerdeMetadataStorageTablesConfig() throws Exception {
Injector injector = Guice.createInjector(new Module() {
@Override
public void configure(Binder binder) {
binder.install(new PropertiesModule(Arrays.asList("test.runtime.properties")));
binder.install(new ConfigModule());
binder.install(new DruidGuiceExtensions());
JsonConfigProvider.bind(binder, "druid.metadata.storage.tables", MetadataStorageTablesConfig.class);
}
@Provides
@LazySingleton
public ObjectMapper jsonMapper() {
return new DefaultObjectMapper();
}
});
Properties props = injector.getInstance(Properties.class);
MetadataStorageTablesConfig config = injector.getInstance(MetadataStorageTablesConfig.class);
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.base"), config.getBase());
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.segments"), config.getSegmentsTable());
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.rules"), config.getRulesTable());
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.config"), config.getConfigTable());
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.tasks"), config.getEntryTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE));
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.taskLog"), config.getLogTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE));
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.taskLock"), config.getLockTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE));
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.dataSource"), config.getDataSourceTable());
Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.supervisors"), config.getSupervisorTable());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class QueryGranularityTest method testSerializeDuration.
@Test
public void testSerializeDuration() throws Exception {
ObjectMapper mapper = new DefaultObjectMapper();
String json = "{ \"type\": \"duration\", \"duration\": \"3600000\" }";
Granularity gran = mapper.readValue(json, Granularity.class);
Assert.assertEquals(new DurationGranularity(3600000, null), gran);
json = "{ \"type\": \"duration\", \"duration\": \"5\", \"origin\": \"2012-09-01T00:00:00.002Z\" }";
gran = mapper.readValue(json, Granularity.class);
Assert.assertEquals(new DurationGranularity(5, 2), gran);
DurationGranularity expected = new DurationGranularity(5, 2);
Assert.assertEquals(expected, mapper.readValue(mapper.writeValueAsString(expected), Granularity.class));
String illegalJson = "{ \"type\": \"duration\", \"duration\": \"0\" }";
try {
mapper.readValue(illegalJson, Granularity.class);
Assert.fail();
} catch (JsonMappingException e) {
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class DataSourceMetadataQueryTest method testContextSerde.
@Test
public void testContextSerde() throws Exception {
final DataSourceMetadataQuery query = Druids.newDataSourceMetadataQueryBuilder().dataSource("foo").intervals("2013/2014").context(ImmutableMap.<String, Object>of("priority", 1, "useCache", true, "populateCache", "true", "finalize", true)).build();
final ObjectMapper mapper = new DefaultObjectMapper();
final Query serdeQuery = mapper.readValue(mapper.writeValueAsBytes(mapper.readValue(mapper.writeValueAsString(query), Query.class)), Query.class);
Assert.assertEquals(1, serdeQuery.getContextValue("priority"));
Assert.assertEquals(true, serdeQuery.getContextValue("useCache"));
Assert.assertEquals("true", serdeQuery.getContextValue("populateCache"));
Assert.assertEquals(true, serdeQuery.getContextValue("finalize"));
Assert.assertEquals(true, serdeQuery.getContextBoolean("useCache", false));
Assert.assertEquals(true, serdeQuery.getContextBoolean("populateCache", false));
Assert.assertEquals(true, serdeQuery.getContextBoolean("finalize", false));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class AggregationTestHelper method createGroupByQueryAggregationTestHelper.
public static final AggregationTestHelper createGroupByQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, GroupByQueryConfig config, TemporaryFolder tempFolder) {
ObjectMapper mapper = new DefaultObjectMapper();
GroupByQueryRunnerFactory factory = GroupByQueryRunnerTest.makeQueryRunnerFactory(mapper, config);
IndexIO indexIO = new IndexIO(mapper, new ColumnConfig() {
@Override
public int columnCacheSizeBytes() {
return 0;
}
});
return new AggregationTestHelper(mapper, new IndexMerger(mapper, indexIO), indexIO, factory.getToolchest(), factory, tempFolder, jsonModulesToRegister);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class AggregationTestHelper method createTopNQueryAggregationTestHelper.
public static final AggregationTestHelper createTopNQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, TemporaryFolder tempFolder) {
ObjectMapper mapper = new DefaultObjectMapper();
TopNQueryQueryToolChest toolchest = new TopNQueryQueryToolChest(new TopNQueryConfig(), QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator());
TopNQueryRunnerFactory factory = new TopNQueryRunnerFactory(new StupidPool<>("TopNQueryRunnerFactory-bufferPool", new Supplier<ByteBuffer>() {
@Override
public ByteBuffer get() {
return ByteBuffer.allocate(10 * 1024 * 1024);
}
}), toolchest, QueryRunnerTestHelper.NOOP_QUERYWATCHER);
IndexIO indexIO = new IndexIO(mapper, new ColumnConfig() {
@Override
public int columnCacheSizeBytes() {
return 0;
}
});
return new AggregationTestHelper(mapper, new IndexMerger(mapper, indexIO), indexIO, toolchest, factory, tempFolder, jsonModulesToRegister);
}
Aggregations