use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class MockMemcachedClient method testMonitor.
@Test
public void testMonitor() throws Exception {
final MemcachedCache cache = MemcachedCache.create(memcachedCacheConfig);
final Emitter emitter = EasyMock.createNiceMock(Emitter.class);
final Collection<Event> events = new ArrayList<>();
final ServiceEmitter serviceEmitter = new ServiceEmitter("service", "host", emitter) {
@Override
public void emit(Event event) {
events.add(event);
}
};
while (events.isEmpty()) {
Thread.sleep(memcachedCacheConfig.getTimeout());
cache.doMonitor(serviceEmitter);
}
Assert.assertFalse(events.isEmpty());
ObjectMapper mapper = new DefaultObjectMapper();
for (Event event : events) {
log.debug("Found event `%s`", mapper.writeValueAsString(event.toMap()));
}
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class IndexSpecTest method testSerdeUncompressed.
@Test
public void testSerdeUncompressed() throws Exception {
final ObjectMapper objectMapper = new DefaultObjectMapper();
final String json = "{ \"dimensionCompression\" : \"uncompressed\" }";
final IndexSpec spec = objectMapper.readValue(json, IndexSpec.class);
Assert.assertEquals(CompressedObjectStrategy.CompressionStrategy.UNCOMPRESSED, spec.getDimensionCompression());
Assert.assertEquals(spec, objectMapper.readValue(objectMapper.writeValueAsBytes(spec), IndexSpec.class));
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class MetadataTest method testSerde.
@Test
public void testSerde() throws Exception {
ObjectMapper jsonMapper = new DefaultObjectMapper();
Metadata metadata = new Metadata();
metadata.put("k", "v");
AggregatorFactory[] aggregators = new AggregatorFactory[] { new LongSumAggregatorFactory("out", "in") };
metadata.setAggregators(aggregators);
metadata.setQueryGranularity(Granularities.ALL);
metadata.setRollup(Boolean.FALSE);
Metadata other = jsonMapper.readValue(jsonMapper.writeValueAsString(metadata), Metadata.class);
Assert.assertEquals(metadata, other);
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class AzureDataSegmentPusherTest method before.
@Before
public void before() {
azureStorage = createMock(AzureStorage.class);
azureAccountConfig = new AzureAccountConfig();
azureAccountConfig.setAccount("account");
azureAccountConfig.setContainer("container");
jsonMapper = new DefaultObjectMapper();
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class HadoopDruidConverterConfigTest method simpleSerDe.
@Test
public void simpleSerDe() throws IOException {
final HadoopDruidConverterConfig config = new HadoopDruidConverterConfig("datasource", Interval.parse("2000/2010"), new IndexSpec(), ImmutableList.<DataSegment>of(), true, URI.create("file:/dev/null"), ImmutableMap.<String, String>of(), "HIGH", temporaryFolder.newFolder().getAbsolutePath());
final ObjectMapper mapper = new DefaultObjectMapper();
mapper.registerSubtypes(HadoopDruidConverterConfig.class);
final byte[] value = mapper.writeValueAsBytes(config);
final HadoopDruidConverterConfig config2 = mapper.readValue(value, HadoopDruidConverterConfig.class);
Assert.assertEquals(mapper.writeValueAsString(config), mapper.writeValueAsString(config2));
}
Aggregations