Search in sources :

Example 6 with SpecialCharFieldValue

use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.

the class FieldValueGeneratorFactoryTest method testForCronFieldOnSpecialCharNotNone.

@Test
public void testForCronFieldOnSpecialCharNotNone() {
    final On mockOn = mock(On.class);
    for (final SpecialChar s : SpecialChar.values()) {
        if (!s.equals(SpecialChar.NONE)) {
            boolean gotException = false;
            when(mockOn.getSpecialChar()).thenReturn(new SpecialCharFieldValue(s));
            when(mockCronField.getExpression()).thenReturn(mockOn);
            try {
                FieldValueGeneratorFactory.forCronField(mockCronField);
            } catch (final RuntimeException e) {
                gotException = true;
            }
            assertTrue("Should get exception when asking for OnValueGenerator with special char", gotException);
        }
    }
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) SpecialChar(com.cronutils.model.field.value.SpecialChar) Test(org.junit.Test)

Example 7 with SpecialCharFieldValue

use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.

the class FieldValueGeneratorFactoryTest method createDayOfMonthValueGeneratorInstance.

private FieldValueGenerator createDayOfMonthValueGeneratorInstance(final SpecialChar specialChar) {
    when(mockCronField.getField()).thenReturn(CronFieldName.DAY_OF_MONTH);
    final On mockOn = mock(On.class);
    when(mockOn.getSpecialChar()).thenReturn(new SpecialCharFieldValue(specialChar));
    when(mockCronField.getExpression()).thenReturn(mockOn);
    return FieldValueGeneratorFactory.createDayOfMonthValueGeneratorInstance(mockCronField, 2015, 1);
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue)

Example 8 with SpecialCharFieldValue

use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.

the class FieldValueGeneratorFactoryTest method testForCronFieldOnSpecialCharNone.

@Test
public void testForCronFieldOnSpecialCharNone() {
    final On mockOn = mock(On.class);
    when(mockOn.getSpecialChar()).thenReturn(new SpecialCharFieldValue(SpecialChar.NONE));
    when(mockCronField.getExpression()).thenReturn(mockOn);
    assertEquals(OnFieldValueGenerator.class, FieldValueGeneratorFactory.forCronField(mockCronField).getClass());
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) Test(org.junit.Test)

Example 9 with SpecialCharFieldValue

use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.

the class OnDayOfMonthValueGeneratorLTest method setUp.

@Before
public void setUp() {
    final FieldConstraints constraints = FieldConstraintsBuilder.instance().addLSupport().createConstraintsInstance();
    fieldValueGenerator = new OnDayOfMonthValueGenerator(new CronField(CronFieldName.DAY_OF_MONTH, new On(new SpecialCharFieldValue(SpecialChar.L)), constraints), YEAR, MONTH);
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) FieldConstraints(com.cronutils.model.field.constraint.FieldConstraints) CronField(com.cronutils.model.field.CronField) On(com.cronutils.model.field.expression.On) Before(org.junit.Before)

Example 10 with SpecialCharFieldValue

use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.

the class OnTest method testAsStringSpecialCharL.

@Test
public void testAsStringSpecialCharL() {
    final String expression = "L";
    assertEquals(expression, new On(new SpecialCharFieldValue(SpecialChar.L)).asString());
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) Test(org.junit.Test)

Aggregations

SpecialCharFieldValue (com.cronutils.model.field.value.SpecialCharFieldValue)23 Test (org.junit.Test)17 IntegerFieldValue (com.cronutils.model.field.value.IntegerFieldValue)16 CronField (com.cronutils.model.field.CronField)5 On (com.cronutils.model.field.expression.On)5 SingleCron (com.cronutils.model.SingleCron)4 ArrayList (java.util.ArrayList)4 SpecialChar (com.cronutils.model.field.value.SpecialChar)3 VisibleForTesting (com.cronutils.utils.VisibleForTesting)3 FieldConstraints (com.cronutils.model.field.constraint.FieldConstraints)1 Before (org.junit.Before)1