### Question:
CronParser { static int getNext(final CronEntry entry, final int current) throws MessageFormatException { int result = 0; if (entry.currentWhen == null) { entry.currentWhen = calculateValues(entry); } List<Integer> list = entry.currentWhen; int next = -1; for (Integer i : list) { if (i.intValue() > current) { next = i.intValue(); break; } } if (next != -1) { result = next - current; } else { int first = list.get(0).intValue(); result = entry.end + first - entry.start - current; if (entry.name.equals("DayOfWeek") || entry.name.equals("Month")) { result++; } } return result; }  static long getNextScheduledTime(final String cronEntry, long currentTime); static void validate(final String cronEntry);  }### Answer:
@Test public void testGetNextCommaSeparated() throws MessageFormatException { String token = "3,5,7"; int next = CronParser.getNext(createEntry(token, 1, 10), 3); assertEquals(2, next); next = CronParser.getNext(createEntry(token, 1, 10), 8); assertEquals(4, next); next = CronParser.getNext(createEntry(token, 1, 10), 1); assertEquals(2, next); }
@Test public void testGetNextRange() throws MessageFormatException { String token = "3-5"; int next = CronParser.getNext(createEntry(token, 1, 10), 3); assertEquals(1, next); next = CronParser.getNext(createEntry(token, 1, 10), 5); assertEquals(7, next); next = CronParser.getNext(createEntry(token, 1, 10), 6); assertEquals(6, next); next = CronParser.getNext(createEntry(token, 1, 10), 1); assertEquals(2, next); }
@Test public void testGetNextExact() throws MessageFormatException { String token = "3"; int next = CronParser.getNext(createEntry(token, 0, 10), 2); assertEquals(1, next); next = CronParser.getNext(createEntry(token, 0, 10), 3); assertEquals(10, next); next = CronParser.getNext(createEntry(token, 0, 10), 1); assertEquals(2, next); }