-
Notifications
You must be signed in to change notification settings - Fork 209
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#1612] Adding validation for calendar.properties #3788
base: main
Are you sure you want to change the base?
Conversation
PR job Reproducerbuild-chain build full_downstream -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-kogito-runtimes -u #3788 --skipParallelCheckout NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution Please look here: https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-runtimes-pr/job/PR-3788/1/display/redirect Test results:
Those are the test failures: PR check / Build projects / org.kie.kogito.it.JDBCOptimisticLockingIT.testAsyncWIHAssertion condition defined as a org.kie.kogito.it.PersistenceTest 1 expectation failed.Expected status code <404> but was <200>. within 10 seconds. |
protected int getPropertyAsInt(String propertyName) { | ||
String value = businessCalendarConfiguration.getProperty(propertyName); | ||
|
||
return Integer.parseInt(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to return a nicer error message if this fails:
Caused by: java.lang.NumberFormatException: For input string: ""
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
at java.base/java.lang.Integer.parseInt(Integer.java:678)
at java.base/java.lang.Integer.parseInt(Integer.java:786)
at org.jbpm.process.core.timer.BusinessCalendarImpl.getPropertyAsInt(BusinessCalendarImpl.java:342)
if (!errorMessage.isEmpty()) { | ||
throw new IllegalArgumentException(errorMessage.toString()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to emit a log message here that summarizes the settings, including the configured ones.
jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendarImpl.java
Show resolved
Hide resolved
…nto incubator-kie-issues#1612 # Conflicts: # jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendarImpl.java # jbpm/jbpm-flow/src/test/java/org/jbpm/process/core/timer/BusinessCalendarImplTest.java
…t classes: CalendarBean is responsible of calendar.properties file. BusinessCalendarImpl is responsible of working time evaluation
Modified BusinessCalendarImpl class to include validation for calendar properties preventing misconfigurations.
Made business.hours.per.day calculated value based on start hour and end hour.
Added validations for properties to throw exceptions when calendar.properties file is misconfigured.
Added tests in BusinessCalendarImplTest to verify the modified intialization logic.
Closes: apache/incubator-kie-issues#1612
NOTE: Work in progress, modifying tests and adding new test in BusinessCalendarImplTest aligning the new changes w.r.t CaleandarBean.