-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
DMNCompilerImpl class code refactoring and Test cases #6267
base: main
Are you sure you want to change the base?
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! 👍
@@ -44,6 +44,7 @@ | |||
|
|||
import javax.xml.namespace.QName; | |||
|
|||
import org.codehaus.plexus.util.CollectionUtils; |
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.
Pls remove this import
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
i.getImportType()); | ||
} | ||
for (Import i : dmndefs.getImport()) { | ||
if (ImportDMNResolverUtil.whichImportType(i) == ImportType.DMN) { |
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.
This if/else
could be replaced by switch
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.
Replaced with switch
return ctx; | ||
} | ||
|
||
private void iterateImports(Definitions dmndefs, Collection<DMNModel> dmnModels, DMNModelImpl model, Function<String, Reader> relativeResolver ) { |
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.
This method need to be tested, at least verify that elements are correctly iterated over
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 if/else inside this method have been replaced with switch case. Tested and is working fine now. Please review once and let me know if any further modification required here.
@@ -1,5 +1,5 @@ | |||
/** | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
|
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.
Pls remove this empty line
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
assertThat(model).isNotNull(); | ||
assertThat(model.getName()).isNotNull().isEqualTo(modelName); | ||
assertThat(model.getMessages()).isNotEmpty(); |
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.
THis test is error prone. It rely on the assumption that there is only one message, without checking it before. Please add assertion on model.getMessages()
size.
Please notice assertions on the same object could be chained
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
assertThat(model).isNotNull(); | ||
assertThat(model.getName()).isNotNull().isEqualTo(modelName); | ||
assertThat(model.getMessages()).isNotEmpty(); |
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.
Same as previous comment
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
DMNCompilerImpl.resolveDMNImportType(input, dmnModels, model, toMerge); | ||
assertThat(model.getMessages()).isEmpty(); | ||
assertThat(model.getImportAliasesForNS().entrySet().stream().findFirst().get().getValue().getLocalPart()).isNotNull().isEqualTo("Imported Model"); |
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.
Please add an assertion on the get()
invocation, or throw an exception
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. Added assertion on the get() invocation
assertThat(importingModel).isNotNull(); | ||
assertThat(importingModel.getNamespace()).isNotNull().isEqualTo(nameSpace); | ||
assertThat(toMerge.isEmpty()).isTrue(); |
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.
Pls replace with more idiomatic
assertThat(toMerge).isEmpty();
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.
Corrected
DMNCompilerImpl.checkLocatedDMNModel(input, located, model, toMerge); | ||
assertThat(emptyNamedModel).isNotNull(); | ||
assertThat(toMerge.isEmpty()).isFalse(); |
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.
Pls replace with more idiomatic
assertThat(toMerge).isNotEmpty();
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/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.java
Show resolved
Hide resolved
…mpl#resolvePMMLImportType
@ChinchuAjith Can you please describe the changes you applied in the first message? Thanks! |
No description provided.