other.clearDatabase(true);
}
@Test
public void testOffsetFromEpoch() throws InterruptedException {
PlayOrmCronJob monitor = new PlayOrmCronJob();
monitor.setId("coolMon");
monitor.setEpochOffset(3000L);
monitor.setTimePeriodMillis(10000);
monitor.addProperty("email", "dean@xsoftware");
monitor.addProperty("myName", "dean");
server1Monitor.saveMonitor(monitor);
PlayOrmCronJob m = server1Monitor.getMonitor(monitor.getId());
Assert.assertEquals(monitor.getTimePeriodMillis(), m.getTimePeriodMillis());
String email1 = monitor.getProperties().get("email");
String emailB = m.getProperties().get("email");
Assert.assertEquals(email1, emailB);
mockTime.addReturnTime(32000);
mockHash.addReturnValue(0); //identify the first server and run server 1
clusterChecker1.run();
Assert.assertNull(listener1.getLastFiredMonitor());
mockTime.addReturnTime(32600);
mockHash.addReturnValue(0); //identify the first server and run server 1
clusterChecker1.run();
PlayOrmCronJob job = listener1.getLastFiredMonitor();
Assert.assertEquals(monitor.getId(), job.getId());
mockTime.addReturnTime(39000);
mockHash.addReturnValue(0); //identify the first server and run server 1
clusterChecker1.run();
Assert.assertNull(listener1.getLastFiredMonitor());
mockTime.addReturnTime(50000);
mockHash.addReturnValue(0); //identify the first server and run server 1
clusterChecker1.run();
PlayOrmCronJob job2 = listener1.getLastFiredMonitor();
Assert.assertEquals(monitor.getId(), job2.getId());
}