use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class DimensionSelectorHavingSpecTest method testDimSelectorHavingClauseSerde.
@Test
public void testDimSelectorHavingClauseSerde() throws Exception {
HavingSpec dimHavingSpec = new DimensionSelectorHavingSpec("dim", "v", null);
Map<String, Object> dimSelectMap = ImmutableMap.<String, Object>of("type", "dimSelector", "dimension", "dim", "value", "v");
ObjectMapper mapper = new DefaultObjectMapper();
assertEquals(dimHavingSpec, mapper.convertValue(dimSelectMap, DimensionSelectorHavingSpec.class));
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class HavingSpecTest method testTypeTypo.
@Test(expected = IllegalArgumentException.class)
public void testTypeTypo() {
Map<String, Object> greaterMap = ImmutableMap.<String, Object>of("type", "nonExistingType", "aggregation", "agg", "value", 1.3);
ObjectMapper mapper = new DefaultObjectMapper();
HavingSpec spec = mapper.convertValue(greaterMap, HavingSpec.class);
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class StringComparatorsTest method testLexicographicComparatorSerdeTest.
@Test
public void testLexicographicComparatorSerdeTest() throws IOException {
ObjectMapper jsonMapper = new DefaultObjectMapper();
String expectJsonSpec = "{\"type\":\"lexicographic\"}";
String jsonSpec = jsonMapper.writeValueAsString(StringComparators.LEXICOGRAPHIC);
Assert.assertEquals(expectJsonSpec, jsonSpec);
Assert.assertEquals(StringComparators.LEXICOGRAPHIC, jsonMapper.readValue(expectJsonSpec, StringComparator.class));
String makeFromJsonSpec = "\"lexicographic\"";
Assert.assertEquals(StringComparators.LEXICOGRAPHIC, jsonMapper.readValue(makeFromJsonSpec, StringComparator.class));
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class StringComparatorsTest method testNumericComparatorSerdeTest.
@Test
public void testNumericComparatorSerdeTest() throws IOException {
ObjectMapper jsonMapper = new DefaultObjectMapper();
String expectJsonSpec = "{\"type\":\"numeric\"}";
String jsonSpec = jsonMapper.writeValueAsString(StringComparators.NUMERIC);
Assert.assertEquals(expectJsonSpec, jsonSpec);
Assert.assertEquals(StringComparators.NUMERIC, jsonMapper.readValue(expectJsonSpec, StringComparator.class));
String makeFromJsonSpec = "\"numeric\"";
Assert.assertEquals(StringComparators.NUMERIC, jsonMapper.readValue(makeFromJsonSpec, StringComparator.class));
makeFromJsonSpec = "\"NuMeRiC\"";
Assert.assertEquals(StringComparators.NUMERIC, jsonMapper.readValue(makeFromJsonSpec, StringComparator.class));
}
use of io.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SpecificSegmentQueryRunnerTest method testRetry.
@Test
public void testRetry() throws Exception {
final ObjectMapper mapper = new DefaultObjectMapper();
SegmentDescriptor descriptor = new SegmentDescriptor(new Interval("2012-01-01T00:00:00Z/P1D"), "version", 0);
final SpecificSegmentQueryRunner queryRunner = new SpecificSegmentQueryRunner(new QueryRunner() {
@Override
public Sequence run(Query query, Map responseContext) {
return new Sequence() {
@Override
public Object accumulate(Object initValue, Accumulator accumulator) {
throw new SegmentMissingException("FAILSAUCE");
}
@Override
public Yielder<Object> toYielder(Object initValue, YieldingAccumulator accumulator) {
throw new SegmentMissingException("FAILSAUCE");
}
};
}
}, new SpecificSegmentSpec(descriptor));
// from accumulate
Map<String, Object> responseContext = Maps.newHashMap();
TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("foo").granularity(Granularities.ALL).intervals(ImmutableList.of(new Interval("2012-01-01T00:00:00Z/P1D"))).aggregators(ImmutableList.<AggregatorFactory>of(new CountAggregatorFactory("rows"))).build();
Sequence results = queryRunner.run(query, responseContext);
Sequences.toList(results, Lists.newArrayList());
validate(mapper, descriptor, responseContext);
// from toYielder
responseContext = Maps.newHashMap();
results = queryRunner.run(query, responseContext);
results.toYielder(null, new YieldingAccumulator() {
final List lists = Lists.newArrayList();
@Override
public Object accumulate(Object accumulated, Object in) {
lists.add(in);
return in;
}
});
validate(mapper, descriptor, responseContext);
}
Aggregations