use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class GraphiteEmitterConfigTest method testSerDeserDruidToGraphiteEventConverter.
@Test
public void testSerDeserDruidToGraphiteEventConverter() throws IOException {
SendAllGraphiteEventConverter sendAllGraphiteEventConverter = new SendAllGraphiteEventConverter("prefix", true, true);
String noopGraphiteEventConverterString = mapper.writeValueAsString(sendAllGraphiteEventConverter);
DruidToGraphiteEventConverter druidToGraphiteEventConverter = mapper.reader(DruidToGraphiteEventConverter.class).readValue(noopGraphiteEventConverterString);
Assert.assertEquals(druidToGraphiteEventConverter, sendAllGraphiteEventConverter);
WhiteListBasedConverter whiteListBasedConverter = new WhiteListBasedConverter("prefix", true, true, "", new DefaultObjectMapper());
String whiteListBasedConverterString = mapper.writeValueAsString(whiteListBasedConverter);
druidToGraphiteEventConverter = mapper.reader(DruidToGraphiteEventConverter.class).readValue(whiteListBasedConverterString);
Assert.assertEquals(druidToGraphiteEventConverter, whiteListBasedConverter);
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class CloudFilesDataSegmentPusherTest method testPush.
@Test
public void testPush() throws Exception {
ObjectApi objectApi = EasyMock.createStrictMock(ObjectApi.class);
EasyMock.expect(objectApi.put(EasyMock.anyString(), EasyMock.<Payload>anyObject())).andReturn(null).atLeastOnce();
EasyMock.replay(objectApi);
CloudFilesApi api = EasyMock.createStrictMock(CloudFilesApi.class);
EasyMock.expect(api.getObjectApi(EasyMock.anyString(), EasyMock.anyString())).andReturn(objectApi).atLeastOnce();
EasyMock.replay(api);
CloudFilesDataSegmentPusherConfig config = new CloudFilesDataSegmentPusherConfig();
config.setRegion("region");
config.setContainer("container");
config.setBasePath("basePath");
CloudFilesDataSegmentPusher pusher = new CloudFilesDataSegmentPusher(api, config, new DefaultObjectMapper());
// Create a mock segment on disk
File tmp = tempFolder.newFile("version.bin");
final byte[] data = new byte[] { 0x0, 0x0, 0x0, 0x1 };
Files.write(data, tmp);
final long size = data.length;
DataSegment segmentToPush = new DataSegment("foo", new Interval("2015/2016"), "0", Maps.<String, Object>newHashMap(), Lists.<String>newArrayList(), Lists.<String>newArrayList(), NoneShardSpec.instance(), 0, size);
DataSegment segment = pusher.push(tempFolder.getRoot(), segmentToPush);
Assert.assertEquals(segmentToPush.getSize(), segment.getSize());
EasyMock.verify(api);
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class VirtualColumnsTest method testSerde.
@Test
public void testSerde() throws Exception {
final ObjectMapper mapper = new DefaultObjectMapper();
final ImmutableList<VirtualColumn> theColumns = ImmutableList.<VirtualColumn>of(new ExpressionVirtualColumn("expr", "x + y"), new ExpressionVirtualColumn("expr2", "x + z"));
final VirtualColumns virtualColumns = VirtualColumns.create(theColumns);
Assert.assertEquals(virtualColumns, mapper.readValue(mapper.writeValueAsString(virtualColumns), VirtualColumns.class));
Assert.assertEquals(theColumns, mapper.readValue(mapper.writeValueAsString(virtualColumns), mapper.getTypeFactory().constructParametricType(List.class, VirtualColumn.class)));
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class BitmapSerdeFactoryTest method testSerialization.
@Test
public void testSerialization() throws Exception {
ObjectMapper mapper = new DefaultObjectMapper();
Assert.assertEquals("{\"type\":\"roaring\",\"compressRunOnSerialization\":true}", mapper.writeValueAsString(new RoaringBitmapSerdeFactory(null)));
Assert.assertEquals("{\"type\":\"roaring\",\"compressRunOnSerialization\":false}", mapper.writeValueAsString(new RoaringBitmapSerdeFactory(false)));
Assert.assertEquals("{\"type\":\"roaring\",\"compressRunOnSerialization\":true}", mapper.writeValueAsString(new RoaringBitmapSerdeFactory(true)));
Assert.assertEquals("{\"type\":\"concise\"}", mapper.writeValueAsString(new ConciseBitmapSerdeFactory()));
Assert.assertEquals("{\"type\":\"concise\"}", mapper.writeValueAsString(BitmapSerde.createLegacyFactory()));
Assert.assertEquals("{\"type\":\"concise\"}", mapper.writeValueAsString(new BitmapSerde.DefaultBitmapSerdeFactory()));
Assert.assertEquals("{\"type\":\"concise\"}", mapper.writeValueAsString(new BitmapSerde.LegacyBitmapSerdeFactory()));
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class BitmapSerdeFactoryTest method testDeserialization.
@Test
public void testDeserialization() throws Exception {
ObjectMapper mapper = new DefaultObjectMapper();
final BitmapSerdeFactory roaringFactory = mapper.readValue("{\"type\":\"roaring\"}", BitmapSerdeFactory.class);
Assert.assertTrue(roaringFactory instanceof RoaringBitmapSerdeFactory);
Assert.assertTrue(((RoaringBitmapSerdeFactory) roaringFactory).getCompressRunOnSerialization());
final BitmapSerdeFactory compressingRoaringFactory = mapper.readValue("{\"type\":\"roaring\", \"compressRunOnSerialization\":false}", BitmapSerdeFactory.class);
Assert.assertTrue(compressingRoaringFactory instanceof RoaringBitmapSerdeFactory);
Assert.assertFalse(((RoaringBitmapSerdeFactory) compressingRoaringFactory).getCompressRunOnSerialization());
Assert.assertTrue(mapper.readValue("{\"type\":\"concise\"}", BitmapSerdeFactory.class) instanceof ConciseBitmapSerdeFactory);
Assert.assertTrue(mapper.readValue("{\"type\":\"BitmapSerde$SomeRandomClass\"}", BitmapSerdeFactory.class) instanceof ConciseBitmapSerdeFactory);
}
Aggregations