use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SegmentIdWithShardSpecTest method testSerde.
@Test
public void testSerde() throws Exception {
final ObjectMapper objectMapper = new DefaultObjectMapper();
objectMapper.registerSubtypes(NumberedShardSpec.class);
final SegmentIdWithShardSpec id2 = objectMapper.readValue(objectMapper.writeValueAsBytes(ID_1), SegmentIdWithShardSpec.class);
Assert.assertEquals(ID_1, id2);
Assert.assertEquals(DATA_SOURCE, id2.getDataSource());
Assert.assertEquals(INTERVAL, id2.getInterval());
Assert.assertEquals(VERSION, id2.getVersion());
Assert.assertEquals(SHARD_SPEC_1.getPartitionNum(), id2.getShardSpec().getPartitionNum());
Assert.assertEquals(SHARD_SPEC_1.getNumCorePartitions(), id2.getShardSpec().getNumCorePartitions());
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SegmentWithStateTest method testSerdeForBackwardCompatibility.
@Test
public void testSerdeForBackwardCompatibility() throws IOException {
final ObjectMapper objectMapper = new DefaultObjectMapper();
Assert.assertEquals(SegmentWithState.SegmentState.APPENDING, objectMapper.readValue("\"ACTIVE\"", SegmentWithState.SegmentState.class));
Assert.assertEquals(SegmentWithState.SegmentState.APPEND_FINISHED, objectMapper.readValue("\"INACTIVE\"", SegmentWithState.SegmentState.class));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class FloatFirstAggregationTest method testSerde.
@Test
public void testSerde() throws Exception {
DefaultObjectMapper mapper = new DefaultObjectMapper();
String floatSpecJson = "{\"type\":\"floatFirst\",\"name\":\"billy\",\"fieldName\":\"nilly\"}";
AggregatorFactory deserialized = mapper.readValue(floatSpecJson, AggregatorFactory.class);
Assert.assertEquals(floatFirstAggregatorFactory, deserialized);
Assert.assertArrayEquals(floatFirstAggregatorFactory.getCacheKey(), deserialized.getCacheKey());
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class DoubleAnyAggregationTest method testSerde.
@Test
public void testSerde() throws Exception {
DefaultObjectMapper mapper = new DefaultObjectMapper();
String doubleSpecJson = "{\"type\":\"doubleAny\",\"name\":\"billy\",\"fieldName\":\"nilly\"}";
Assert.assertEquals(doubleAnyAggFactory, mapper.readValue(doubleSpecJson, AggregatorFactory.class));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class LongAnyAggregationTest method testSerde.
@Test
public void testSerde() throws Exception {
DefaultObjectMapper mapper = new DefaultObjectMapper();
String longSpecJson = "{\"type\":\"longAny\",\"name\":\"billy\",\"fieldName\":\"nilly\"}";
Assert.assertEquals(longAnyAggFactory, mapper.readValue(longSpecJson, AggregatorFactory.class));
}
Aggregations