### Question:
ArgumentResolver { void resolveRepeat(Map<String, Object> map, ReminderImpl reminder, Calendar now){ if(!map.containsKey(Constants.KEY_REPEAT)){ reminder.repeatDuration = -1; return; } Map<String, Object> repeatMap = (Map<String, Object>) map.get(Constants.KEY_REPEAT); zip(Constants.KEYS_TIME, Constants.KEYS_MUL, Constants.KEYS_CAL_FIELD) .forEach((key, mul, field) -> { if(repeatMap.containsKey(key)){ int duration = ((Number) repeatMap.get(key)).intValue(); reminder.repeatDuration += duration * mul; if(key.equals(Constants.KEY_WEEK)) duration *= 7; now.add(field, duration); } return true; }); if(repeatMap.containsKey(Constants.KEY_DOW)) resolveRepeatDow(((Number) repeatMap.get(Constants.KEY_DOW)).intValue(), reminder, now); if(repeatMap.containsKey(Constants.KEY_SHIFT)) getOrDefault(map, Constants.KEY_START_TIME, new HashMap<String, Object>()) .put(Constants.KEY_SHIFT, repeatMap.get(Constants.KEY_SHIFT)); reminder.startTime = now.getTime(); } ArgumentResolver(Context context); Reminder resolve(Map<String, Object> map, String rawText, Calendar now);  }### Answer:
@Test public void resolveRepeatYear() { Map<String, Object> map = make("{repeat:{year:2}}"); Calendar c = Calendar.getInstance(); c.setTime(now.getTime()); c.add(Calendar.YEAR, 2); long expectedDur = 2L * 365 * 24 * 3600 * 1000; resolver.resolveRepeat(map, reminder, now); assertEquals(expectedDur, reminder.repeatDuration, 100); assertNotNull(reminder.startTime); assertEquals(c.getTimeInMillis(), reminder.startTime.getTime(), 100); }
@Test public void resolveRepeatWeek() { Map<String, Object> map = make("{repeat:{week:2}}"); Calendar c = Calendar.getInstance(); c.setTime(now.getTime()); c.add(Calendar.DAY_OF_MONTH, 2*7); long expectedDur = 2L * 7 * 24 * 3600 * 1000; resolver.resolveRepeat(map, reminder, now); assertEquals(expectedDur, reminder.repeatDuration, 100); assertNotNull(reminder.startTime); assertEquals(c.getTimeInMillis(), reminder.startTime.getTime(), 100); }
@Test public void resolveRepeatSecond() { Map<String, Object> map = make("{repeat:{second:200}}"); Calendar c = Calendar.getInstance(); c.setTime(now.getTime()); c.add(Calendar.SECOND, 200); long expectedDur = 200L * 1000; resolver.resolveRepeat(map, reminder, now); assertEquals(expectedDur, reminder.repeatDuration, 100); assertNotNull(reminder.startTime); assertEquals(c.getTimeInMillis(), reminder.startTime.getTime(), 100); }