DateRangeFactory { public void validateRange(String ranges) throws JSONException, ParseException { JSONArray rangesJSONArray = JSONFactoryUtil.createJSONArray(ranges); for (int i = 0; i < rangesJSONArray.length(); i++) { String range = rangesJSONArray.getJSONObject( i ).getString( "range" ); String from = range.split("TO")[0].trim(); from = from.substring(1); validateDateFormat(from); String to = range.split("TO")[1].trim(); to = to.substring(0, to.length() - 1); validateDateFormat(to); } } DateRangeFactory(DateFormatFactory dateFormatFactory); String getRangeString(String label, Calendar calendar); String getRangeString(String from, String to); Map<String, String> getRangeStrings(Calendar calendar); JSONArray replaceAliases(
		JSONArray rangesJSONArray, Calendar calendar, JSONFactory jsonFactory); String replaceAliases(String rangeString, Calendar calendar); void validateRange(String ranges);  }
@Test(expected = ParseException.class) public void testDateFormatShouldBeyyyyMMddHHmmss() throws Exception { _dateRangeFactory.validateRange( "[{\"label\":\"past-hour\", \"range\":\"20190908 TO *\"}]"); }
@Test(expected = ParseException.class) public void testInvalidRangeAliases() throws Exception { _dateRangeFactory.validateRange( "[{\"label\":\"past-hour\", \"range\":\"[past-test TO *]\"}]"); }
@Test(expected = ParseException.class) public void testInvalidRangeWithoutBrackets() throws Exception { _dateRangeFactory.validateRange( "[{\"label\":\"past-hour\", \"range\":\"past-hour TO *\"}]"); }