@Test public void reminderdate_equals_targetdate_by_default() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); task.setTargetDate(calendar.getTime()); task.initializeReminders(reminders, dates); Assert.assertEquals(task.getTargetDate(), task.getReminderDate()); }
@Test public void WHEN_no_targetdate_and_remindertype_weekly_THEN_reminderdate_set_nextweek_without_time_information() { task.setReminderType(Task.REMINDER_WEEKLY); Calendar calendar = (Calendar) today.clone(); calendar.add(Calendar.DATE, 7); when(reminder.getNext(today.getTime(), dates, 1)).thenReturn(calendar.getTime()); task.initializeReminders(reminders, dates); Assert.assertEquals(calendar.getTime(), task.getReminderDate()); }
@Test public void WHEN_no_targetdate_and_remindertype_weekly_THEN_reminderdate_set_nextweek() { task.setReminderType(Task.REMINDER_WEEKLY); Calendar calendar = (Calendar) today.clone(); calendar.add(Calendar.DATE, 7); when(reminder.getNext(today.getTime(), dates, 1)).thenReturn(calendar.getTime()); task.initializeReminders(reminders, dates); verify(reminder, times(1)).getNext(any(Date.class), any(TaskDateProvider.class), eq(1)); Assert.assertEquals(calendar.getTime(), task.getReminderDate()); }
@Test public void WITH_past_reminderdate_and_weekly_remindertype_WHEN_targetdate_is_null_THEN_reminderdate_moves_to_week_after_today() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -1); task.setReminderType(Task.REMINDER_WEEKLY); task.setReminderDate(calendar.getTime()); calendar.setTime(TaskDateFormatter.getToday()); calendar.add(Calendar.DATE, 7); when(reminder.getNext(any(Date.class), any(TaskDateProvider.class), eq(1))) .thenReturn(calendar.getTime()); task.initializeReminders(reminders, dates); verify(reminder, times(1)).getNext(any(Date.class), any(TaskDateProvider.class), eq(1)); Assert.assertEquals(calendar.getTime(), task.getReminderDate()); }
@Test public void WITH_future_targetdate_and_reminderdate_and_remindertype_weekly_WHEN_dates_are_equal_THEN_reminderdate_stays_targetdate() { task.setReminderType(Task.REMINDER_WEEKLY); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); task.setTargetDate(calendar.getTime()); task.setReminderDate(calendar.getTime()); task.initializeReminders(reminders, dates); Assert.assertEquals(task.getTargetDate(), task.getReminderDate()); }
@Test public void WITH_equal_future_targetdate_and_reminderdate_WHEN_targetdate_set_to_earlier_future_date_THEN_reminderdate_set_to_targetdate() { Calendar calendar = Calendar.getInstance(); task.setReminderType(Task.REMINDER_WEEKLY); calendar.add(Calendar.DATE, 2); task.setTargetDate(calendar.getTime()); task.setReminderDate(calendar.getTime()); calendar.add(Calendar.DATE, -1); task.setTargetDate(calendar.getTime()); task.initializeReminders(reminders, dates); Assert.assertEquals(task.getTargetDate(), task.getReminderDate()); }
@Test public void WHEN_past_targetdate_and_future_reminderdate_and_weekly_remindertype_THEN_reminderdate_remains_unchanged_and_future() { Calendar calendar = Calendar.getInstance(); task.setReminderType(Task.REMINDER_WEEKLY); calendar.add(Calendar.DATE, -1); task.setTargetDate(calendar.getTime()); calendar.add(Calendar.DATE, 7); task.setReminderDate(calendar.getTime()); when(reminder.getNext(task.getTargetDate(), dates, 1)).thenReturn(calendar.getTime()); task.initializeReminders(reminders, dates); verify(reminder, times(1)).getNext(any(Date.class), any(TaskDateProvider.class), eq(1)); Assert.assertEquals(calendar.getTime(), task.getReminderDate()); }
@Test public void remindertype_is_manual_by_default() { Assert.assertEquals(Task.REMINDER_MANUAL, task.getReminderType()); }
@Test public void reminderdate_stays_null_if_no_targetdate_set() { task.initializeReminders(reminders, dates); Assert.assertNull(task.getReminderDate()); }