try {
beginTx();
setupResources();
MeasurementSchedule schedule1 = new MeasurementSchedule(definitionCt1, resource1);
em.persist(schedule1);
definitionCt1.addSchedule(schedule1);
resource1.addSchedule(schedule1);
resource1 = em.merge(resource1);
commitAndClose();
// 60s is valid
schedule1.setInterval(60000L);
measurementScheduleManager.updateSchedule(overlord, schedule1);
schedule1 = measurementScheduleManager.getScheduleById(overlord, schedule1.getId());
Assert.assertEquals(60000L, schedule1.getInterval());
// 10s is invalid and should be assigned 30s
schedule1.setInterval(10000L);
measurementScheduleManager.updateSchedule(overlord, schedule1);
schedule1 = measurementScheduleManager.getScheduleById(overlord, schedule1.getId());
Assert.assertEquals(MeasurementConstants.MINIMUM_COLLECTION_INTERVAL_MILLIS, schedule1.getInterval());
// 0s is invalid and should be assigned 30s
schedule1.setInterval(0L);
measurementScheduleManager.updateSchedule(overlord, schedule1);
schedule1 = measurementScheduleManager.getScheduleById(overlord, schedule1.getId());
Assert.assertEquals(MeasurementConstants.MINIMUM_COLLECTION_INTERVAL_MILLIS, schedule1.getInterval());
// negative intervals are invalid and should be assigned 30s
schedule1.setInterval(-60000L);
measurementScheduleManager.updateSchedule(overlord, schedule1);
schedule1 = measurementScheduleManager.getScheduleById(overlord, schedule1.getId());
Assert.assertEquals(MeasurementConstants.MINIMUM_COLLECTION_INTERVAL_MILLIS, schedule1.getInterval());
// Try a different mechanism
// 60s is valid
measurementScheduleManager.updateSchedulesForResource(overlord, resource1.getId(),