- String invalidTypes = "{ \"field\": \"timestamp\", \"lte\": 5, \"gte\": \"2016-10-06T23:59:59.558+03:00\"}";
-
- ObjectMapper mapper = new ObjectMapper();
-
- // Attempt to parse a query where we are setting values for both the
- // 'greater than' and 'greater than and equal to' operators.
- boolean gotExpectedException = false;
- try {
- RangeQuery badRangeQuery = mapper.readValue(invalidGTAndGTE, RangeQuery.class);
- } catch (JsonMappingException e) {
- gotExpectedException = true;
- }
- assertTrue("Attempting to set both a 'gt' and 'gte' value on the same query should not have been allowed",
- gotExpectedException);
-
- // Attempt to parse a query where we are setting values for both the
- // 'less than' and 'less than and equal to' operators.
- gotExpectedException = false;
- try {
- RangeQuery badRangeQuery = mapper.readValue(invalidLTAndLTE, RangeQuery.class);
- } catch (JsonMappingException e) {
- gotExpectedException = true;
- }
- assertTrue("Attempting to set both a 'lt' and 'lte' value on the same query should not have been allowed",
- gotExpectedException);
-
- // Attempt to parse a query where we are mixing numeric and date values
- // in the same query.
- gotExpectedException = false;
- try {
- RangeQuery badRangeQuery = mapper.readValue(invalidTypes, RangeQuery.class);
- } catch (JsonMappingException e) {
- gotExpectedException = true;
- }
- assertTrue("Attempting to mix numeric and date values in the same query should not have been allowed",
- gotExpectedException);