diff --git a/processing/src/main/java/io/druid/query/datasourcemetadata/DataSourceMetadataQuery.java b/processing/src/main/java/io/druid/query/datasourcemetadata/DataSourceMetadataQuery.java index 9b21f57f5ed..da1b8e1307e 100644 --- a/processing/src/main/java/io/druid/query/datasourcemetadata/DataSourceMetadataQuery.java +++ b/processing/src/main/java/io/druid/query/datasourcemetadata/DataSourceMetadataQuery.java @@ -22,7 +22,6 @@ package io.druid.query.datasourcemetadata; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import io.druid.common.utils.JodaUtils; import io.druid.query.BaseQuery; import io.druid.query.DataSource; @@ -45,9 +44,6 @@ public class DataSourceMetadataQuery extends BaseQueryof( - "priority", - 1, - "useCache", - true, - "populateCache", - true, - "finalize", - true - ) - ).build(); + .dataSource("foo") + .intervals("2013/2014") + .context( + ImmutableMap.of( + "priority", + 1, + "useCache", + true, + "populateCache", + true, + "finalize", + true + ) + ).build(); final ObjectMapper mapper = new DefaultObjectMapper(); @@ -113,7 +113,8 @@ public class DataSourceMetadataQueryTest { final IncrementalIndex rtIndex = new OnheapIncrementalIndex( 0L, QueryGranularity.NONE, new AggregatorFactory[]{new CountAggregatorFactory("count")}, 1000 - );; + ); + ; final QueryRunner runner = QueryRunnerTestHelper.makeQueryRunner( (QueryRunnerFactory) new DataSourceMetadataQueryRunnerFactory( QueryRunnerTestHelper.NOOP_QUERYWATCHER @@ -128,8 +129,8 @@ public class DataSourceMetadataQueryTest ) ); DataSourceMetadataQuery dataSourceMetadataQuery = Druids.newDataSourceMetadataQueryBuilder() - .dataSource("testing") - .build(); + .dataSource("testing") + .build(); Map context = new MapMaker().makeMap(); context.put(Result.MISSING_SEGMENTS_KEY, Lists.newArrayList()); Iterable> results = Sequences.toList( @@ -209,4 +210,34 @@ public class DataSourceMetadataQueryTest } } + @Test + public void testResultSerialization() + { + final DataSourceMetadataResultValue resultValue = new DataSourceMetadataResultValue(new DateTime("2000-01-01T00Z")); + final Map resultValueMap = new DefaultObjectMapper().convertValue( + resultValue, + new TypeReference>() + { + } + ); + Assert.assertEquals( + ImmutableMap.of("maxIngestedEventTime", "2000-01-01T00:00:00.000Z"), + resultValueMap + ); + } + + @Test + public void testResultDeserialization() + { + final Map resultValueMap = ImmutableMap.of( + "maxIngestedEventTime", + "2000-01-01T00:00:00.000Z" + ); + final DataSourceMetadataResultValue resultValue = new DefaultObjectMapper().convertValue( + resultValueMap, + DataSourceMetadataResultValue.class + ); + Assert.assertEquals(new DateTime("2000"), resultValue.getMaxIngestedEventTime()); + } + }