Esempio n. 1
0
  @Before
  public void setUp() throws Exception {

    task = new Task();
    alarms = mock(TaskAlarmManager.class);
    reminder = mock(TaskDateCalculation.class);
    dates = mock(TaskDateProvider.class);
    reminders = mock(ReminderCalculations.class);
    recurrences = mock(RecurrenceCalculations.class);

    today = Calendar.getInstance();
    today.setTime(TaskDateFormatter.getToday());

    when(reminders.create(task)).thenReturn(reminder);
    when(dates.getToday()).thenReturn(today);
    when(dates.getNow()).thenReturn(today);
  }
Esempio n. 2
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());
  }