@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)); }
@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)); }
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; }
@Test public void shouldNotPopulateErrorsWhenTimerSpecIsValid() { timerConfig = new TimerConfig("0 0 12 * * ?", false); timerConfig.validate(null); assertThat(timerConfig.errors().isEmpty(), is(true)); }
@Test public void shouldPopulateErrorsWhenTimerSpecIsInvalid() { timerConfig = new TimerConfig("SOME JUNK TIMER SPEC", false); timerConfig.validate(null); assertThat(timerConfig.errors().firstError(), startsWith("Invalid cron syntax")); }