package com.hubspot.singularity.data;

import org.junit.Assert;
import org.junit.Test;

import com.google.inject.Inject;
import com.hubspot.singularity.SingularityTestBaseNoDb;


public class ValidatorTest extends SingularityTestBaseNoDb {

  @Inject
  private SingularityValidator validator;

  @Test
  public void testCronExpressionHandlesDayIndexing() {
    Assert.assertEquals("0 0 12 ? * 1", validator.getQuartzScheduleFromCronSchedule("0 12 * * 0"));
    Assert.assertEquals("0 0 12 ? * 1-6", validator.getQuartzScheduleFromCronSchedule("0 12 * * 0-5"));
    Assert.assertEquals("0 0 12 ? * 1,2,3,4", validator.getQuartzScheduleFromCronSchedule("0 12 * * 0,1,2,3"));
    Assert.assertEquals("0 0 12 ? * MON,TUES,WED", validator.getQuartzScheduleFromCronSchedule("0 12 * * MON,TUES,WED"));
    Assert.assertEquals("0 0 12 ? * MON-WED", validator.getQuartzScheduleFromCronSchedule("0 12 * * MON-WED"));
  }

}

@@ -293,106 +293,467 @@
 %0A%0A  
-@Test%0A  public void testCronExpressionHandlesDayIndexing() %7B%0A    Assert.assertEquals(%220 0 12 ? * 1
+/**%0A   * Standard cron: day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)%0A   * Quartz: 1-7 or SUN-SAT%0A   */%0A%0A  @Test%0A  public void testCronExpressionHandlesDayIndexing() %7B%0A    Assert.assertEquals(%220 0 12 ? * SUN%22, validator.getQuartzScheduleFromCronSchedule(%220 12 * * 7%22));%0A    Assert.assertEquals(%220 0 12 ? * SAT%22, validator.getQuartzScheduleFromCronSchedule(%220 12 * * 6%22));%0A    Assert.assertEquals(%220 0 12 ? * SUN
 %22, v
@@ -851,11 +851,15 @@
 ? * 
-1-6
+SUN-FRI
 %22, v
@@ -959,15 +959,23 @@
 ? * 
-1,2,3,4
+SUN,MON,TUE,WED
 %22, v
@@ -1078,25 +1078,24 @@
  ? * MON,TUE
-S
 ,WED%22, valid
@@ -1150,17 +1150,16 @@
  MON,TUE
-S
 ,WED%22));

fix tests