Search in sources :

Example 31 with IntegerFieldValue

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

the class OnTest method testAsStringSpecialCharW.

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

Example 32 with IntegerFieldValue

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

the class OnTest method testAsStringJustNumber.

@Test
public void testAsStringJustNumber() {
    final int expression = 3;
    assertEquals(String.format("%s", expression), new On(new IntegerFieldValue(expression)).asString());
}
Also used : IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 33 with IntegerFieldValue

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

the class OnTest method testAsStringSpecialCharLWithNth.

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

Example 34 with IntegerFieldValue

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

the class OnTest method testAsStringWithNth.

@Test
public void testAsStringWithNth() {
    final int first = 3;
    final int second = 4;
    final String expression = String.format("%s#%s", first, second);
    assertEquals(expression, new On(new IntegerFieldValue(first), new SpecialCharFieldValue(SpecialChar.HASH), new IntegerFieldValue(second)).asString());
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 35 with IntegerFieldValue

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

the class ValidationFieldExpressionVisitorTest method testVisitEvery.

@Test
public void testVisitEvery() {
    Every every = new Every(new IntegerFieldValue(MIDDLE));
    final ValidationFieldExpressionVisitor spy = Mockito.spy(visitor);
    final ValidationFieldExpressionVisitor strictSpy = Mockito.spy(strictVisitor);
    assertEquals(every, every.accept(spy));
    assertEquals(every, every.accept(strictSpy));
    final Between between = new Between(new IntegerFieldValue(LOW), new IntegerFieldValue(MIDDLE));
    every = new Every(between, new IntegerFieldValue(HIGH));
    assertEquals(every, every.accept(spy));
    assertEquals(every, every.accept(strictSpy));
    between.accept(verify(spy, times(1)));
    between.accept(verify(strictSpy, times(1)));
    final On on = new On(new IntegerFieldValue(LOW));
    every = new Every(on, new IntegerFieldValue(HIGH));
    assertEquals(every, every.accept(spy));
    assertEquals(every, every.accept(strictSpy));
    on.accept(verify(spy, times(1)));
    on.accept(verify(strictSpy, times(1)));
}
Also used : IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Aggregations

IntegerFieldValue (com.cronutils.model.field.value.IntegerFieldValue)43 Test (org.junit.Test)32 CronField (com.cronutils.model.field.CronField)18 SpecialCharFieldValue (com.cronutils.model.field.value.SpecialCharFieldValue)16 On (com.cronutils.model.field.expression.On)13 SingleCron (com.cronutils.model.SingleCron)10 ArrayList (java.util.ArrayList)10 Between (com.cronutils.model.field.expression.Between)6 Before (org.junit.Before)6 WeekDay (com.cronutils.mapper.WeekDay)4 FieldConstraints (com.cronutils.model.field.constraint.FieldConstraints)4 Every (com.cronutils.model.field.expression.Every)3 VisibleForTesting (com.cronutils.utils.VisibleForTesting)3 And (com.cronutils.model.field.expression.And)1 SpecialChar (com.cronutils.model.field.value.SpecialChar)1