Skip to content

Commit a631ab3

Browse files
authored
Merge pull request #488 from IndeedSi/480-fix-incorrect-definition-in-test
#480 The unit test didn't define valid DoW value, which caused the test failure
2 parents 6660d8f + 92b954c commit a631ab3

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

.github/workflows/maven-test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
java: [ '8', '11', '16' ]
21+
java: [ '16' ]
2222

2323
runs-on: ubuntu-latest
2424

2525
steps:
2626
- uses: actions/checkout@v2
27-
- name: Set up JDK 1.8
28-
uses: actions/setup-java@v1
27+
- name: Set up JDK
28+
uses: actions/setup-java@v2
2929
with:
30+
distribution: 'zulu'
3031
java-version: ${{ matrix.java }}
3132

3233
- name: compile and test

src/test/java/com/cronutils/Issue480Test.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Issue480Test {
2929
private static final CronDefinition definition = CronDefinitionBuilder.defineCron()
3030
.withMinutes().and()
3131
.withHours().and()
32-
.withDayOfWeek().supportsQuestionMark().and()
32+
.withDayOfWeek().withValidRange(1, 7).withMondayDoWValue(1).supportsQuestionMark().and()
3333
.withDayOfMonth().supportsL().supportsQuestionMark().and()
3434
.withDayOfYear().supportsQuestionMark().and()
3535
.withMonth().and()
@@ -40,7 +40,6 @@ public class Issue480Test {
4040
.instance();
4141

4242
@Test
43-
@Ignore // TODO broken??
4443
public void testIntervalsEvery5thMonthsSinceASpecificMonth() {
4544
LocalDateTime sunday = LocalDateTime.of(2021, 6, 27, 0, 0);
4645
Assert.assertEquals(sunday.getDayOfWeek(), DayOfWeek.SUNDAY);
@@ -65,8 +64,8 @@ private CronBuilder getWeekly(ZonedDateTime now) {
6564
return CronBuilder.cron(definition)
6665
.withMinute(on(now.getMinute()))
6766
.withHour(on(now.getHour()))
68-
.withDoW(on(now.getDayOfWeek().ordinal())) // ordinal -- 0 to 6
69-
// .withDoW(on(now.getDayOfWeek().getValue())) // value -- 1 to 7
67+
// .withDoW(on(now.getDayOfWeek().ordinal())) // ordinal -- 0 to 6, This is a wrong way of mapping
68+
.withDoW(on(now.getDayOfWeek().getValue())) // value -- 1 to 7
7069
.withDoM(questionMark())
7170
.withDoY(questionMark())
7271
.withMonth(always())

0 commit comments

Comments
 (0)