BackupJobs { public Job scheduleRegular() { return schedule(preferences.getRegularTimeoutSecs(), REGULAR, false); } BackupJobs(Context context);   BackupJobs(Context context, Preferences preferences); @Nullable Job scheduleIncoming(); Job scheduleRegular(); @Nullable Job scheduleContentTriggerJob(); @Nullable Job scheduleBootup(); @Nullable Job scheduleImmediate(); void cancelAll(); void cancelRegular();  }
@Test public void shouldNotScheduleRegularBackupIfAutoBackupIsDisabled() throws Exception { when(preferences.isAutoBackupEnabled()).thenReturn(false); assertThat(subject.scheduleRegular()).isEqualTo(null); }
@Test public void shouldScheduleRegular() throws Exception { when(preferences.isAutoBackupEnabled()).thenReturn(true); when(preferences.getRegularTimeoutSecs()).thenReturn(2000); Job job = subject.scheduleRegular(); verifyJobScheduled(job, 2000, "REGULAR"); }