Esempio n. 1
0
  @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());
  }
Esempio n. 2
0
  @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());
  }
Esempio n. 3
0
  @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());
  }
Esempio n. 4
0
  @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());
  }
Esempio n. 5
0
  @Test
  public void
      WHEN_past_reminderdate_and_past_targetdate_and_weekly_remindertype__THEN_reminderdate_moves_to_next_week() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -1);

    task.setReminderType(Task.REMINDER_WEEKLY);
    task.setReminderDate(calendar.getTime());
    task.setTargetDate(calendar.getTime());

    calendar.add(Calendar.DATE, 7);
    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());
  }