@Test public void resolveShift() { Calendar c = Calendar.getInstance(); c.clear(); resolver.resolveShift("morning", c); assertEquals(9, c.get(Calendar.HOUR_OF_DAY)); c.clear(); resolver.resolveShift("noon", c); assertEquals(12, c.get(Calendar.HOUR_OF_DAY)); c.clear(); resolver.resolveShift("afternoon", c); assertEquals(14, c.get(Calendar.HOUR_OF_DAY)); c.clear(); resolver.resolveShift("evening", c); assertEquals(18, c.get(Calendar.HOUR_OF_DAY)); c.clear(); resolver.resolveShift("night", c); assertEquals(20, c.get(Calendar.HOUR_OF_DAY)); assertEquals(0, c.get(Calendar.MINUTE)); assertEquals(1970, c.get(Calendar.YEAR)); assertEquals(Calendar.JANUARY, c.get(Calendar.MONTH)); assertEquals(1, c.get(Calendar.DAY_OF_MONTH)); assertEquals(0, c.get(Calendar.SECOND)); }
void resolveShift(String shift, Calendar calendar){ switch (shift){ case Constants.SHIFT_AM: calendar.set(Calendar.AM_PM, Calendar.AM); break; case Constants.SHIFT_PM: calendar.set(Calendar.AM_PM, Calendar.PM); break; case Constants.SHIFT_MORNING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_MORNING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_MORNING_TIME%100); break; case Constants.SHIFT_NOON: calendar.set(Calendar.HOUR_OF_DAY, 12); break; case Constants.SHIFT_AFTERNOON: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_AFTERNOON_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_AFTERNOON_TIME%100); break; case Constants.SHIFT_EVENING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_EVENING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_EVENING_TIME%100); break; case Constants.SHIFT_NIGHT: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_NIGHT_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_NIGHT_TIME%100); break; } }
ArgumentResolver { void resolveShift(String shift, Calendar calendar){ switch (shift){ case Constants.SHIFT_AM: calendar.set(Calendar.AM_PM, Calendar.AM); break; case Constants.SHIFT_PM: calendar.set(Calendar.AM_PM, Calendar.PM); break; case Constants.SHIFT_MORNING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_MORNING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_MORNING_TIME%100); break; case Constants.SHIFT_NOON: calendar.set(Calendar.HOUR_OF_DAY, 12); break; case Constants.SHIFT_AFTERNOON: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_AFTERNOON_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_AFTERNOON_TIME%100); break; case Constants.SHIFT_EVENING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_EVENING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_EVENING_TIME%100); break; case Constants.SHIFT_NIGHT: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_NIGHT_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_NIGHT_TIME%100); break; } } }
ArgumentResolver { void resolveShift(String shift, Calendar calendar){ switch (shift){ case Constants.SHIFT_AM: calendar.set(Calendar.AM_PM, Calendar.AM); break; case Constants.SHIFT_PM: calendar.set(Calendar.AM_PM, Calendar.PM); break; case Constants.SHIFT_MORNING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_MORNING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_MORNING_TIME%100); break; case Constants.SHIFT_NOON: calendar.set(Calendar.HOUR_OF_DAY, 12); break; case Constants.SHIFT_AFTERNOON: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_AFTERNOON_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_AFTERNOON_TIME%100); break; case Constants.SHIFT_EVENING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_EVENING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_EVENING_TIME%100); break; case Constants.SHIFT_NIGHT: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_NIGHT_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_NIGHT_TIME%100); break; } } ArgumentResolver(Context context); }
ArgumentResolver { void resolveShift(String shift, Calendar calendar){ switch (shift){ case Constants.SHIFT_AM: calendar.set(Calendar.AM_PM, Calendar.AM); break; case Constants.SHIFT_PM: calendar.set(Calendar.AM_PM, Calendar.PM); break; case Constants.SHIFT_MORNING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_MORNING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_MORNING_TIME%100); break; case Constants.SHIFT_NOON: calendar.set(Calendar.HOUR_OF_DAY, 12); break; case Constants.SHIFT_AFTERNOON: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_AFTERNOON_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_AFTERNOON_TIME%100); break; case Constants.SHIFT_EVENING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_EVENING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_EVENING_TIME%100); break; case Constants.SHIFT_NIGHT: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_NIGHT_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_NIGHT_TIME%100); break; } } ArgumentResolver(Context context); Reminder resolve(Map<String, Object> map, String rawText, Calendar now); }
ArgumentResolver { void resolveShift(String shift, Calendar calendar){ switch (shift){ case Constants.SHIFT_AM: calendar.set(Calendar.AM_PM, Calendar.AM); break; case Constants.SHIFT_PM: calendar.set(Calendar.AM_PM, Calendar.PM); break; case Constants.SHIFT_MORNING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_MORNING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_MORNING_TIME%100); break; case Constants.SHIFT_NOON: calendar.set(Calendar.HOUR_OF_DAY, 12); break; case Constants.SHIFT_AFTERNOON: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_AFTERNOON_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_AFTERNOON_TIME%100); break; case Constants.SHIFT_EVENING: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_EVENING_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_EVENING_TIME%100); break; case Constants.SHIFT_NIGHT: calendar.set(Calendar.HOUR_OF_DAY, Constants.DEFAULT_NIGHT_TIME/100); calendar.set(Calendar.MINUTE, Constants.DEFAULT_NIGHT_TIME%100); break; } } ArgumentResolver(Context context); Reminder resolve(Map<String, Object> map, String rawText, Calendar now);  }