From 813ce049a541ce2005bf2301956203c9f69052df Mon Sep 17 00:00:00 2001 From: Kseniya Tomskikh Date: Tue, 22 May 2018 19:45:57 -0700 Subject: HYPE-5 Support filters by date --- .../rest/parsers/SearchFilterParserSuite.scala | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/test') diff --git a/src/test/scala/xyz/driver/restquery/rest/parsers/SearchFilterParserSuite.scala b/src/test/scala/xyz/driver/restquery/rest/parsers/SearchFilterParserSuite.scala index 9abf372..4abf550 100644 --- a/src/test/scala/xyz/driver/restquery/rest/parsers/SearchFilterParserSuite.scala +++ b/src/test/scala/xyz/driver/restquery/rest/parsers/SearchFilterParserSuite.scala @@ -1,5 +1,6 @@ package xyz.driver.restquery.rest.parsers +import java.time.LocalDate import java.util.UUID import fastparse.core.Parsed @@ -162,6 +163,33 @@ class SearchFilterParserSuite extends FreeSpecLike with Checkers { } } + "actual startDate - date" - { + "should parse the full date as java.time.LocalDate type" in { + val filter = SearchFilterParser.parse(Seq("filters" -> "startDate EQ 2018-05-22")) + assert( + filter === Success(SearchFilterExpr.Atom + .Binary(Dimension(None, "start_date"), Eq, LocalDate.of(2018, 5, 22)))) + } + } + + "actual date list" - { + "should parse the list of dates as java.time.LocalDate type" in { + val filter = SearchFilterParser.parse(Seq("filters" -> ("startDate in 2018-05-19," + + "2018-05-20,2018-05-21"))) + assert( + filter === Success( + SearchFilterExpr.Atom.NAry( + Dimension(None, "start_date"), + In, + Seq( + LocalDate.of(2018, 5, 19), + LocalDate.of(2018, 5, 20), + LocalDate.of(2018, 5, 21) + ) + ))) + } + } + "all operators" - { "should be parsed with numeric values" in check { val testQueryGen = queryGen( -- cgit v1.2.3