コード例 #1
0
  @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());
  }
コード例 #2
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());
  }
コード例 #3
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());
  }
コード例 #4
0
  @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());
  }
コード例 #5
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());
  }
コード例 #6
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());
  }
コード例 #7
0
  @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());
  }
コード例 #8
0
 @Test
 public void remindertype_is_manual_by_default() {
   Assert.assertEquals(Task.REMINDER_MANUAL, task.getReminderType());
 }
コード例 #9
0
 @Test
 public void reminderdate_stays_null_if_no_targetdate_set() {
   task.initializeReminders(reminders, dates);
   Assert.assertNull(task.getReminderDate());
 }