This is an automated email from the ASF dual-hosted git repository.
tkobayas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-drools.git
The following commit(s) were added to refs/heads/main by this push:
new 1b022f1d61b [incubator-kie-drools-6802] follow-up on
DeclaredTypesTest.testExtend… (#6803)
1b022f1d61b is described below
commit 1b022f1d61ba2674d07739f01d6ddf91c37fcea3
Author: Toshiya Kobayashi <[email protected]>
AuthorDate: Tue Jul 14 17:58:19 2026 +0900
[incubator-kie-drools-6802] follow-up on DeclaredTypesTest.testExtend…
(#6803)
* [incubator-kie-drools-6802] follow-up on
DeclaredTypesTest.testExtendPojoInheritedFieldsConstructor
* apply copilot suggestion
---
.../drools/model/codegen/execmodel/DeclaredTypesTest.java | 14 ++++++++------
.../model/codegen/execmodel/domain/PositionalParent.java | 14 +++++++++++++-
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git
a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/DeclaredTypesTest.java
b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/DeclaredTypesTest.java
index 0bc143692e7..ea5d487cead 100644
---
a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/DeclaredTypesTest.java
+++
b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/DeclaredTypesTest.java
@@ -663,14 +663,16 @@ public class DeclaredTypesTest extends BaseModelTest {
}
@ParameterizedTest
- @MethodSource("parameters")
+ @MethodSource("parametersPatternOnly")
public void testExtendPojoInheritedFieldsConstructor(RUN_TYPE runType)
throws Exception {
// A declared type extending a Java (classpath) class must generate a
full-argument
// constructor that also includes the superclass @Position fields and
forwards them to
- // super(...). PositionalParent has @Position(0) name and @Position(1)
age, so Child should
- // expose Child(String name, int age, String dept). The executable
model previously omitted
- // the inherited fields, generating only Child(String dept), which
failed to compile the
- // 'new Child("Mario", 40, "Sales")' consequent.
+ // super(...). PositionalParent has @Position(0) name, @Position(1)
age, and @Position(2) salary,
+ // so Child should expose Child(String name, int age, long salary,
String dept). The executable
+ // model previously omitted the inherited fields, generating only
Child(String dept), which
+ // failed to compile the 'new Child("Mario", 40, 50L, "Sales")'
consequent.
+ // Note that in case of non-exec-model, a generated constructor arg
order doesn't respect @Position,
+ // which means non-deterministic. So this test is only for exec-model.
String str =
"package org.test;\n" +
"import " + PositionalParent.class.getCanonicalName() + ";\n" +
@@ -681,7 +683,7 @@ public class DeclaredTypesTest extends BaseModelTest {
"end\n" +
"rule Init when\n" +
"then\n" +
- " insert( new Child(\"Mario\", 40, \"Sales\") );\n" +
+ " insert( new Child(\"Mario\", 40, 50L, \"Sales\") );\n" +
"end\n" +
"rule Check when\n" +
" $c : Child( name == \"Mario\", age == 40, dept ==
\"Sales\" )\n" +
diff --git
a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/domain/PositionalParent.java
b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/domain/PositionalParent.java
index 70570848527..40be4498625 100644
---
a/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/domain/PositionalParent.java
+++
b/drools-model/drools-model-codegen/src/test/java/org/drools/model/codegen/execmodel/domain/PositionalParent.java
@@ -33,12 +33,16 @@ public class PositionalParent {
@Position(1)
private int age;
+ @Position(2)
+ private long salary;
+
public PositionalParent() {
}
- public PositionalParent(String name, int age) {
+ public PositionalParent(String name, int age, long salary) {
this.name = name;
this.age = age;
+ this.salary = salary;
}
public String getName() {
@@ -56,4 +60,12 @@ public class PositionalParent {
public void setAge(int age) {
this.age = age;
}
+
+ public long getSalary() {
+ return salary;
+ }
+
+ public void setSalary(long salary) {
+ this.salary = salary;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]