RangeTermQueryValueParser { public RangeTermQueryValue parse(String value) { Matcher matcher = _pattern.matcher(value); if (!matcher.matches()) { return null; } RangeTermQueryValue.Builder rangeTermQueryValueBuilder = new RangeTermQueryValue.Builder(); rangeTermQueryValueBuilder.includesLower(isIncludesLower(matcher)); rangeTermQueryValueBuilder.includesUpper(isIncludesUpper(matcher)); rangeTermQueryValueBuilder.lowerBound(matcher.group("lowerBound")); rangeTermQueryValueBuilder.upperBound(matcher.group("upperBound")); return rangeTermQueryValueBuilder.build(); }  RangeTermQueryValue parse(String value);  }
@Test public void testParseDateRangeIncludesLower() { RangeTermQueryValue rangeTermQueryValue = rangeTermQueryValueParser.parse("[now/d now+1d/d["); Assert.assertNotNull(rangeTermQueryValue); assertIncludesLower(rangeTermQueryValue); assertDoesNotIncludeUpper(rangeTermQueryValue); assertBounds(rangeTermQueryValue, "now/d", "now+1d/d"); }
@Test public void testParseDateRangeIncludesLowerIncludesUpper() { RangeTermQueryValue rangeTermQueryValue = rangeTermQueryValueParser.parse("[now/d now+1d/d]"); Assert.assertNotNull(rangeTermQueryValue); assertIncludesLower(rangeTermQueryValue); assertIncludesUpper(rangeTermQueryValue); assertBounds(rangeTermQueryValue, "now/d", "now+1d/d"); }
@Test public void testParseDateRangeIncludesUpper() { RangeTermQueryValue rangeTermQueryValue = rangeTermQueryValueParser.parse("]now/d now+1d/d]"); Assert.assertNotNull(rangeTermQueryValue); assertDoesNotIncludeLower(rangeTermQueryValue); assertIncludesUpper(rangeTermQueryValue); assertBounds(rangeTermQueryValue, "now/d", "now+1d/d"); }
@Test public void testParseDateRangeInvalidEnd() { RangeTermQueryValue rangeTermQueryValue = rangeTermQueryValueParser.parse("[now/d now+1d/d"); Assert.assertNull(rangeTermQueryValue); }
@Test public void testParseDateRangeInvalidStart() { RangeTermQueryValue rangeTermQueryValue = rangeTermQueryValueParser.parse("now/d now+1d/d["); Assert.assertNull(rangeTermQueryValue); }