예제 #1
0
 @Test
 public void shouldCreateTimerGivenTheAttributeMapOnlyOnChangesIsNotPresent() {
   HashMap<String, String> mapOfTimerValues = new HashMap<String, String>();
   mapOfTimerValues.put(TimerConfig.TIMER_SPEC, "0 0 * * * ?");
   TimerConfig timer = TimerConfig.createTimer(mapOfTimerValues);
   assertThat(timer.getTimerSpec(), is("0 0 * * * ?"));
   assertThat(timer.shouldTriggerOnlyOnChanges(), is(false));
 }
예제 #2
0
 @Test
 public void shouldCreateTimerGivenTheAttributeMapIfOnlyOnChangesIsNotCheckedInUI() {
   HashMap<String, String> mapOfTimerValues = new HashMap<String, String>();
   mapOfTimerValues.put(TimerConfig.TIMER_SPEC, "0 0 * * * ?");
   mapOfTimerValues.put(TimerConfig.TIMER_ONLY_ON_CHANGES, "0");
   TimerConfig timer = TimerConfig.createTimer(mapOfTimerValues);
   assertThat(timer.getTimerSpec(), is("0 0 * * * ?"));
   assertThat(timer.getOnlyOnChanges(), is(false));
 }
예제 #3
0
  private Timer(boolean dummy, Plugin plugin, TimerConfig config, int seconds) {
    this.plugin = plugin;
    this.majorDelay = config.getMajorDuration();
    this.minorDelay = config.getMinorDuration();
    this.format = config.getFormat();
    this.endMessage = config.getEndMessage();

    this.taskId = -1;
    this.remainingTime = seconds;

    this.currentDelay = 0;
  }
예제 #4
0
 @Test
 public void shouldNotPopulateErrorsWhenTimerSpecIsValid() {
   timerConfig = new TimerConfig("0 0 12 * * ?", false);
   timerConfig.validate(null);
   assertThat(timerConfig.errors().isEmpty(), is(true));
 }
예제 #5
0
 @Test
 public void shouldPopulateErrorsWhenTimerSpecIsInvalid() {
   timerConfig = new TimerConfig("SOME JUNK TIMER SPEC", false);
   timerConfig.validate(null);
   assertThat(timerConfig.errors().firstError(), startsWith("Invalid cron syntax"));
 }