Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
gitgabrio merged PR #6538: URL: https://github.com/apache/incubator-kie-drools/pull/6538 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
yesamer commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2589524160
##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java:
##
@@ -167,6 +167,39 @@ void actualCoerceValueCollectionToArray() {
assertThat(retrieved).isEqualTo(item);
}
+@Test
+void testCoerceValueToCollection() {
+Object item = "TESTED_OBJECT";
+Object value = Collections.singletonList(item);
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"string",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.STRING);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(value);
+}
+
+@Test
+void testCoerceValueToCollectionTypeAny() {
+Object item = "TESTED_OBJECT";
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"Any",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.UNKNOWN);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(item);
Review Comment:
@gitgabrio The scope of that test is to check the
`SimpleTypeImpl.UNKNOWN_DMNTYPE` (eg. Any) type scenario. We discovered that
type is always considered a collection (it looks weird to me, but that
assumption is present since the beginning of the DMN Engine). To summarize, if
the requiredType = ANY, the coercion shouldn't be applied.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
gitgabrio commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2589595247
##
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/util/CoerceUtil.java:
##
@@ -48,6 +49,11 @@ static Object actualCoerceValue(DMNType requiredType, Object
valueToCoerce) {
// and vice-versa
return ((Collection) valueToCoerce).toArray()[0];
}
+if (requiredType.isCollection() && !(valueToCoerce instanceof
Collection) &&
+(!(requiredType instanceof SimpleTypeImpl simpleType)
Review Comment:
🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
yesamer commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2589529064
##
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/util/CoerceUtil.java:
##
@@ -48,6 +49,11 @@ static Object actualCoerceValue(DMNType requiredType, Object
valueToCoerce) {
// and vice-versa
return ((Collection) valueToCoerce).toArray()[0];
}
+if (requiredType.isCollection() && !(valueToCoerce instanceof
Collection) &&
+(!(requiredType instanceof SimpleTypeImpl simpleType)
Review Comment:
@gitgabrio It's because of SimpleTypeImpl.UNKNOWN_DMNTYPE (eg. Any) type.
It's considered a collection.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
yesamer commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2589524160
##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java:
##
@@ -167,6 +167,39 @@ void actualCoerceValueCollectionToArray() {
assertThat(retrieved).isEqualTo(item);
}
+@Test
+void testCoerceValueToCollection() {
+Object item = "TESTED_OBJECT";
+Object value = Collections.singletonList(item);
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"string",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.STRING);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(value);
+}
+
+@Test
+void testCoerceValueToCollectionTypeAny() {
+Object item = "TESTED_OBJECT";
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"Any",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.UNKNOWN);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(item);
Review Comment:
@gitgabrio The scope of that test is to check the
`SimpleTypeImpl.UNKNOWN_DMNTYPE` (eg. Any) type scenario. We discover that type
is always considered a collection (it looks weird to me, but that assumption is
present since the beginning of the DMN Engine). To summarize, if the
requiredType = ANY, the coercion shouldn't be applied.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
yesamer commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2589529064
##
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/util/CoerceUtil.java:
##
@@ -48,6 +49,11 @@ static Object actualCoerceValue(DMNType requiredType, Object
valueToCoerce) {
// and vice-versa
return ((Collection) valueToCoerce).toArray()[0];
}
+if (requiredType.isCollection() && !(valueToCoerce instanceof
Collection) &&
+(!(requiredType instanceof SimpleTypeImpl simpleType)
Review Comment:
@gitgabrio It's because of `SimpleTypeImpl.UNKNOWN_DMNTYPE` (eg. Any) type.
It's considered a collection.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
yesamer commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2589524160
##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java:
##
@@ -167,6 +167,39 @@ void actualCoerceValueCollectionToArray() {
assertThat(retrieved).isEqualTo(item);
}
+@Test
+void testCoerceValueToCollection() {
+Object item = "TESTED_OBJECT";
+Object value = Collections.singletonList(item);
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"string",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.STRING);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(value);
+}
+
+@Test
+void testCoerceValueToCollectionTypeAny() {
+Object item = "TESTED_OBJECT";
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"Any",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.UNKNOWN);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(item);
Review Comment:
@gitgabrio The scope of that test is to check the
SimpleTypeImpl.UNKNOWN_DMNTYPE (eg. Any) type scenario. We discover that type
is always considered a collection (it looks weird to me, but that assumption is
present since the beginning of the DMN Engine). To summarize, if the
requiredType = ANY, the coercion shouldn't be applied.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
yesamer commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2589515632
##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java:
##
@@ -167,6 +167,39 @@ void actualCoerceValueCollectionToArray() {
assertThat(retrieved).isEqualTo(item);
}
+@Test
+void testCoerceValueToCollection() {
+Object item = "TESTED_OBJECT";
+Object value = Collections.singletonList(item);
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"string",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.STRING);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(value);
+}
+
+@Test
+void testCoerceValueToCollectionTypeAny() {
+Object item = "TESTED_OBJECT";
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
Review Comment:
@AthiraHari77 I would suggest to directly import
SimpleTypeImpl.UNKNOWN_DMNTYPE.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
yesamer commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2589507144
##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java:
##
@@ -167,6 +167,39 @@ void actualCoerceValueCollectionToArray() {
assertThat(retrieved).isEqualTo(item);
}
+@Test
+void testCoerceValueToCollection() {
+Object item = "TESTED_OBJECT";
+Object value = Collections.singletonList(item);
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"string",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.STRING);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(value);
+}
+
+@Test
+void testCoerceValueToCollectionTypeAny() {
Review Comment:
@AthiraHari77 Please rename it to `testCoerceUnknownType`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
gitgabrio commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2588687672
##
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/util/CoerceUtil.java:
##
@@ -48,6 +49,11 @@ static Object actualCoerceValue(DMNType requiredType, Object
valueToCoerce) {
// and vice-versa
return ((Collection) valueToCoerce).toArray()[0];
}
+if (requiredType.isCollection() && !(valueToCoerce instanceof
Collection) &&
+(!(requiredType instanceof SimpleTypeImpl simpleType)
Review Comment:
Hi @AthiraHari77
IIUC, it seems we can't have collections of SimpleType: why it is that ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
gitgabrio commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2588682349
##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/util/CoerceUtilTest.java:
##
@@ -167,6 +167,39 @@ void actualCoerceValueCollectionToArray() {
assertThat(retrieved).isEqualTo(item);
}
+@Test
+void testCoerceValueToCollection() {
+Object item = "TESTED_OBJECT";
+Object value = Collections.singletonList(item);
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"string",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.STRING);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(value);
+}
+
+@Test
+void testCoerceValueToCollectionTypeAny() {
+Object item = "TESTED_OBJECT";
+DMNType requiredType = new
SimpleTypeImpl("http://www.omg.org/spec/DMN/20180521/FEEL/";,
+"Any",
+null,
+true,
+null,
+null,
+null,
+BuiltInType.UNKNOWN);
+Object retrieved = CoerceUtil.actualCoerceValue(requiredType, item);
+assertThat(retrieved).isNotNull();
+assertThat(retrieved).isEqualTo(item);
Review Comment:
Hi @AthiraHari77
If the `requiredType` is a collection (as in this case), should not the
retrieved object be a collection too ? 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
kie-ci3 commented on PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#issuecomment-3607779781
**PR job** `#3` 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
https://github.com/apache/incubator-kie-drools/pull/6538 --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-6538/3/display/redirect
**Test results:**
- PASSED: 23966
- FAILED: 1
Those are the test failures:
https://ci-builds.apache.org/job/KIE/job/drools/job/main/job/pullrequest_jobs/job/drools-pr/job/PR-6538/3/testReport/org.kie.scanner/KieModuleIncrementalCompilationTest/testIncrementalCompilationFirstBuildHasErrors/";>org.kie.scanner.KieModuleIncrementalCompilationTest.testIncrementalCompilationFirstBuildHasErrors
org.eclipse.aether.collection.DependencyCollectionException: Failed to read
artifact descriptor for org.default:artifact:jar:1.0.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
AthiraHari77 commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2585330300
##
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/util/CoerceUtil.java:
##
@@ -48,6 +49,11 @@ static Object actualCoerceValue(DMNType requiredType, Object
valueToCoerce) {
// and vice-versa
return ((Collection) valueToCoerce).toArray()[0];
}
+if (requiredType.isCollection() && !(valueToCoerce instanceof
Collection) &&
Review Comment:
@yesamer Updated the tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
Copilot commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2585102980
##
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/util/CoerceUtil.java:
##
@@ -48,6 +49,11 @@ static Object actualCoerceValue(DMNType requiredType, Object
valueToCoerce) {
// and vice-versa
return ((Collection) valueToCoerce).toArray()[0];
}
+if (requiredType.isCollection() && !(valueToCoerce instanceof
Collection) &&
+(!(requiredType instanceof SimpleTypeImpl simpleType)
+|| simpleType.getFeelType() != BuiltInType.UNKNOWN)) {
+return Collections.singletonList(valueToCoerce);
+}
Review Comment:
The new coercion logic for wrapping non-collection values into singleton
lists lacks unit test coverage in CoerceUtilTest.java. Consider adding a test
case that verifies this behavior, similar to the existing
`actualCoerceValueCollectionToArray` test but in the opposite direction (e.g.,
`actualCoerceValueArrayToCollection`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] [Incubator kie issues#2158] Fix errors in implicit conversion for list type [incubator-kie-drools]
yesamer commented on code in PR #6538:
URL:
https://github.com/apache/incubator-kie-drools/pull/6538#discussion_r2585073985
##
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/util/CoerceUtil.java:
##
@@ -48,6 +49,11 @@ static Object actualCoerceValue(DMNType requiredType, Object
valueToCoerce) {
// and vice-versa
return ((Collection) valueToCoerce).toArray()[0];
}
+if (requiredType.isCollection() && !(valueToCoerce instanceof
Collection) &&
Review Comment:
@AthiraHari77 Do you think is it possibile to Unit test this change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
