-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[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
[incubator-kie-issues#1748] DMNCompilerImpl class code refactoring and Test cases #6267
Conversation
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.
Good job @ChinchuAjith
There are only minor details to fix, IMO. Thanks! 👍
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
…mpl#resolvePMMLImportType
@ChinchuAjith Can you please describe the changes you applied in the first message? Thanks! |
@yesamer added description for the PR |
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.
Just a couple of minor details, then would be fine for me
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Outdated
Show resolved
Hide resolved
…o DMNImportsUtil.
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.
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"); | ||
} | ||
|
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 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.
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java
Outdated
Show resolved
Hide resolved
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.*; |
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.
Instead of asterisk and importing everything, import what exactly is required
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.
Done
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNImportsUtil.java
Show resolved
Hide resolved
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 |
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.
The comment regarding the incubator-kie-issues#852 is valuable but could be made clearer with a bit more context of the same
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNImportsUtil.java
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNImportsUtil.java
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNImportsUtil.java
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNImportsUtil.java
Show resolved
Hide resolved
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-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:
Those are the test failures: org.kie.dmn.core.compiler.DMNCompilerImplTest.compileWithInvalidModelExpecting actual not to be null |
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-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:
Those are the test failures: org.kie.dmn.core.compiler.DMNCompilerImplTest.compileWithInvalidModelExpecting actual not to be null |
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNCompilerImpl.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNImportsUtil.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNImportsUtil.java
Outdated
Show resolved
Hide resolved
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNImportsUtil.java
Outdated
Show resolved
Hide resolved
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.
Thank @ChinchuAjith
Great stuf!! 👍
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.
Nice refactoring @ChinchuAjith , well done!
@gitgabrio iirc, jenkins hasn't being used for PR checks for awhile |
…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]>
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.