### Question:
SessionRangeCalculator { public SessionDateInfo findDateRange(String schoolYearRange) { Pair<String, String> years = parseDateRange(schoolYearRange); Set<String> edOrgIds = edOrgHelper.getDirectEdorgs(); Iterable<Entity> sessions = getSessions(years, edOrgIds); return findMinMaxDates(sessions); }  SessionDateInfo findDateRange(String schoolYearRange);  }### Answer:
@Test public void shouldCatchInvalidDateRange() { List<String> invalidRanges = Arrays.asList("123-1234", "1234-123", "12345-1234", "1234-12345", "123A-1234", "1234-123A", "12341234", "1234--1234", "2001-2001", "2001-2000"); for (String range : invalidRanges) { try { initRepo(); calc.findDateRange(range); Assert.fail("Did not catch an invalid range: " + range); } catch (QueryParseException e) { } } }
@Test public void shouldAllowValidDateRange() { initRepo(); SessionDateInfo result = calc.findDateRange("2009-2010"); Assert.assertEquals("Should match", "2006-08-14", result.getStartDate()); Assert.assertEquals("Should match", "2009-05-22", result.getEndDate()); Assert.assertEquals("Should match", 4, result.getSessionIds().size()); }
@Test public void shouldReturnEmptyRanges() { initRepo(Collections.EMPTY_LIST); SessionDateInfo result = calc.findDateRange("2009-2010"); Assert.assertEquals("Should match", "", result.getStartDate()); Assert.assertEquals("Should match", "", result.getEndDate()); Assert.assertEquals("Should match", 0, result.getSessionIds().size()); }