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#1612] Adding validation for calendar.properties #3788

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Abhitocode
Copy link
Contributor

@Abhitocode Abhitocode commented Nov 20, 2024

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.

@Abhitocode Abhitocode changed the title [incubator-kie-issues#1612] Addind validation for calendar.properties [incubator-kie-issues#1612] Adding validation for calendar.properties Nov 20, 2024
@kie-ci3
Copy link
Contributor

kie-ci3 commented Nov 20, 2024

PR job #1 was: UNSTABLE
Possible explanation: This should be test failures

Reproducer

build-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:

  • PASSED: 3056
  • FAILED: 1

Those are the test failures:

PR check / Build projects / org.kie.kogito.it.JDBCOptimisticLockingIT.testAsyncWIH Assertion 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);
Copy link
Contributor

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());
}
}
Copy link
Contributor

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.

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.

Providing an inconsistent set of properties on calendar.properties may lead to unexpected behavior
3 participants