diff --git a/pom.xml b/pom.xml index b58edf73..b6fa1f77 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,6 @@ UTF-8 2.9.10.4 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..1b67d0ea 100644 --- a/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java +++ b/src/main/java/in/zapr/druid/druidry/granularity/DurationGranularity.java @@ -19,11 +19,13 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import org.joda.time.DateTime; +import java.time.ZonedDateTime; import lombok.EqualsAndHashCode; import lombok.Getter; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; + @Getter @JsonInclude(JsonInclude.Include.NON_NULL) @EqualsAndHashCode(callSuper = true) @@ -34,19 +36,19 @@ public class DurationGranularity extends Granularity { private final String type; @JsonProperty("duration") private long durationInMilliSeconds; - private DateTime origin; + private ZonedDateTime origin; public DurationGranularity(long durationInMilliSeconds) { this(durationInMilliSeconds, null); } - public DurationGranularity(long durationInMilliSeconds, DateTime origin) { + public DurationGranularity(long durationInMilliSeconds, ZonedDateTime 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..b8f84d7a 100644 --- a/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java +++ b/src/main/java/in/zapr/druid/druidry/granularity/PeriodGranularity.java @@ -18,18 +18,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; +import java.time.ZoneId; +import java.time.ZonedDateTime; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; + @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 +43,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..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 @@ -18,7 +18,8 @@ import com.fasterxml.jackson.annotation.JsonValue; -import org.joda.time.DateTime; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,18 +29,20 @@ @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 ZonedDateTime startTime; + private ZonedDateTime endTime; - public Interval(@NonNull DateTime startTime, @NonNull DateTime endTime) { + public Interval(@NonNull ZonedDateTime startTime, @NonNull ZonedDateTime 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..88e1ee0b 100644 --- a/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java +++ b/src/test/java/in/zapr/druid/druidry/dataSource/QueryDataSourceTest.java @@ -19,8 +19,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; @@ -29,6 +27,8 @@ 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; @@ -55,8 +55,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); + 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() 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..e2a381fb 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); + ZonedDateTime 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..188b4a9b 100644 --- a/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java +++ b/src/test/java/in/zapr/druid/druidry/filter/IntervalFilterTest.java @@ -19,8 +19,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; @@ -29,6 +27,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Arrays; @@ -67,15 +67,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); + ZonedDateTime startTimeInterval1 = ZonedDateTime.of(2013, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime 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); + ZonedDateTime startTimeInterval2 = ZonedDateTime.of(2018, 8, 31, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime 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..925f70d7 100644 --- a/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java +++ b/src/test/java/in/zapr/druid/druidry/granularity/DurationGranularityTest.java @@ -19,8 +19,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.json.JSONObject; import org.skyscreamer.jsonassert.JSONAssert; @@ -29,6 +27,11 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; + +import static java.time.format.DateTimeFormatter.ISO_DATE_TIME; + 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); + ZonedDateTime 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); + 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/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..e375983e 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); + 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 37f1c68d..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 @@ -19,10 +19,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; @@ -31,12 +27,12 @@ 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.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 +44,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 +57,8 @@ 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; public class GroupByTest { private static ObjectMapper objectMapper; @@ -149,8 +149,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); + 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() @@ -166,7 +168,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 +178,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); + 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() @@ -213,8 +217,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); + 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 e4bbbe46..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,10 +18,7 @@ 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; @@ -30,11 +27,11 @@ 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.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 +49,8 @@ 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; public class TimeSeriesTest { private static ObjectMapper objectMapper; @@ -59,7 +58,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 +97,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); + 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); Granularity granularity = new SimpleGranularity(PredefinedGranularity.DAY); @@ -158,8 +158,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); + ZonedDateTime startTime = ZonedDateTime.of(2013, 7, 14, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime 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 +189,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); + ZonedDateTime startTime = ZonedDateTime.of(2013, 7, 14, + 0, 0, 0, 0, ZoneOffset.UTC); + ZonedDateTime 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 d8f0a441..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 @@ -19,8 +19,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; @@ -30,11 +28,11 @@ 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.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,6 +51,8 @@ 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; @@ -87,8 +87,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); + 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); @@ -176,8 +178,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); + 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"); @@ -216,8 +220,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); + 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"); @@ -288,8 +294,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); + 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"); @@ -335,8 +343,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); + 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"); @@ -382,8 +392,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); + 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 2ffc5187..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 @@ -16,31 +16,29 @@ 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.ZonedDateTime; public class IntervalTest { @Test(expectedExceptions = NullPointerException.class) public void testMissingStartField() { - - DateTime startTime = new DateTime(); - Interval interval = new Interval(startTime, null); + ZonedDateTime startTime = ZonedDateTime.now(); + new Interval(startTime, null); } @Test(expectedExceptions = NullPointerException.class) public void testMissingEndField() { - DateTime endTime = new DateTime(); - Interval interval = new Interval(null, endTime); + ZonedDateTime endTime = ZonedDateTime.now(); + new Interval(null, endTime); } @Test public void intervalEqualityTest() { - DateTime startTime = new DateTime(); - DateTime 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); - DateTime otherStartTime = new DateTime(startTime); - DateTime otherEndTime = new DateTime(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 17786b73..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 @@ -19,26 +19,27 @@ 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.time.ZoneOffset; +import java.time.ZonedDateTime; 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.query.config.Interval; import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; public class DruidScanQueryTest { + private static ObjectMapper objectMapper; @BeforeClass @@ -54,10 +55,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); + 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,11 +113,11 @@ public void testSampleQuery() throws JsonProcessingException, JSONException { @Test public void testRequiredFields() throws JsonProcessingException, JSONException { + 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); - 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 +137,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); + 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() { - DateTime startTime = new DateTime(2013, 1, 1, 0, - 0, 0, DateTimeZone.UTC); - DateTime endTime = new DateTime(2013, 1, 3, 0, - 0, 0, DateTimeZone.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() @@ -177,13 +178,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); + 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"); @@ -222,7 +222,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..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 @@ -19,21 +19,18 @@ 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.time.ZoneOffset; +import java.time.ZonedDateTime; 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,6 +41,9 @@ 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; public class DruidSearchQueryTest { @@ -62,10 +62,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); + 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() @@ -116,10 +116,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); + 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() @@ -157,10 +157,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); + 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 edb27ad9..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 @@ -19,23 +19,23 @@ 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.time.ZoneOffset; +import java.time.ZonedDateTime; 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.query.config.Interval; import in.zapr.druid.druidry.virtualColumn.ExpressionVirtualColumn; public class DruidSelectQueryTest { @@ -49,10 +49,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); + 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<>()); @@ -97,10 +97,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); + 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<>(); @@ -143,10 +143,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); + 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<>()); @@ -177,10 +177,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); + 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);