fix tests

This commit is contained in:
Roumen Georgiev 2019-09-12 12:08:36 +03:00
parent 7c78270981
commit 68b6591f42

View file

@ -32,12 +32,21 @@ public class TriggerTimeRangeTest {
@Test @Test
public void shouldRunTest() { public void shouldRunTest() {
// scheduled 1 min before
TriggerTimeRange t; TriggerTimeRange t;
// when(System.currentTimeMillis()).thenReturn((long) now*60000);
when(DateUtil.now()).thenReturn((long) now*60000);
// scheduled 1 min in the future // range starts 1 min in the future
t = new TriggerTimeRange().period(now + 1, now + 30); t = new TriggerTimeRange().period(now + 1, now + 30);
Assert.assertFalse(t.shouldRun()); Assert.assertEquals(false, t.shouldRun());
// range starts 30 min back
t = new TriggerTimeRange().period((int) (System.currentTimeMillis() - 30*60000), now + 30);
Assert.assertEquals(true, t.shouldRun());
// Period is all day long
t = new TriggerTimeRange().period(1, 1440);
Assert.assertEquals(true, t.shouldRun());
// already run // already run
t = new TriggerTimeRange().period(now - 1, now + 30).lastRun(now - 1); t = new TriggerTimeRange().period(now - 1, now + 30).lastRun(now - 1);