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

DMNCompilerImpl class code refactoring and Test cases #6267

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

ChinchuAjith
Copy link

No description provided.

@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! 👍

@@ -44,6 +44,7 @@

import javax.xml.namespace.QName;

import org.codehaus.plexus.util.CollectionUtils;
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls remove this import

Copy link
Author

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) {
Copy link
Contributor

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

Copy link
Author

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 ) {
Copy link
Contributor

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

Copy link
Author

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

Copy link
Contributor

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

Copy link
Author

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

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

Copy link
Author

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

Choose a reason for hiding this comment

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

Same as previous comment

Copy link
Author

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

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

Copy link
Author

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

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();

Copy link
Author

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

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();

Copy link
Author

Choose a reason for hiding this comment

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

Done

@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!

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.

3 participants