use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class DimFilterHavingSpecTest method testSerde.
@Test
public void testSerde() throws Exception {
final DimFilterHavingSpec havingSpec = new DimFilterHavingSpec(new SelectorDimFilter("foo", "1", null), false);
final ObjectMapper objectMapper = new DefaultObjectMapper();
Assert.assertEquals(havingSpec, objectMapper.readValue(objectMapper.writeValueAsBytes(havingSpec), HavingSpec.class));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class LookupExtractorTest method testSerDes.
@Test
public void testSerDes() throws IOException {
ObjectMapper mapper = new DefaultObjectMapper();
Assert.assertEquals(lookupExtractor, mapper.readerFor(LookupExtractor.class).readValue(mapper.writeValueAsBytes(lookupExtractor)));
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SearchQueryQueryToolChestTest method testCacheStrategy.
@Test
public void testCacheStrategy() throws Exception {
CacheStrategy<Result<SearchResultValue>, Object, SearchQuery> strategy = new SearchQueryQueryToolChest(null, null).getCacheStrategy(new SearchQuery(new TableDataSource("dummy"), null, Granularities.ALL, 1, new MultipleIntervalSegmentSpec(ImmutableList.of(Intervals.of("2015-01-01/2015-01-02"))), ImmutableList.of(Druids.DIMENSION_IDENTITY.apply("dim1")), new FragmentSearchQuerySpec(ImmutableList.of("a", "b")), null, null));
final Result<SearchResultValue> result = new Result<>(DateTimes.utc(123L), new SearchResultValue(ImmutableList.of(new SearchHit("dim1", "a"))));
Object preparedValue = strategy.prepareForSegmentLevelCache().apply(result);
ObjectMapper objectMapper = new DefaultObjectMapper();
Object fromCacheValue = objectMapper.readValue(objectMapper.writeValueAsBytes(preparedValue), strategy.getCacheObjectClazz());
Result<SearchResultValue> fromCacheResult = strategy.pullFromSegmentLevelCache().apply(fromCacheValue);
Assert.assertEquals(result, fromCacheResult);
}
use of org.apache.druid.jackson.DefaultObjectMapper in project druid by druid-io.
the class SearchSortSpecTest method testSerde.
@Test
public void testSerde() throws IOException {
ObjectMapper jsonMapper = new DefaultObjectMapper();
SearchSortSpec spec = new SearchSortSpec(StringComparators.ALPHANUMERIC);
String expectJsonSpec = "{\"type\":{\"type\":\"alphanumeric\"}}";
String jsonSpec = jsonMapper.writeValueAsString(spec);
Assert.assertEquals(expectJsonSpec, jsonSpec);
Assert.assertEquals(spec, jsonMapper.readValue(jsonSpec, SearchSortSpec.class));
String expectJsonSpec2 = "{\"type\":\"alphanumeric\"}";
Assert.assertEquals(spec, jsonMapper.readValue(expectJsonSpec2, SearchSortSpec.class));
}
use of org.apache.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));
}
Aggregations