Skip to content

[incubator-kie-issues#1748] DMNCompilerImpl class code refactoring and Test cases #6267

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

Merged
merged 30 commits into from
Mar 24, 2025

Conversation

ChinchuAjith
Copy link
Contributor

@ChinchuAjith ChinchuAjith commented Feb 28, 2025

Closes apache/incubator-kie-issues#1748

This PR is to refactor the methods to adhere to clean code principles and also added test cases to increase the coverage.

@ChinchuAjith ChinchuAjith marked this pull request as draft February 28, 2025 04:50
Copy link
Contributor

@gitgabrio gitgabrio left a comment

Choose a reason for hiding this comment

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

Good job @ChinchuAjith
There are only minor details to fix, IMO. Thanks! 👍

@ChinchuAjith ChinchuAjith requested a review from gitgabrio March 7, 2025 06:43
@gitgabrio gitgabrio requested review from baldimir and yesamer March 7, 2025 09:07
@gitgabrio gitgabrio marked this pull request as ready for review March 7, 2025 09:08
@yesamer
Copy link
Contributor

yesamer commented Mar 7, 2025

@ChinchuAjith Can you please describe the changes you applied in the first message? Thanks!

@ChinchuAjith
Copy link
Contributor Author

@ChinchuAjith Can you please describe the changes you applied in the first message? Thanks!

@yesamer added description for the PR

Copy link
Contributor

@gitgabrio gitgabrio left a comment

Choose a reason for hiding this comment

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

Just a couple of minor details, then would be fine for me

@ChinchuAjith ChinchuAjith requested a review from gitgabrio March 10, 2025 15:56
Copy link
Contributor

@bncriju bncriju left a comment

Choose a reason for hiding this comment

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

Thanks @ChinchuAjith for the PR. Have commented few minor review comments.

DMNImportsUtil.resolvePMMLImportType(model, input, relativeResource, dmnCompilerConfig);
assertThat(model.getPmmlImportInfo()).hasSize(1).containsOnlyKeys("test_tree");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be beneficial to include edge cases, such as:

  • An empty DMN file or one with invalid syntax.
  • A case where the import model is valid but contains errors or discrepancies in the expected structure.

import org.kie.dmn.core.compiler.ImportDMNResolverUtil;
import org.kie.dmn.core.compiler.ImportDMNResolverUtil.ImportType;
import org.kie.dmn.core.compiler.RuntimeTypeCheckOption;
import org.kie.dmn.core.compiler.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of asterisk and importing everything, import what exactly is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

static void checkLocatedDMNModel(Import i, DMNModel located, DMNModelImpl model, List<DMNModel> toMerge) {
if (located != null) {
String iAlias = Optional.ofNullable(i.getName()).orElse(located.getName());
// incubator-kie-issues#852: The idea is to not treat the anonymous models as import, but to "merge" them
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment regarding the incubator-kie-issues#852 is valuable but could be made clearer with a bit more context of the same

@yesamer yesamer changed the title DMNCompilerImpl class code refactoring and Test cases [incubator-kie-issues#1748] DMNCompilerImpl class code refactoring and Test cases Mar 18, 2025
@yesamer yesamer added the DMN label Mar 18, 2025
@kie-ci3
Copy link

kie-ci3 commented Mar 19, 2025

PR job #11 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-drools -u #6267 --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/drools/job/main/job/pullrequest_jobs/job/drools-pr/job/PR-6267/11/display/redirect

Test results:

  • PASSED: 23364
  • FAILED: 1

Those are the test failures:

org.kie.dmn.core.compiler.DMNCompilerImplTest.compileWithInvalidModel
Expecting actual not to be null

@kie-ci3
Copy link

kie-ci3 commented Mar 19, 2025

PR job #12 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-drools -u #6267 --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/drools/job/main/job/pullrequest_jobs/job/drools-pr/job/PR-6267/12/display/redirect

Test results:

  • PASSED: 23364
  • FAILED: 1

Those are the test failures:

org.kie.dmn.core.compiler.DMNCompilerImplTest.compileWithInvalidModel
Expecting actual not to be null

@ChinchuAjith ChinchuAjith requested a review from gitgabrio March 21, 2025 10:45
Copy link
Contributor

@gitgabrio gitgabrio left a comment

Choose a reason for hiding this comment

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

Thank @ChinchuAjith
Great stuf!! 👍

Copy link
Contributor

@yesamer yesamer left a comment

Choose a reason for hiding this comment

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

Nice refactoring @ChinchuAjith , well done!

@porcelli
Copy link
Member

@gitgabrio iirc, jenkins hasn't being used for PR checks for awhile

@gitgabrio gitgabrio merged commit 9da33cd into apache:main Mar 24, 2025
9 of 10 checks passed
saumya1singh pushed a commit to saumya1singh/drools that referenced this pull request Apr 3, 2025
…d Test cases (apache#6267)

* TestCases for DMNCompilerImpl class

* TestCases for DMNCompilerImpl class

* TestCases for DMNCompilerImpl class - changes in assertions

* TestCases for DMNCompilerImpl class - changes in assertions

* Changing Testcase names

* Refactoring Compile method

* Refactoring Compile method

* Refactoring Compile method

* Refactoring Compile method-Incorporating review comments, code cleanup

* Test cases for refactored method

* Review Comments fix

* Review Comments fix:replace if/else with switch in DMNCompilerImpl class

* [incubator-kie-issues#1748] Refactoring and unit testing DMNCompilerImpl#resolvePMMLImportType

* Review Comments fix

* Moving static classes to the Util class and Renaming the util class to DMNImportsUtil.

* Adding javaDoc

* Added test case for invalidDMN and mocked the static methods

* Added test case for invalidDMN and mocked the static methods

* [incubator-kie-issues#1748] Minor refactoring unit test

* Correcting dmn file name

* Adding Javadoc for newly created Methods

* Updating Javadoc for newly created Methods

---------

Co-authored-by: Gabriele-Cardosi <[email protected]>
@ChinchuAjith ChinchuAjith deleted the incubator-kie-issues#1748 branch July 2, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve DMNCompilerImpl class
7 participants