From 3940a8c0ff8c129402191bbeeb92713ba7a8e0cc Mon Sep 17 00:00:00 2001 From: Jonasz Czerepko Date: Sat, 29 Feb 2020 15:30:58 +0100 Subject: [PATCH 1/2] Removed JodaTime dependency - migrated to java.time. --- pom.xml | 13 ---- .../granularity/DurationGranularity.java | 13 ++-- .../granularity/PeriodGranularity.java | 18 ++--- .../druid/druidry/query/config/Interval.java | 16 +++-- .../dataSource/QueryDataSourceTest.java | 27 ++++---- .../TimeFormatExtractionFunctionTest.java | 17 ++--- .../druidry/filter/IntervalFilterTest.java | 25 ++++--- .../granularity/DurationGranularityTest.java | 15 ++-- .../granularity/PeriodGranularityTest.java | 34 ++++----- .../granularity/SimpleGranularityTest.java | 8 ++- .../query/aggregation/GroupByTest.java | 57 ++++++++------- .../query/aggregation/TimeSeriesTest.java | 51 +++++++------- .../query/aggregation/TopNQueryTest.java | 69 +++++++++++-------- .../druidry/query/config/IntervalTest.java | 20 +++--- .../query/scan/DruidScanQueryTest.java | 67 +++++++++--------- .../query/search/DruidSearchQueryTest.java | 55 ++++++++------- .../query/select/DruidSelectQueryTest.java | 53 +++++++------- 17 files changed, 287 insertions(+), 271 deletions(-) diff --git a/pom.xml b/pom.xml index e442e540..f51fab74 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,6 @@ UTF-8 2.9.10.1 2.9.9 - 2.9.7 1.18.10 6.11 1.2.1 @@ -30,24 +29,12 @@ - - joda-time - joda-time - ${jodatime.version} - - com.fasterxml.jackson.core jackson-databind ${jackson.databind.version} - - com.fasterxml.jackson.datatype - jackson-datatype-joda - ${jackson.datatype.version} - - org.projectlombok lombok diff --git a/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java b/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java index 50e08688..0821b55a 100644 --- a/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java +++ b/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java @@ -16,14 +16,15 @@ package in.zapr.druid.druidry.granularity; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; - -import org.joda.time.DateTime; - import lombok.EqualsAndHashCode; import lombok.Getter; +import java.time.temporal.Temporal; + @Getter @JsonInclude(JsonInclude.Include.NON_NULL) @EqualsAndHashCode(callSuper = true) @@ -34,19 +35,19 @@ public class DurationGranularity extends Granularity { private final String type; @JsonProperty("duration") private long durationInMilliSeconds; - private DateTime origin; + private Temporal origin; public DurationGranularity(long durationInMilliSeconds) { this(durationInMilliSeconds, null); } - public DurationGranularity(long durationInMilliSeconds, DateTime origin) { + public DurationGranularity(long durationInMilliSeconds, Temporal origin) { this.type = DURATION_GRANULARITY_TYPE; this.durationInMilliSeconds = durationInMilliSeconds; this.origin = origin; } public String getOrigin() { - return origin == null ? null : origin.toDateTimeISO().toString(); + return origin == null ? null : ISO_DATE_TIME.format(origin); } } \ No newline at end of file diff --git a/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java b/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java index bc2437b4..896e51bd 100644 --- a/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java +++ b/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java @@ -16,20 +16,22 @@ package in.zapr.druid.druidry.granularity; -import com.fasterxml.jackson.annotation.JsonInclude; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; +import java.time.ZoneId; +import java.time.ZonedDateTime; + @Builder @Getter @JsonInclude(JsonInclude.Include.NON_NULL) @EqualsAndHashCode(callSuper = true) public class PeriodGranularity extends Granularity { + private static final String PERIOD_GRANULARITY_TYPE = "period"; private static final String DEFAULT_TIMEZONE = "UTC"; @@ -40,14 +42,14 @@ public class PeriodGranularity extends Granularity { private String period; // TODO: Check if it is alright - private DateTimeZone timeZone; - private DateTime origin; + private ZoneId timeZone; + private ZonedDateTime origin; public String getOrigin() { - return origin == null ? null : origin.toDateTimeISO().toString(); + return origin == null ? null : ISO_DATE_TIME.format(origin); } public String getTimeZone() { - return timeZone == null ? DEFAULT_TIMEZONE : timeZone.getID(); + return timeZone == null ? DEFAULT_TIMEZONE : timeZone.getId(); } } \ No newline at end of file diff --git a/src/main/java/in/zapr/druid/druidry/query/config/Interval.java b/src/main/java/in/zapr/druid/druidry/query/config/Interval.java index 150694d2..87c995e1 100644 --- a/src/main/java/in/zapr/druid/druidry/query/config/Interval.java +++ b/src/main/java/in/zapr/druid/druidry/query/config/Interval.java @@ -17,29 +17,31 @@ package in.zapr.druid.druidry.query.config; import com.fasterxml.jackson.annotation.JsonValue; - -import org.joda.time.DateTime; - import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAccessor; + @Getter @EqualsAndHashCode public class Interval { + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + private final static String DRUID_INTERVAL_FORMAT = "%s/%s"; - private DateTime startTime; - private DateTime endTime; + private TemporalAccessor startTime; + private TemporalAccessor endTime; - public Interval(@NonNull DateTime startTime, @NonNull DateTime endTime) { + public Interval(@NonNull TemporalAccessor startTime, @NonNull TemporalAccessor endTime) { this.startTime = startTime; this.endTime = endTime; } @JsonValue private String getIntervalAsString() { - return String.format(DRUID_INTERVAL_FORMAT, startTime.toDateTimeISO(), endTime.toDateTimeISO()); + return String.format(DRUID_INTERVAL_FORMAT, FORMATTER.format(startTime), FORMATTER.format(endTime)); } } \ No newline at end of file diff --git a/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java b/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java index 5902de9a..b6edac54 100644 --- a/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java +++ b/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java @@ -18,9 +18,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; +import in.zapr.druid.druidry.dimension.DruidDimension; +import in.zapr.druid.druidry.dimension.SimpleDimension; +import in.zapr.druid.druidry.granularity.Granularity; +import in.zapr.druid.druidry.granularity.PredefinedGranularity; +import in.zapr.druid.druidry.granularity.SimpleGranularity; +import in.zapr.druid.druidry.query.aggregation.DruidGroupByQuery; +import in.zapr.druid.druidry.query.config.Interval; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -29,17 +33,12 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; import java.util.Arrays; import java.util.Collections; -import in.zapr.druid.druidry.dimension.DruidDimension; -import in.zapr.druid.druidry.dimension.SimpleDimension; -import in.zapr.druid.druidry.granularity.Granularity; -import in.zapr.druid.druidry.granularity.PredefinedGranularity; -import in.zapr.druid.druidry.granularity.SimpleGranularity; -import in.zapr.druid.druidry.query.aggregation.DruidGroupByQuery; -import in.zapr.druid.druidry.query.config.Interval; - public class QueryDataSourceTest { private static ObjectMapper objectMapper; @@ -55,8 +54,10 @@ public void testQueryDataSource() throws JsonProcessingException, JSONException Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); // Interval - DateTime startTime = new DateTime(2012, 1, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2012, 1, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2012, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2012, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidGroupByQuery druidGroupByQuery = DruidGroupByQuery.builder() diff --git a/src/test/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunctionTest.java b/src/test/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunctionTest.java index 5c77a0b8..7836c36a 100644 --- a/src/test/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunctionTest.java +++ b/src/test/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunctionTest.java @@ -16,21 +16,22 @@ package in.zapr.druid.druidry.extractionFunctions; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; +import in.zapr.druid.druidry.granularity.DurationGranularity; import org.json.JSONException; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; import java.util.Locale; -import in.zapr.druid.druidry.granularity.DurationGranularity; - public class TimeFormatExtractionFunctionTest { private static ObjectMapper objectMapper; @@ -48,7 +49,7 @@ public void testAllFields() throws JsonProcessingException, JSONException { String timeZone = "America/Montreal"; - DateTime originDate = new DateTime(DateTimeZone.UTC); + Temporal originDate = ZonedDateTime.now(ZoneOffset.UTC); DurationGranularity spec = new DurationGranularity(7200000, originDate); @@ -63,8 +64,8 @@ public void testAllFields() throws JsonProcessingException, JSONException { String actualJSON = objectMapper.writeValueAsString(timeFormatExtractonFunction); String expectedJSONString = "{\n\"type\" : \"timeFormat\",\n \"format\" : \"dd-MM-yyyy\",\n \"timeZone\" : \"America/Montreal\",\n \"locale\" : \"fr\",\n \"granularity\": {\"type\": \"duration\", \"duration\": 7200000, \"origin\": \"" + - originDate.toDateTimeISO() + - "\"},\n \"asMillis\": true\n\n }"; + ISO_DATE_TIME.format(originDate) + + "\"},\n \"asMillis\": true\n\n }"; JSONAssert.assertEquals(expectedJSONString, actualJSON, JSONCompareMode.NON_EXTENSIBLE); } diff --git a/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java b/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java index 516790d3..327b4232 100644 --- a/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java +++ b/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java @@ -18,9 +18,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; +import in.zapr.druid.druidry.query.config.Interval; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -29,11 +27,12 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; import java.util.ArrayList; import java.util.Arrays; -import in.zapr.druid.druidry.query.config.Interval; - public class IntervalFilterTest { private static ObjectMapper objectMapper; @@ -67,15 +66,15 @@ public void testFields() throws JsonProcessingException, JSONException { jsonObject.put("dimension", "__time"); jsonObject.put("intervals", intervalJsonArray); - DateTime startTimeInterval1 = new DateTime(2013, 8, 31, - 0, 0, 0, DateTimeZone.UTC); - DateTime endTimeInterval1 = new DateTime(2013, 9, 3, - 0, 0, 0, DateTimeZone.UTC); + Temporal startTimeInterval1 = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTimeInterval1 = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); - DateTime startTimeInterval2 = new DateTime(2018, 8, 31, - 0, 0, 0, DateTimeZone.UTC); - DateTime endTimeInterval2 = new DateTime(2018, 9, 3, - 0, 0, 0, DateTimeZone.UTC); + Temporal startTimeInterval2 = ZonedDateTime.of(2018, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTimeInterval2 = ZonedDateTime.of(2018, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval1 = new Interval(startTimeInterval1, endTimeInterval1); Interval interval2 = new Interval(startTimeInterval2, endTimeInterval2); diff --git a/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java b/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java index 26553ace..14370caa 100644 --- a/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java +++ b/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java @@ -16,11 +16,10 @@ package in.zapr.druid.druidry.granularity; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import org.json.JSONException; import org.json.JSONObject; import org.skyscreamer.jsonassert.JSONAssert; @@ -29,6 +28,10 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; + public class DurationGranularityTest { private static ObjectMapper objectMapper; @@ -41,12 +44,12 @@ public void init() { @Test public void testAllFields() throws JSONException, JsonProcessingException { - DateTime originDate = new DateTime(DateTimeZone.UTC); + Temporal originDate = ZonedDateTime.now(ZoneOffset.UTC); DurationGranularity granularity = new DurationGranularity(3141, originDate); JSONObject jsonObject = new JSONObject(); jsonObject.put("type", "duration"); jsonObject.put("duration", 3141L); - jsonObject.put("origin", originDate); + jsonObject.put("origin", ISO_DATE_TIME.format(originDate)); String actualJSON = objectMapper.writeValueAsString(granularity); String expectedJSON = jsonObject.toString(); @@ -85,7 +88,7 @@ public void testEqualsNegative() { public void testEqualsWithAnotherSubClass() { SimpleGranularity granularity1 = new SimpleGranularity(PredefinedGranularity.ALL); - DateTime originDate = new DateTime(DateTimeZone.UTC); + Temporal originDate = ZonedDateTime.now(ZoneOffset.UTC); DurationGranularity granularity2 = new DurationGranularity(3141, originDate); Assert.assertNotEquals(granularity1, granularity2); diff --git a/src/test/java/in/zapr/druid/druidry/granularity/PeriodGranularityTest.java b/src/test/java/in/zapr/druid/druidry/granularity/PeriodGranularityTest.java index 5937f95b..97c64665 100644 --- a/src/test/java/in/zapr/druid/druidry/granularity/PeriodGranularityTest.java +++ b/src/test/java/in/zapr/druid/druidry/granularity/PeriodGranularityTest.java @@ -16,11 +16,10 @@ package in.zapr.druid.druidry.granularity; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import org.json.JSONException; import org.json.JSONObject; import org.skyscreamer.jsonassert.JSONAssert; @@ -29,6 +28,9 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneId; +import java.time.ZonedDateTime; + public class PeriodGranularityTest { private final static String PERIOD = "PT1H"; private final static String TIMEZONE = "Asia/Kolkata"; @@ -42,17 +44,17 @@ public void init() { @Test public void testAllFields() throws JSONException, JsonProcessingException { - DateTime originDate = new DateTime(DateTimeZone.forID(TIMEZONE)); + ZonedDateTime originDate = ZonedDateTime.now(ZoneId.of(TIMEZONE)); PeriodGranularity periodGranularity = PeriodGranularity.builder() .origin(originDate) .period(PERIOD) - .timeZone(DateTimeZone.forID(TIMEZONE)) + .timeZone(ZoneId.of(TIMEZONE)) .build(); JSONObject jsonObject = new JSONObject(); jsonObject.put("type", "period"); jsonObject.put("period", PERIOD); jsonObject.put("timeZone", TIMEZONE); - jsonObject.put("origin", originDate); + jsonObject.put("origin", ISO_DATE_TIME.format(originDate)); String actualJSON = objectMapper.writeValueAsString(periodGranularity); String expectedJSON = jsonObject.toString(); @@ -61,18 +63,18 @@ public void testAllFields() throws JSONException, JsonProcessingException { @Test public void testEqualsPositive() { - DateTime originDate = new DateTime(DateTimeZone.forID(TIMEZONE)); + ZonedDateTime originDate = ZonedDateTime.now(ZoneId.of(TIMEZONE)); PeriodGranularity granularity1 = PeriodGranularity.builder() .origin(originDate) .period(PERIOD) - .timeZone(DateTimeZone.forID(TIMEZONE)) + .timeZone(ZoneId.of(TIMEZONE)) .build(); - DateTime originDate2 = new DateTime(originDate); + ZonedDateTime originDate2 = ZonedDateTime.from(originDate); PeriodGranularity granularity2 = PeriodGranularity.builder() .origin(originDate2) .period(PERIOD) - .timeZone(DateTimeZone.forID(TIMEZONE)) + .timeZone(ZoneId.of(TIMEZONE)) .build(); Assert.assertEquals(granularity1, granularity2); @@ -80,19 +82,19 @@ public void testEqualsPositive() { @Test public void testEqualsNegative() { - DateTime originDate = new DateTime(DateTimeZone.forID(TIMEZONE)); + ZonedDateTime originDate = ZonedDateTime.now(ZoneId.of(TIMEZONE)); PeriodGranularity granularity1 = PeriodGranularity.builder() .origin(originDate) .period(PERIOD) - .timeZone(DateTimeZone.forID(TIMEZONE)) + .timeZone(ZoneId.of(TIMEZONE)) .build(); - DateTime originDate2 = new DateTime(DateTimeZone.forID(TIMEZONE)); + ZonedDateTime originDate2 = ZonedDateTime.from(originDate); originDate2 = originDate2.plusDays(1); PeriodGranularity granularity2 = PeriodGranularity.builder() .origin(originDate2) .period(PERIOD) - .timeZone(DateTimeZone.forID(TIMEZONE)) + .timeZone(ZoneId.of(TIMEZONE)) .build(); Assert.assertNotEquals(granularity1, granularity2); @@ -102,11 +104,11 @@ public void testEqualsNegative() { public void testEqualsWithAnotherSubClass() { SimpleGranularity granularity1 = new SimpleGranularity(PredefinedGranularity.ALL); - DateTime originDate = new DateTime(DateTimeZone.forID(TIMEZONE)); + ZonedDateTime originDate = ZonedDateTime.now(ZoneId.of(TIMEZONE)); PeriodGranularity granularity2 = PeriodGranularity.builder() .origin(originDate) .period(PERIOD) - .timeZone(DateTimeZone.forID(TIMEZONE)) + .timeZone(ZoneId.of(TIMEZONE)) .build(); Assert.assertNotEquals(granularity1, granularity2); diff --git a/src/test/java/in/zapr/druid/druidry/granularity/SimpleGranularityTest.java b/src/test/java/in/zapr/druid/druidry/granularity/SimpleGranularityTest.java index fd2ee778..f815aa01 100644 --- a/src/test/java/in/zapr/druid/druidry/granularity/SimpleGranularityTest.java +++ b/src/test/java/in/zapr/druid/druidry/granularity/SimpleGranularityTest.java @@ -16,11 +16,13 @@ package in.zapr.druid.druidry.granularity; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import org.testng.Assert; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; + public class SimpleGranularityTest { @Test @@ -43,7 +45,7 @@ public void testEqualsNegative() { public void testEqualsWithAnotherSubClass() { SimpleGranularity granularity1 = new SimpleGranularity(PredefinedGranularity.ALL); - DateTime originDate = new DateTime(DateTimeZone.UTC); + Temporal originDate = ZonedDateTime.now(ZoneOffset.UTC); DurationGranularity granularity2 = new DurationGranularity(3141, originDate); Assert.assertNotEquals(granularity1, granularity2); diff --git a/src/test/java/in/zapr/druid/druidry/query/aggregation/GroupByTest.java b/src/test/java/in/zapr/druid/druidry/query/aggregation/GroupByTest.java index 51ae1ecd..eb42a0f1 100644 --- a/src/test/java/in/zapr/druid/druidry/query/aggregation/GroupByTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/aggregation/GroupByTest.java @@ -18,25 +18,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import in.zapr.druid.druidry.filter.havingSpec.HavingSpec; -import in.zapr.druid.druidry.filter.havingSpec.GreaterThanHaving; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import in.zapr.druid.druidry.query.config.Context; -import in.zapr.druid.druidry.query.config.Interval; import in.zapr.druid.druidry.aggregator.CountAggregator; import in.zapr.druid.druidry.aggregator.DoubleSumAggregator; import in.zapr.druid.druidry.aggregator.DruidAggregator; @@ -48,6 +29,8 @@ import in.zapr.druid.druidry.filter.DruidFilter; import in.zapr.druid.druidry.filter.OrFilter; import in.zapr.druid.druidry.filter.SelectorFilter; +import in.zapr.druid.druidry.filter.havingSpec.GreaterThanHaving; +import in.zapr.druid.druidry.filter.havingSpec.HavingSpec; import in.zapr.druid.druidry.granularity.Granularity; import in.zapr.druid.druidry.granularity.PredefinedGranularity; import in.zapr.druid.druidry.granularity.SimpleGranularity; @@ -59,6 +42,22 @@ import in.zapr.druid.druidry.postAggregator.ConstantPostAggregator; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; +import in.zapr.druid.druidry.query.config.Context; +import in.zapr.druid.druidry.query.config.Interval; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class GroupByTest { private static ObjectMapper objectMapper; @@ -149,8 +148,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { .build(); // Interval - DateTime startTime = new DateTime(2012, 1, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2012, 1, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2012, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2012, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidGroupByQuery query = DruidGroupByQuery.builder() @@ -166,7 +167,7 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { .build(); String actualJson = objectMapper.writeValueAsString(query); - JSONAssert.assertEquals(actualJson, expectedJsonAsString, JSONCompareMode.NON_EXTENSIBLE); + JSONAssert.assertEquals(expectedJsonAsString, actualJson, JSONCompareMode.NON_EXTENSIBLE); } @Test @@ -176,8 +177,10 @@ public void testRequiredFields() throws JSONException, JsonProcessingException { Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); // Interval - DateTime startTime = new DateTime(2012, 1, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2012, 1, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2012, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2012, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidGroupByQuery druidGroupByQuery = DruidGroupByQuery.builder() @@ -213,8 +216,10 @@ public void testAllFields() throws JSONException, JsonProcessingException { Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); // Interval - DateTime startTime = new DateTime(2012, 1, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2012, 1, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2012, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2012, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidFilter filter = new SelectorFilter("Spread", "Peace"); diff --git a/src/test/java/in/zapr/druid/druidry/query/aggregation/TimeSeriesTest.java b/src/test/java/in/zapr/druid/druidry/query/aggregation/TimeSeriesTest.java index fbf732d6..0fe54749 100644 --- a/src/test/java/in/zapr/druid/druidry/query/aggregation/TimeSeriesTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/aggregation/TimeSeriesTest.java @@ -18,23 +18,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.joda.JodaModule; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.Collections; - -import in.zapr.druid.druidry.query.config.Context; -import in.zapr.druid.druidry.query.config.Interval; import in.zapr.druid.druidry.aggregator.CountAggregator; import in.zapr.druid.druidry.aggregator.DoubleSumAggregator; import in.zapr.druid.druidry.aggregator.DruidAggregator; @@ -52,6 +35,21 @@ import in.zapr.druid.druidry.postAggregator.ConstantPostAggregator; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; +import in.zapr.druid.druidry.query.config.Context; +import in.zapr.druid.druidry.query.config.Interval; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; +import java.util.Arrays; +import java.util.Collections; public class TimeSeriesTest { private static ObjectMapper objectMapper; @@ -59,7 +57,6 @@ public class TimeSeriesTest { @BeforeClass public void init() { objectMapper = new ObjectMapper(); - objectMapper.registerModule(new JodaModule()); objectMapper.configure(com.fasterxml.jackson.databind.SerializationFeature. WRITE_DATES_AS_TIMESTAMPS, false); } @@ -99,8 +96,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { .build(); //2013-08-31T00:00:00.000/2013-09-03T00:00:00.000" - DateTime startTime = new DateTime(2012, 1, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2012, 1, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2012, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2012, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); Granularity granularity = new SimpleGranularity(PredefinedGranularity.DAY); @@ -158,8 +157,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testRequiredFields() throws JsonProcessingException, JSONException { - DateTime startTime = new DateTime(2013, 7, 14, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 11, 16, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 7, 14, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 11, 16, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); Granularity granularity = new SimpleGranularity(PredefinedGranularity.DAY); @@ -187,8 +188,10 @@ public void testRequiredFields() throws JsonProcessingException, JSONException { @Test public void testAllFields() throws JSONException, JsonProcessingException { - DateTime startTime = new DateTime(2013, 7, 14, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 11, 16, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 7, 14, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 11, 16, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); Granularity granularity = new SimpleGranularity(PredefinedGranularity.DAY); diff --git a/src/test/java/in/zapr/druid/druidry/query/aggregation/TopNQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/aggregation/TopNQueryTest.java index 5169baf0..f1e71635 100644 --- a/src/test/java/in/zapr/druid/druidry/query/aggregation/TopNQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/aggregation/TopNQueryTest.java @@ -18,23 +18,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.Collections; - -import in.zapr.druid.druidry.query.config.Context; -import in.zapr.druid.druidry.query.config.Interval; import in.zapr.druid.druidry.aggregator.CountAggregator; import in.zapr.druid.druidry.aggregator.DoubleSumAggregator; import in.zapr.druid.druidry.aggregator.DruidAggregator; @@ -53,8 +36,24 @@ import in.zapr.druid.druidry.postAggregator.ConstantPostAggregator; import in.zapr.druid.druidry.postAggregator.DruidPostAggregator; import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; +import in.zapr.druid.druidry.query.config.Context; +import in.zapr.druid.druidry.query.config.Interval; import in.zapr.druid.druidry.topNMetric.SimpleMetric; import in.zapr.druid.druidry.topNMetric.TopNMetric; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; +import java.util.Arrays; +import java.util.Collections; public class TopNQueryTest { private static ObjectMapper objectMapper; @@ -87,8 +86,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { .fields(Arrays.asList(fieldAccessPostAggregator1, fieldAccessPostAggregator2)) .build(); - DateTime startTime = new DateTime(2013, 8, 31, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 9, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); @@ -176,8 +177,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testRequiredFields() throws JsonProcessingException, JSONException { - DateTime startTime = new DateTime(2013, 8, 31, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 9, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); @@ -216,8 +219,10 @@ public void testRequiredFields() throws JsonProcessingException, JSONException { @Test public void testAllFields() throws JSONException, JsonProcessingException { - DateTime startTime = new DateTime(2013, 8, 31, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 9, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); @@ -288,8 +293,10 @@ public void testAllFields() throws JSONException, JsonProcessingException { @Test public void testEquals() { - DateTime startTime = new DateTime(2013, 8, 31, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 9, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); @@ -335,8 +342,10 @@ public void testEquals() { @Test public void testUnequals() { - DateTime startTime = new DateTime(2013, 8, 31, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 9, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); @@ -382,8 +391,10 @@ public void testUnequals() { @Test(expectedExceptions = IllegalArgumentException.class) public void preconditionCheck() { - DateTime startTime = new DateTime(2013, 8, 31, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 9, 3, 0, 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); diff --git a/src/test/java/in/zapr/druid/druidry/query/config/IntervalTest.java b/src/test/java/in/zapr/druid/druidry/query/config/IntervalTest.java index 2ffc5187..2a727693 100644 --- a/src/test/java/in/zapr/druid/druidry/query/config/IntervalTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/config/IntervalTest.java @@ -16,31 +16,31 @@ package in.zapr.druid.druidry.query.config; -import org.joda.time.DateTime; import org.testng.Assert; import org.testng.annotations.Test; -import in.zapr.druid.druidry.query.config.Interval; +import java.time.LocalDateTime; +import java.time.temporal.Temporal; public class IntervalTest { @Test(expectedExceptions = NullPointerException.class) public void testMissingStartField() { - DateTime startTime = new DateTime(); - Interval interval = new Interval(startTime, null); + Temporal startTime = LocalDateTime.now(); + new Interval(startTime, null); } @Test(expectedExceptions = NullPointerException.class) public void testMissingEndField() { - DateTime endTime = new DateTime(); - Interval interval = new Interval(null, endTime); + Temporal endTime = LocalDateTime.now(); + new Interval(null, endTime); } @Test public void intervalEqualityTest() { - DateTime startTime = new DateTime(); - DateTime endTime = startTime.plusDays(1); + LocalDateTime startTime = LocalDateTime.now(); + LocalDateTime endTime = startTime.plusDays(1); Interval interval1 = new Interval(startTime, endTime); Interval interval2 = new Interval(startTime, endTime); @@ -50,8 +50,8 @@ public void intervalEqualityTest() { Assert.assertNotEquals(interval1, interval3); - DateTime otherStartTime = new DateTime(startTime); - DateTime otherEndTime = new DateTime(endTime); + Temporal otherStartTime = LocalDateTime.from(startTime); + Temporal otherEndTime = LocalDateTime.from(endTime); Interval interval4 = new Interval(otherStartTime, otherEndTime); Assert.assertEquals(interval1, interval4); diff --git a/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java index 17786b73..43fcfbdc 100644 --- a/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java @@ -18,27 +18,27 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; +import in.zapr.druid.druidry.dataSource.TableDataSource; +import in.zapr.druid.druidry.dimension.enums.OutputType; +import in.zapr.druid.druidry.filter.DruidFilter; +import in.zapr.druid.druidry.filter.SelectorFilter; +import in.zapr.druid.druidry.query.config.Interval; +import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; import org.json.JSONException; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; import java.util.Arrays; import java.util.Collections; import java.util.List; -import in.zapr.druid.druidry.query.config.Interval; -import in.zapr.druid.druidry.dataSource.TableDataSource; -import in.zapr.druid.druidry.dimension.enums.OutputType; -import in.zapr.druid.druidry.filter.DruidFilter; -import in.zapr.druid.druidry.filter.SelectorFilter; -import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; - public class DruidScanQueryTest { + private static ObjectMapper objectMapper; @BeforeClass @@ -54,10 +54,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { List searchDimensions = Arrays.asList("dim1", "dim2"); - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidFilter filter = new SelectorFilter("dim1", "value1"); @@ -112,11 +112,11 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testRequiredFields() throws JsonProcessingException, JSONException { + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.UTC); Interval interval = new Interval(startTime, endTime); DruidScanQuery query = DruidScanQuery.builder() @@ -136,16 +136,16 @@ public void testRequiredFields() throws JsonProcessingException, JSONException { "}"; String actualJson = objectMapper.writeValueAsString(query); - JSONAssert.assertEquals(actualJson, expectedJsonAsString, JSONCompareMode.NON_EXTENSIBLE); + JSONAssert.assertEquals(expectedJsonAsString, actualJson, JSONCompareMode.NON_EXTENSIBLE); } @Test(expectedExceptions = IllegalArgumentException.class) public void preconditionLimitCheck() { - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, 0, + 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 3, 0, + 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidScanQuery query = DruidScanQuery.builder() @@ -159,10 +159,10 @@ public void preconditionLimitCheck() { @Test(expectedExceptions = IllegalArgumentException.class) public void preconditionBatchSizeCheck() { - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidScanQuery query = DruidScanQuery.builder() @@ -177,13 +177,12 @@ public void preconditionBatchSizeCheck() { public void testSampleQueryWithEmptyLines() throws JsonProcessingException, JSONException { - List searchDimensions - = Arrays.asList(); + List searchDimensions = Collections.emptyList(); - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidFilter filter = new SelectorFilter("dim1", "value1"); @@ -222,7 +221,7 @@ public void testSampleQueryWithEmptyLines() throws JsonProcessingException, JSON "}"; String actualJson = objectMapper.writeValueAsString(query); - JSONAssert.assertEquals(actualJson, expectedJsonAsString, JSONCompareMode.NON_EXTENSIBLE); + JSONAssert.assertEquals(expectedJsonAsString, actualJson, JSONCompareMode.NON_EXTENSIBLE); } } diff --git a/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java index 42fe44d6..b9dbc083 100644 --- a/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java @@ -18,22 +18,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.json.JSONException; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import in.zapr.druid.druidry.query.config.Context; -import in.zapr.druid.druidry.query.config.Interval; -import in.zapr.druid.druidry.query.config.SortingOrder; import in.zapr.druid.druidry.dataSource.TableDataSource; import in.zapr.druid.druidry.dimension.DruidDimension; import in.zapr.druid.druidry.dimension.SimpleDimension; @@ -44,7 +28,22 @@ import in.zapr.druid.druidry.filter.searchQuerySpec.SearchQuerySpec; import in.zapr.druid.druidry.granularity.PredefinedGranularity; import in.zapr.druid.druidry.granularity.SimpleGranularity; +import in.zapr.druid.druidry.query.config.Context; +import in.zapr.druid.druidry.query.config.Interval; +import in.zapr.druid.druidry.query.config.SortingOrder; import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; +import org.json.JSONException; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; public class DruidSearchQueryTest { private static ObjectMapper objectMapper; @@ -62,10 +61,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { SearchQuerySpec searchQuerySpec = new InsensitiveContainsSearchQuerySpec("Ke"); - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidSearchQuery query = DruidSearchQuery.builder() @@ -116,10 +115,10 @@ public void testRequiredFields() throws JsonProcessingException, JSONException { SearchQuerySpec searchQuerySpec = new InsensitiveContainsSearchQuerySpec("Ke"); - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidSearchQuery query = DruidSearchQuery.builder() @@ -157,10 +156,10 @@ public void testAllFields() throws JsonProcessingException, JSONException { SearchQuerySpec searchQuerySpec = new InsensitiveContainsSearchQuerySpec("Ke"); - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidFilter druidFilter = new SelectorFilter("Dim", "You"); diff --git a/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java index edb27ad9..1513859e 100644 --- a/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java @@ -18,26 +18,25 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; +import in.zapr.druid.druidry.dataSource.TableDataSource; +import in.zapr.druid.druidry.dimension.enums.OutputType; +import in.zapr.druid.druidry.granularity.Granularity; +import in.zapr.druid.druidry.granularity.PredefinedGranularity; +import in.zapr.druid.druidry.granularity.SimpleGranularity; +import in.zapr.druid.druidry.query.config.Interval; +import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; import org.json.JSONException; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.temporal.Temporal; import java.util.Collections; import java.util.HashMap; -import in.zapr.druid.druidry.query.config.Interval; -import in.zapr.druid.druidry.dataSource.TableDataSource; -import in.zapr.druid.druidry.dimension.enums.OutputType; -import in.zapr.druid.druidry.granularity.Granularity; -import in.zapr.druid.druidry.granularity.PredefinedGranularity; -import in.zapr.druid.druidry.granularity.SimpleGranularity; -import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; - public class DruidSelectQueryTest { private static ObjectMapper objectMapper; @@ -49,10 +48,10 @@ public void init() { @Test public void testSampleQuery() throws JsonProcessingException, JSONException { - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 2, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 2, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); PagingSpec pagingSpec = new PagingSpec(5, new HashMap<>()); @@ -97,10 +96,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testPagingQuery() throws JsonProcessingException, JSONException { - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 2, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 2, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); HashMap pagingIdentifiers = new HashMap<>(); @@ -143,10 +142,10 @@ public void testPagingQuery() throws JsonProcessingException, JSONException { @Test(expectedExceptions = NullPointerException.class) public void testNullableDataSource() { - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 2, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 2, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); PagingSpec pagingSpec = new PagingSpec(5, new HashMap<>()); @@ -177,10 +176,10 @@ public void testNullableInterval() { @Test(expectedExceptions = NullPointerException.class) public void testNullablePagingSpec() { - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 2, 0, - 0, 0, DateTimeZone.UTC); + Temporal startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + Temporal endTime = ZonedDateTime.of(2013, 1, 2, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); From 59ce9300b083b712fde52a8e40034d69550153c1 Mon Sep 17 00:00:00 2001 From: Jonasz Czerepko Date: Mon, 27 Apr 2020 17:39:38 +0200 Subject: [PATCH 2/2] Fixes after code review - ZonedDateTime used instead of Temporal (would cause errors in many cases as Temporal is too general); reverted code reordering (mostly imports). --- .../granularity/DurationGranularity.java | 11 +-- .../granularity/PeriodGranularity.java | 9 ++- .../druid/druidry/query/config/Interval.java | 13 ++-- .../dataSource/QueryDataSourceTest.java | 21 ++--- .../TimeFormatExtractionFunctionTest.java | 2 +- .../druidry/filter/IntervalFilterTest.java | 13 ++-- .../granularity/DurationGranularityTest.java | 10 +-- .../granularity/SimpleGranularityTest.java | 2 +- .../query/aggregation/GroupByTest.java | 53 ++++++------- .../query/aggregation/MovingAverageTest.java | 28 +++---- .../query/aggregation/TimeSeriesTest.java | 39 +++++----- .../query/aggregation/TopNQueryTest.java | 77 ++++++++++--------- .../druidry/query/config/IntervalTest.java | 16 ++-- .../query/scan/DruidScanQueryTest.java | 55 ++++++------- .../query/search/DruidSearchQueryTest.java | 49 ++++++------ .../query/select/DruidSelectQueryTest.java | 49 ++++++------ 16 files changed, 228 insertions(+), 219 deletions(-) diff --git a/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java b/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java index 0821b55a..1b67d0ea 100644 --- a/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java +++ b/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java @@ -16,14 +16,15 @@ package in.zapr.druid.druidry.granularity; -import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; + +import java.time.ZonedDateTime; + import lombok.EqualsAndHashCode; import lombok.Getter; -import java.time.temporal.Temporal; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; @Getter @JsonInclude(JsonInclude.Include.NON_NULL) @@ -35,13 +36,13 @@ public class DurationGranularity extends Granularity { private final String type; @JsonProperty("duration") private long durationInMilliSeconds; - private Temporal origin; + private ZonedDateTime origin; public DurationGranularity(long durationInMilliSeconds) { this(durationInMilliSeconds, null); } - public DurationGranularity(long durationInMilliSeconds, Temporal origin) { + public DurationGranularity(long durationInMilliSeconds, ZonedDateTime origin) { this.type = DURATION_GRANULARITY_TYPE; this.durationInMilliSeconds = durationInMilliSeconds; this.origin = origin; diff --git a/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java b/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java index 896e51bd..b8f84d7a 100644 --- a/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java +++ b/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java @@ -16,15 +16,16 @@ package in.zapr.druid.druidry.granularity; -import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; - import com.fasterxml.jackson.annotation.JsonInclude; + +import java.time.ZoneId; +import java.time.ZonedDateTime; + import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; -import java.time.ZoneId; -import java.time.ZonedDateTime; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; @Builder @Getter diff --git a/src/main/java/in/zapr/druid/druidry/query/config/Interval.java b/src/main/java/in/zapr/druid/druidry/query/config/Interval.java index 87c995e1..3d624861 100644 --- a/src/main/java/in/zapr/druid/druidry/query/config/Interval.java +++ b/src/main/java/in/zapr/druid/druidry/query/config/Interval.java @@ -17,13 +17,14 @@ package in.zapr.druid.druidry.query.config; import com.fasterxml.jackson.annotation.JsonValue; + +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; -import java.time.format.DateTimeFormatter; -import java.time.temporal.TemporalAccessor; - @Getter @EqualsAndHashCode public class Interval { @@ -32,10 +33,10 @@ public class Interval { private final static String DRUID_INTERVAL_FORMAT = "%s/%s"; - private TemporalAccessor startTime; - private TemporalAccessor endTime; + private ZonedDateTime startTime; + private ZonedDateTime endTime; - public Interval(@NonNull TemporalAccessor startTime, @NonNull TemporalAccessor endTime) { + public Interval(@NonNull ZonedDateTime startTime, @NonNull ZonedDateTime endTime) { this.startTime = startTime; this.endTime = endTime; } diff --git a/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java b/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java index b6edac54..88e1ee0b 100644 --- a/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java +++ b/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java @@ -18,13 +18,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import in.zapr.druid.druidry.dimension.DruidDimension; -import in.zapr.druid.druidry.dimension.SimpleDimension; -import in.zapr.druid.druidry.granularity.Granularity; -import in.zapr.druid.druidry.granularity.PredefinedGranularity; -import in.zapr.druid.druidry.granularity.SimpleGranularity; -import in.zapr.druid.druidry.query.aggregation.DruidGroupByQuery; -import in.zapr.druid.druidry.query.config.Interval; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -35,10 +29,17 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.time.temporal.Temporal; import java.util.Arrays; import java.util.Collections; +import in.zapr.druid.druidry.dimension.DruidDimension; +import in.zapr.druid.druidry.dimension.SimpleDimension; +import in.zapr.druid.druidry.granularity.Granularity; +import in.zapr.druid.druidry.granularity.PredefinedGranularity; +import in.zapr.druid.druidry.granularity.SimpleGranularity; +import in.zapr.druid.druidry.query.aggregation.DruidGroupByQuery; +import in.zapr.druid.druidry.query.config.Interval; + public class QueryDataSourceTest { private static ObjectMapper objectMapper; @@ -54,9 +55,9 @@ public void testQueryDataSource() throws JsonProcessingException, JSONException Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); // Interval - Temporal startTime = ZonedDateTime.of(2012, 1, 1, + ZonedDateTime startTime = ZonedDateTime.of(2012, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2012, 1, 3, + ZonedDateTime endTime = ZonedDateTime.of(2012, 1, 3, 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); diff --git a/src/test/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunctionTest.java b/src/test/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunctionTest.java index 7836c36a..e2a381fb 100644 --- a/src/test/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunctionTest.java +++ b/src/test/java/in/zapr/druid/druidry/extractionFunctions/TimeFormatExtractionFunctionTest.java @@ -49,7 +49,7 @@ public void testAllFields() throws JsonProcessingException, JSONException { String timeZone = "America/Montreal"; - Temporal originDate = ZonedDateTime.now(ZoneOffset.UTC); + ZonedDateTime originDate = ZonedDateTime.now(ZoneOffset.UTC); DurationGranularity spec = new DurationGranularity(7200000, originDate); diff --git a/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java b/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java index 327b4232..188b4a9b 100644 --- a/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java +++ b/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import in.zapr.druid.druidry.query.config.Interval; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -29,10 +29,11 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.time.temporal.Temporal; import java.util.ArrayList; import java.util.Arrays; +import in.zapr.druid.druidry.query.config.Interval; + public class IntervalFilterTest { private static ObjectMapper objectMapper; @@ -66,14 +67,14 @@ public void testFields() throws JsonProcessingException, JSONException { jsonObject.put("dimension", "__time"); jsonObject.put("intervals", intervalJsonArray); - Temporal startTimeInterval1 = ZonedDateTime.of(2013, 8, 31, + ZonedDateTime startTimeInterval1 = ZonedDateTime.of(2013, 8, 31, 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTimeInterval1 = ZonedDateTime.of(2013, 9, 3, + ZonedDateTime endTimeInterval1 = ZonedDateTime.of(2013, 9, 3, 0, 0, 0, 0, ZoneOffset.UTC); - Temporal startTimeInterval2 = ZonedDateTime.of(2018, 8, 31, + ZonedDateTime startTimeInterval2 = ZonedDateTime.of(2018, 8, 31, 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTimeInterval2 = ZonedDateTime.of(2018, 9, 3, + ZonedDateTime endTimeInterval2 = ZonedDateTime.of(2018, 9, 3, 0, 0, 0, 0, ZoneOffset.UTC); Interval interval1 = new Interval(startTimeInterval1, endTimeInterval1); diff --git a/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java b/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java index 14370caa..925f70d7 100644 --- a/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java +++ b/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java @@ -16,10 +16,9 @@ package in.zapr.druid.druidry.granularity; -import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + import org.json.JSONException; import org.json.JSONObject; import org.skyscreamer.jsonassert.JSONAssert; @@ -30,7 +29,8 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.time.temporal.Temporal; + +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; public class DurationGranularityTest { @@ -44,7 +44,7 @@ public void init() { @Test public void testAllFields() throws JSONException, JsonProcessingException { - Temporal originDate = ZonedDateTime.now(ZoneOffset.UTC); + ZonedDateTime originDate = ZonedDateTime.now(ZoneOffset.UTC); DurationGranularity granularity = new DurationGranularity(3141, originDate); JSONObject jsonObject = new JSONObject(); jsonObject.put("type", "duration"); @@ -88,7 +88,7 @@ public void testEqualsNegative() { public void testEqualsWithAnotherSubClass() { SimpleGranularity granularity1 = new SimpleGranularity(PredefinedGranularity.ALL); - Temporal originDate = ZonedDateTime.now(ZoneOffset.UTC); + ZonedDateTime originDate = ZonedDateTime.now(ZoneOffset.UTC); DurationGranularity granularity2 = new DurationGranularity(3141, originDate); Assert.assertNotEquals(granularity1, granularity2); diff --git a/src/test/java/in/zapr/druid/druidry/granularity/SimpleGranularityTest.java b/src/test/java/in/zapr/druid/druidry/granularity/SimpleGranularityTest.java index f815aa01..e375983e 100644 --- a/src/test/java/in/zapr/druid/druidry/granularity/SimpleGranularityTest.java +++ b/src/test/java/in/zapr/druid/druidry/granularity/SimpleGranularityTest.java @@ -45,7 +45,7 @@ public void testEqualsNegative() { public void testEqualsWithAnotherSubClass() { SimpleGranularity granularity1 = new SimpleGranularity(PredefinedGranularity.ALL); - Temporal originDate = ZonedDateTime.now(ZoneOffset.UTC); + ZonedDateTime originDate = ZonedDateTime.now(ZoneOffset.UTC); DurationGranularity granularity2 = new DurationGranularity(3141, originDate); Assert.assertNotEquals(granularity1, granularity2); diff --git a/src/test/java/in/zapr/druid/druidry/query/aggregation/GroupByTest.java b/src/test/java/in/zapr/druid/druidry/query/aggregation/GroupByTest.java index a1c36750..fe93d2f1 100644 --- a/src/test/java/in/zapr/druid/druidry/query/aggregation/GroupByTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/aggregation/GroupByTest.java @@ -18,6 +18,21 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import in.zapr.druid.druidry.aggregator.CountAggregator; import in.zapr.druid.druidry.aggregator.DoubleSumAggregator; import in.zapr.druid.druidry.aggregator.DruidAggregator; @@ -44,20 +59,6 @@ import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; import in.zapr.druid.druidry.query.config.Context; import in.zapr.druid.druidry.query.config.Interval; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.temporal.Temporal; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; public class GroupByTest { private static ObjectMapper objectMapper; @@ -148,10 +149,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { .build(); // Interval - Temporal startTime = ZonedDateTime.of(2012, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2012, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2012, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2012, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidGroupByQuery query = DruidGroupByQuery.builder() @@ -177,10 +178,10 @@ public void testRequiredFields() throws JSONException, JsonProcessingException { Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); // Interval - Temporal startTime = ZonedDateTime.of(2012, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2012, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2012, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2012, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidGroupByQuery druidGroupByQuery = DruidGroupByQuery.builder() @@ -216,10 +217,10 @@ public void testAllFields() throws JSONException, JsonProcessingException { Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); // Interval - Temporal startTime = ZonedDateTime.of(2012, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2012, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2012, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2012, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidFilter filter = new SelectorFilter("Spread", "Peace"); diff --git a/src/test/java/in/zapr/druid/druidry/query/aggregation/MovingAverageTest.java b/src/test/java/in/zapr/druid/druidry/query/aggregation/MovingAverageTest.java index dff9864d..72295cea 100644 --- a/src/test/java/in/zapr/druid/druidry/query/aggregation/MovingAverageTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/aggregation/MovingAverageTest.java @@ -20,8 +20,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.testng.annotations.BeforeClass; @@ -33,6 +31,8 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; import in.zapr.druid.druidry.aggregator.DoubleSumAggregator; import in.zapr.druid.druidry.aggregator.DruidAggregator; @@ -83,8 +83,8 @@ public void testAllFieldsQuery() throws Exception { DefaultLimitSpec limitSpec = new DefaultLimitSpec(5000, of(new OrderByColumnSpecString("column_1"), new OrderByColumnSpecString("column_2"))); - DateTime startTime = new DateTime(2020, 2, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2020, 3, 31, 23, 59, 59, DateTimeZone.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2020, 2, 1, 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2020, 3, 31, 23, 59, 59, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); String averagedName = "averagedName"; DruidAggregator aggregator = new DoubleSumAggregator(averagedName, "aggregatedFieldName"); @@ -119,8 +119,8 @@ public void testAllFieldsQuery() throws Exception { @Test(expectedExceptions = NullPointerException.class) public void tryToBuildWithoutDataSource() { - DateTime startTime = new DateTime(2020, 2, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2020, 3, 31, 23, 59, 59, DateTimeZone.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2020, 2, 1, 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2020, 3, 31, 23, 59, 59, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidAggregator aggregator = new DoubleSumAggregator("name", "fieldName"); DruidAverager averager = DoubleMeanAverager.builder() @@ -140,8 +140,8 @@ public void tryToBuildWithoutDataSource() { @Test(expectedExceptions = NullPointerException.class) public void tryToBuildWithoutGranularity() { - DateTime startTime = new DateTime(2020, 2, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2020, 3, 31, 23, 59, 59, DateTimeZone.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2020, 2, 1, 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2020, 3, 31, 23, 59, 59, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidAggregator aggregator = new DoubleSumAggregator("name", "fieldName"); DruidAverager averager = DoubleMeanAverager.builder() @@ -161,8 +161,8 @@ public void tryToBuildWithoutGranularity() { @Test(expectedExceptions = NullPointerException.class) public void tryToBuildWithoutAggregations() { - DateTime startTime = new DateTime(2020, 2, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2020, 3, 31, 23, 59, 59, DateTimeZone.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2020, 2, 1, 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2020, 3, 31, 23, 59, 59, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidAverager averager = DoubleMeanAverager.builder() .name("name") @@ -199,8 +199,8 @@ public void tryToBuildWithoutIntervals() { @Test(expectedExceptions = NullPointerException.class) public void tryToBuildWithoutAveragers() { - DateTime startTime = new DateTime(2020, 2, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2020, 3, 31, 23, 59, 59, DateTimeZone.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2020, 2, 1, 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2020, 3, 31, 23, 59, 59, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidAggregator aggregator = new DoubleSumAggregator("name", "fieldName"); @@ -255,8 +255,8 @@ private String loadExpectedJson(String fileName) throws IOException, URISyntaxEx private static DruidMovingAverageQuery simpleQuery( MovingAverageCreators.Creator averagerCreator) { - DateTime startTime = new DateTime(2020, 1, 1, 0, 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2020, 2, 29, 23, 59, 59, DateTimeZone.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2020, 2, 29, 23, 59, 59, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); String averagedName = "averagedName"; DruidAggregator aggregator = new DoubleSumAggregator(averagedName, "aggregatedFieldName"); diff --git a/src/test/java/in/zapr/druid/druidry/query/aggregation/TimeSeriesTest.java b/src/test/java/in/zapr/druid/druidry/query/aggregation/TimeSeriesTest.java index 218e493a..9330f498 100644 --- a/src/test/java/in/zapr/druid/druidry/query/aggregation/TimeSeriesTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/aggregation/TimeSeriesTest.java @@ -18,6 +18,20 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Collections; + import in.zapr.druid.druidry.aggregator.CountAggregator; import in.zapr.druid.druidry.aggregator.DoubleSumAggregator; import in.zapr.druid.druidry.aggregator.DruidAggregator; @@ -37,19 +51,6 @@ import in.zapr.druid.druidry.postAggregator.FieldAccessPostAggregator; import in.zapr.druid.druidry.query.config.Context; import in.zapr.druid.druidry.query.config.Interval; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.temporal.Temporal; -import java.util.Arrays; -import java.util.Collections; public class TimeSeriesTest { private static ObjectMapper objectMapper; @@ -96,9 +97,9 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { .build(); //2013-08-31T00:00:00.000/2013-09-03T00:00:00.000" - Temporal startTime = ZonedDateTime.of(2012, 1, 1, + ZonedDateTime startTime = ZonedDateTime.of(2012, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2012, 1, 3, + ZonedDateTime endTime = ZonedDateTime.of(2012, 1, 3, 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); @@ -157,9 +158,9 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testRequiredFields() throws JsonProcessingException, JSONException { - Temporal startTime = ZonedDateTime.of(2013, 7, 14, + ZonedDateTime startTime = ZonedDateTime.of(2013, 7, 14, 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 11, 16, + ZonedDateTime endTime = ZonedDateTime.of(2013, 11, 16, 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); @@ -188,9 +189,9 @@ public void testRequiredFields() throws JsonProcessingException, JSONException { @Test public void testAllFields() throws JSONException, JsonProcessingException { - Temporal startTime = ZonedDateTime.of(2013, 7, 14, + ZonedDateTime startTime = ZonedDateTime.of(2013, 7, 14, 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 11, 16, + ZonedDateTime endTime = ZonedDateTime.of(2013, 11, 16, 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); diff --git a/src/test/java/in/zapr/druid/druidry/query/aggregation/TopNQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/aggregation/TopNQueryTest.java index 10fc1da9..ab70cc5f 100644 --- a/src/test/java/in/zapr/druid/druidry/query/aggregation/TopNQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/aggregation/TopNQueryTest.java @@ -18,6 +18,21 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Collections; + import in.zapr.druid.druidry.aggregator.CountAggregator; import in.zapr.druid.druidry.aggregator.DoubleSumAggregator; import in.zapr.druid.druidry.aggregator.DruidAggregator; @@ -40,20 +55,6 @@ import in.zapr.druid.druidry.query.config.Interval; import in.zapr.druid.druidry.topNMetric.SimpleMetric; import in.zapr.druid.druidry.topNMetric.TopNMetric; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.temporal.Temporal; -import java.util.Arrays; -import java.util.Collections; public class TopNQueryTest { private static ObjectMapper objectMapper; @@ -86,10 +87,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { .fields(Arrays.asList(fieldAccessPostAggregator1, fieldAccessPostAggregator2)) .build(); - Temporal startTime = ZonedDateTime.of(2013, 8, 31, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 9, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL); @@ -177,10 +178,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testRequiredFields() throws JsonProcessingException, JSONException { - Temporal startTime = ZonedDateTime.of(2013, 8, 31, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 9, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); @@ -219,10 +220,10 @@ public void testRequiredFields() throws JsonProcessingException, JSONException { @Test public void testAllFields() throws JSONException, JsonProcessingException { - Temporal startTime = ZonedDateTime.of(2013, 8, 31, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 9, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); @@ -293,10 +294,10 @@ public void testAllFields() throws JSONException, JsonProcessingException { @Test public void testEquals() { - Temporal startTime = ZonedDateTime.of(2013, 8, 31, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 9, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); @@ -342,10 +343,10 @@ public void testEquals() { @Test public void testUnequals() { - Temporal startTime = ZonedDateTime.of(2013, 8, 31, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 9, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); @@ -391,10 +392,10 @@ public void testUnequals() { @Test(expectedExceptions = IllegalArgumentException.class) public void preconditionCheck() { - Temporal startTime = ZonedDateTime.of(2013, 8, 31, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 9, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 9, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidDimension dimension = new SimpleDimension("Demo"); diff --git a/src/test/java/in/zapr/druid/druidry/query/config/IntervalTest.java b/src/test/java/in/zapr/druid/druidry/query/config/IntervalTest.java index 2a727693..56bb7eee 100644 --- a/src/test/java/in/zapr/druid/druidry/query/config/IntervalTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/config/IntervalTest.java @@ -19,28 +19,26 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.time.LocalDateTime; -import java.time.temporal.Temporal; +import java.time.ZonedDateTime; public class IntervalTest { @Test(expectedExceptions = NullPointerException.class) public void testMissingStartField() { - - Temporal startTime = LocalDateTime.now(); + ZonedDateTime startTime = ZonedDateTime.now(); new Interval(startTime, null); } @Test(expectedExceptions = NullPointerException.class) public void testMissingEndField() { - Temporal endTime = LocalDateTime.now(); + ZonedDateTime endTime = ZonedDateTime.now(); new Interval(null, endTime); } @Test public void intervalEqualityTest() { - LocalDateTime startTime = LocalDateTime.now(); - LocalDateTime endTime = startTime.plusDays(1); + ZonedDateTime startTime = ZonedDateTime.now(); + ZonedDateTime endTime = startTime.plusDays(1); Interval interval1 = new Interval(startTime, endTime); Interval interval2 = new Interval(startTime, endTime); @@ -50,8 +48,8 @@ public void intervalEqualityTest() { Assert.assertNotEquals(interval1, interval3); - Temporal otherStartTime = LocalDateTime.from(startTime); - Temporal otherEndTime = LocalDateTime.from(endTime); + ZonedDateTime otherStartTime = ZonedDateTime.from(startTime); + ZonedDateTime otherEndTime = ZonedDateTime.from(endTime); Interval interval4 = new Interval(otherStartTime, otherEndTime); Assert.assertEquals(interval1, interval4); diff --git a/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java index 43fcfbdc..44c60b85 100644 --- a/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/scan/DruidScanQueryTest.java @@ -18,12 +18,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import in.zapr.druid.druidry.dataSource.TableDataSource; -import in.zapr.druid.druidry.dimension.enums.OutputType; -import in.zapr.druid.druidry.filter.DruidFilter; -import in.zapr.druid.druidry.filter.SelectorFilter; -import in.zapr.druid.druidry.query.config.Interval; -import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; + import org.json.JSONException; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @@ -32,11 +27,17 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.time.temporal.Temporal; import java.util.Arrays; import java.util.Collections; import java.util.List; +import in.zapr.druid.druidry.dataSource.TableDataSource; +import in.zapr.druid.druidry.dimension.enums.OutputType; +import in.zapr.druid.druidry.filter.DruidFilter; +import in.zapr.druid.druidry.filter.SelectorFilter; +import in.zapr.druid.druidry.query.config.Interval; +import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; + public class DruidScanQueryTest { private static ObjectMapper objectMapper; @@ -54,10 +55,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { List searchDimensions = Arrays.asList("dim1", "dim2"); - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidFilter filter = new SelectorFilter("dim1", "value1"); @@ -112,10 +113,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testRequiredFields() throws JsonProcessingException, JSONException { - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); @@ -142,10 +143,10 @@ public void testRequiredFields() throws JsonProcessingException, JSONException { @Test(expectedExceptions = IllegalArgumentException.class) public void preconditionLimitCheck() { - Temporal startTime = ZonedDateTime.of(2013, 1, 1, 0, - 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 3, 0, - 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, 0, + 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 3, 0, + 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidScanQuery query = DruidScanQuery.builder() @@ -159,10 +160,10 @@ public void preconditionLimitCheck() { @Test(expectedExceptions = IllegalArgumentException.class) public void preconditionBatchSizeCheck() { - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidScanQuery query = DruidScanQuery.builder() @@ -179,10 +180,10 @@ public void testSampleQueryWithEmptyLines() throws JsonProcessingException, JSON List searchDimensions = Collections.emptyList(); - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidFilter filter = new SelectorFilter("dim1", "value1"); diff --git a/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java index b9dbc083..566dcfef 100644 --- a/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/search/DruidSearchQueryTest.java @@ -18,6 +18,19 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + +import org.json.JSONException; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import in.zapr.druid.druidry.dataSource.TableDataSource; import in.zapr.druid.druidry.dimension.DruidDimension; import in.zapr.druid.druidry.dimension.SimpleDimension; @@ -32,18 +45,6 @@ import in.zapr.druid.druidry.query.config.Interval; import in.zapr.druid.druidry.query.config.SortingOrder; import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; -import org.json.JSONException; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.temporal.Temporal; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; public class DruidSearchQueryTest { private static ObjectMapper objectMapper; @@ -61,10 +62,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { SearchQuerySpec searchQuerySpec = new InsensitiveContainsSearchQuerySpec("Ke"); - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidSearchQuery query = DruidSearchQuery.builder() @@ -115,10 +116,10 @@ public void testRequiredFields() throws JsonProcessingException, JSONException { SearchQuerySpec searchQuerySpec = new InsensitiveContainsSearchQuerySpec("Ke"); - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidSearchQuery query = DruidSearchQuery.builder() @@ -156,10 +157,10 @@ public void testAllFields() throws JsonProcessingException, JSONException { SearchQuerySpec searchQuerySpec = new InsensitiveContainsSearchQuerySpec("Ke"); - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 3, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 3, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); DruidFilter druidFilter = new SelectorFilter("Dim", "You"); diff --git a/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java b/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java index 1513859e..3c9e12f6 100644 --- a/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java +++ b/src/test/java/in/zapr/druid/druidry/query/select/DruidSelectQueryTest.java @@ -18,13 +18,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import in.zapr.druid.druidry.dataSource.TableDataSource; -import in.zapr.druid.druidry.dimension.enums.OutputType; -import in.zapr.druid.druidry.granularity.Granularity; -import in.zapr.druid.druidry.granularity.PredefinedGranularity; -import in.zapr.druid.druidry.granularity.SimpleGranularity; -import in.zapr.druid.druidry.query.config.Interval; -import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; + import org.json.JSONException; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @@ -33,10 +27,17 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; -import java.time.temporal.Temporal; import java.util.Collections; import java.util.HashMap; +import in.zapr.druid.druidry.dataSource.TableDataSource; +import in.zapr.druid.druidry.dimension.enums.OutputType; +import in.zapr.druid.druidry.granularity.Granularity; +import in.zapr.druid.druidry.granularity.PredefinedGranularity; +import in.zapr.druid.druidry.granularity.SimpleGranularity; +import in.zapr.druid.druidry.query.config.Interval; +import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; + public class DruidSelectQueryTest { private static ObjectMapper objectMapper; @@ -48,10 +49,10 @@ public void init() { @Test public void testSampleQuery() throws JsonProcessingException, JSONException { - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 2, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 2, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); PagingSpec pagingSpec = new PagingSpec(5, new HashMap<>()); @@ -96,10 +97,10 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testPagingQuery() throws JsonProcessingException, JSONException { - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 2, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 2, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); HashMap pagingIdentifiers = new HashMap<>(); @@ -142,10 +143,10 @@ public void testPagingQuery() throws JsonProcessingException, JSONException { @Test(expectedExceptions = NullPointerException.class) public void testNullableDataSource() { - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 2, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 2, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); PagingSpec pagingSpec = new PagingSpec(5, new HashMap<>()); @@ -176,10 +177,10 @@ public void testNullableInterval() { @Test(expectedExceptions = NullPointerException.class) public void testNullablePagingSpec() { - Temporal startTime = ZonedDateTime.of(2013, 1, 1, - 0, 0, 0, 0, ZoneOffset.UTC); - Temporal endTime = ZonedDateTime.of(2013, 1, 2, - 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime startTime = ZonedDateTime.of(2013, 1, 1, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime endTime = ZonedDateTime.of(2013, 1, 2, + 0, 0, 0, 0, ZoneOffset.UTC); Interval interval = new Interval(startTime, endTime); Granularity granularity = new SimpleGranularity(PredefinedGranularity.ALL);