@Test
public void calendarRelativeTest() {

    TriggerAction ta = new TriggerAction("tenant", "plugin", "action", new TimeConstraint("20:30", "20:45"));
    Calendar eventCal = Calendar.getInstance();
    eventCal.set(2016, Calendar.JANUARY, 26, 20, 31);
    Alert alert = new Alert();
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.JANUARY, 23, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2015, Calendar.FEBRUARY, 23, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2015, Calendar.FEBRUARY, 23, 19, 25);
    alert.setCtime(eventCal.getTimeInMillis());
    assertFalse(ActionsValidator.validate(ta, alert));
    eventCal.set(2015, Calendar.MARCH, 23, 19, 25);
    alert.setCtime(eventCal.getTimeInMillis());
    assertFalse(ActionsValidator.validate(ta, alert));
    ta = new TriggerAction("tenant", "plugin", "action", new TimeConstraint("Thursday,20:30", "Sunday,20:45"));
    eventCal.set(2016, Calendar.JANUARY, 28, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.JANUARY, 29, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.JANUARY, 30, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.JANUARY, 18, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertFalse(ActionsValidator.validate(ta, alert));
    eventCal.set(2015, Calendar.JANUARY, 19, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertFalse(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.JANUARY, 31, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.JANUARY, 7, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.JANUARY, 8, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.FEBRUARY, 5, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertTrue(ActionsValidator.validate(ta, alert));
    eventCal.set(2016, Calendar.FEBRUARY, 15, 20, 31);
    alert.setCtime(eventCal.getTimeInMillis());
    assertFalse(ActionsValidator.validate(ta, alert));
}