Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incubator-kie-issues-3871] Repeating timer gets executed immediately #3872

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

abhijithumbe
Copy link

#3871

Using timer node with timer expression R/PT5M, the job gets executed immediately, then in the configured 5min intervals.

@@ -135,7 +135,7 @@ public void testParseRepeatablePeriodOnly() {

assertThat(parsedRepeatable[0]).isEqualTo(-1L);
// Default delay time is 1000ms
assertThat(parsedRepeatable[1]).isEqualTo(1000L);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to cover this targeted logic, we can add below junit


@Test
    public void testDefaultDelay() {
        String isoString = "R/PT0M";
        long[] parsedRepeatable = DateTimeUtils.parseRepeatableDateTime(isoString);
        // Default delay time is 1000ms
        assertThat(parsedRepeatable[1]).isEqualTo(1000L);
    }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have the same test here as it was used in v7:
https://github.com/kiegroup/jbpm/blob/main/jbpm-flow/src/test/java/org/jbpm/process/core/timer/DateTimeUtilsTest.java#L126-L136

In the new syntax, this would be:

        assertThat(parsedRepeatable[0]).isEqualTo(-1L);
        assertThat(parsedRepeatable[1] <= MINUTE_IN_MILLISECONDS).as("Parsed delay is bigger than " + MINUTE_IN_MILLISECONDS).isTrue();
        assertThat(parsedRepeatable[1] > FIFTY_NINE_SECONDS_IN_MILLISECONDS)
                .as("Parsed delay is too low! Expected value is between " + MINUTE_IN_MILLISECONDS + " and " + FIFTY_NINE_SECONDS_IN_MILLISECONDS + " but is " + parsedRepeatable[1]).isTrue();
        assertThat(parsedRepeatable[2]).as("Parsed period should be one minute in milliseconds but is " + parsedRepeatable[2]).isEqualTo(MINUTE_IN_MILLISECONDS);

Not directly linked to this change, but as you are on it, I think it might be a good idea to add the additional tests from v7 (starting in L138) to the codebase as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinweiler Thank you for looking into this. I have included additional tests as you suggested.Please take a look.

Copy link
Contributor

@martinweiler martinweiler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @abhijithumbe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants