use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper 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 org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper 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 org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper in project druid by druid-io.
the class DefaultLimitSpecTest method testSerde.
@Test
public void testSerde() throws Exception {
ObjectMapper mapper = TestHelper.getObjectMapper();
//defaults
String json = "{\"type\": \"default\"}";
DefaultLimitSpec spec = mapper.readValue(mapper.writeValueAsString(mapper.readValue(json, DefaultLimitSpec.class)), DefaultLimitSpec.class);
Assert.assertEquals(new DefaultLimitSpec(null, null), spec);
//non-defaults
json = "{\n" + " \"type\":\"default\",\n" + " \"columns\":[{\"dimension\":\"d\",\"direction\":\"DESCENDING\", \"dimensionOrder\":\"numeric\"}],\n" + " \"limit\":10\n" + "}";
spec = mapper.readValue(mapper.writeValueAsString(mapper.readValue(json, DefaultLimitSpec.class)), DefaultLimitSpec.class);
Assert.assertEquals(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("d", OrderByColumnSpec.Direction.DESCENDING, StringComparators.NUMERIC)), 10), spec);
json = "{\n" + " \"type\":\"default\",\n" + " \"columns\":[{\"dimension\":\"d\",\"direction\":\"DES\", \"dimensionOrder\":\"numeric\"}],\n" + " \"limit\":10\n" + "}";
spec = mapper.readValue(mapper.writeValueAsString(mapper.readValue(json, DefaultLimitSpec.class)), DefaultLimitSpec.class);
Assert.assertEquals(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("d", OrderByColumnSpec.Direction.DESCENDING, StringComparators.NUMERIC)), 10), spec);
json = "{\n" + " \"type\":\"default\",\n" + " \"columns\":[{\"dimension\":\"d\"}],\n" + " \"limit\":10\n" + "}";
spec = mapper.readValue(mapper.writeValueAsString(mapper.readValue(json, DefaultLimitSpec.class)), DefaultLimitSpec.class);
Assert.assertEquals(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("d", OrderByColumnSpec.Direction.ASCENDING, StringComparators.LEXICOGRAPHIC)), 10), spec);
json = "{\n" + " \"type\":\"default\",\n" + " \"columns\":[\"d\"],\n" + " \"limit\":10\n" + "}";
spec = mapper.readValue(mapper.writeValueAsString(mapper.readValue(json, DefaultLimitSpec.class)), DefaultLimitSpec.class);
Assert.assertEquals(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("d", OrderByColumnSpec.Direction.ASCENDING, StringComparators.LEXICOGRAPHIC)), 10), spec);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper 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 org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper 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));
}
Aggregations