Skip to content

Commit

Permalink
fix trait
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas committed Nov 1, 2024
1 parent ab5b3f6 commit e8f6a1c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void traitWithMixedInterfacesExtendingEachOther(VirtualPropertyMode mode)

"rule 'Bar Don'" +
"when " +
" $b : BarImpl(this isA Foo.class, this not isA Foo2.class)\n" +
" $b : BarImpl(this ##isA Foo.class, this not ##isA Foo2.class)\n" +
" String()\n" +
"then " +
" list.add(3); " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.List;

import org.drools.drl.parser.DrlParser;
import org.drools.traits.compiler.CommonTraitTest;
import org.drools.traits.compiler.ReviseTraitTestWithPRAlwaysCategory;
import org.drools.traits.core.factmodel.TraitFactoryImpl;
Expand Down Expand Up @@ -182,7 +183,7 @@ public void testTraitFieldUpdate1(VirtualPropertyMode mode) {

"rule \"test parent and child traits\" \n" +
"when\n" +
" $p : ParentTrait( $c : child isA ChildTrait.class )\n" +
" $p : ParentTrait( $c : child ##isA ChildTrait.class )\n" +
"then\n" +
" //shed ( $p , ParentTrait.class );\n"+
" list.add(\"correct\");\n"+
Expand Down Expand Up @@ -270,7 +271,7 @@ public void testTraitFieldUpdate2(VirtualPropertyMode mode) {
"when\n" +
" $c : Child( gender == \"male\" )\n" +
" $p : Parent( name == \"parent\" )\n" +
" ParentTrait( child not isA ChildTrait.class )\n" +
" ParentTrait( child not ##isA ChildTrait.class )\n" +
" ChildTrait()\n"+
"then\n" +
" " +
Expand All @@ -282,7 +283,7 @@ public void testTraitFieldUpdate2(VirtualPropertyMode mode) {

"rule \"test parent and child traits\" \n" +
"when\n" +
" $p : ParentTrait( child isA ChildTrait.class )\n" +
" $p : ParentTrait( child ##isA ChildTrait.class )\n" +
"then\n" +
" //shed ( $p , ParentTrait.class );\n"+
" list.add(\"correct\");\n"+
Expand Down Expand Up @@ -369,7 +370,7 @@ public void testTraitFieldUpdate3(VirtualPropertyMode mode) {
"when\n" +
" Child( gender == \"male\" )\n" +
" $p : Parent( name == \"parent\" )\n" +
" ParentTrait( child not isA ChildTrait.class )\n" +
" ParentTrait( child not ##isA ChildTrait.class )\n" +
" $c : ChildTrait()\n"+ //<<<<<
"then\n" +
" $p.setChild((Child)$c.getCore());\n"+ //<<<<<
Expand All @@ -379,7 +380,7 @@ public void testTraitFieldUpdate3(VirtualPropertyMode mode) {

"rule \"test parent and child traits\" \n" +
"when\n" +
" $p : ParentTrait( child isA ChildTrait.class )\n" +
" $p : ParentTrait( child ##isA ChildTrait.class )\n" +
"then\n" +
" //shed ( $p , ParentTrait.class );\n"+
" list.add(\"correct\");\n"+
Expand Down Expand Up @@ -448,7 +449,7 @@ public void testTraitFieldUpdate4(VirtualPropertyMode mode) {

"rule \"trait child\" \n" +
"when\n" +
" $p : Parent( $c := child not isA ChildTrait )\n"+
" $p : Parent( $c := child not ##isA ChildTrait )\n"+
" $c := Child( gender == \"male\" )\n" +
"then\n" +
" ChildTrait c = don ( $c , ChildTrait.class );\n" +
Expand All @@ -460,7 +461,7 @@ public void testTraitFieldUpdate4(VirtualPropertyMode mode) {

"rule \"test parent and a child trait\" \n" +
"when\n" +
" $p : Parent( child isA ChildTrait.class ) \n" + //<<<<<
" $p : Parent( child ##isA ChildTrait.class ) \n" + //<<<<<
"then\n" +
" list.add(\"correct\");\n"+
"end\n"+
Expand Down Expand Up @@ -545,7 +546,7 @@ public void testTraitFieldUpdate5(VirtualPropertyMode mode) {
"rule \"test parent and child traits\" \n" +
"\n" +
"when\n" +
" $p : ParentTrait( $c : child isA ChildTrait.class ) \n" + //<<<<<
" $p : ParentTrait( $c : child ##isA ChildTrait.class ) \n" + //<<<<<
"then\n" +
" list.add(\"correct\");\n"+
"end\n"+
Expand Down Expand Up @@ -627,14 +628,14 @@ public void testTraitFieldUpdate6(VirtualPropertyMode mode) {
"" +
"rule \"Side effect\" \n" +
"when \n" +
" $p : Parent( child isA ChildTrait ) \n" +
" $p : Parent( child ##isA ChildTrait ) \n" +
"then \n" +
" list.add(\"correct2\");\n"+
"end \n"+
"rule \"test parent and child traits\" \n" +
"\n" +
"when\n" +
" $p : ParentTrait( child isA ChildTrait.class )\n" +
" $p : ParentTrait( child ##isA ChildTrait.class )\n" +
"then\n" +
" //shed ( $p , ParentTrait.class );\n"+
" list.add(\"correct\");\n"+
Expand Down Expand Up @@ -720,7 +721,7 @@ public void testTraitFieldUpdate7(VirtualPropertyMode mode) {
"\n" +
"when\n" +
// " $c : Child( $gender := gender )\n"+
" $p : ParentTrait( child isA ChildTrait )\n" + //<<<<<
" $p : ParentTrait( child ##isA ChildTrait )\n" + //<<<<<
"then\n" +
" list.add(\"correct\");\n"+
"end\n"+
Expand Down Expand Up @@ -805,7 +806,7 @@ public void testTraitFieldUpdate8(VirtualPropertyMode mode) {
"rule \"test parent and child traits\" \n" +
"\n" +
"when\n" +
" $p : ParentTrait( child isA ChildTrait.class )\n" +
" $p : ParentTrait( child ##isA ChildTrait.class )\n" +
"then\n" +
" //shed ( $p , ParentTrait.class );\n"+
" list.add(\"correct\");\n"+
Expand Down Expand Up @@ -885,8 +886,8 @@ public void testTraitFieldUpdate9(VirtualPropertyMode mode) {
"rule \"trait and assign the child\" \n" +
"\n" +
"when\n" +
" $c : Child( gender == \"male\", this not isA ChildTrait )\n" +
" $p : Parent( this isA ParentTrait )\n" +
" $c : Child( gender == \"male\", this not ##isA ChildTrait )\n" +
" $p : Parent( this ##isA ParentTrait )\n" +
"then\n" +
" ChildTrait c = don ( $c , ChildTrait.class );\n"+ //<<<<<<
" modify($p){\n"+
Expand All @@ -897,7 +898,7 @@ public void testTraitFieldUpdate9(VirtualPropertyMode mode) {
"rule \"test parent and child traits\" \n" +
"\n" +
"when\n" +
" $p : ParentTrait( child isA ChildTrait.class, child.gender == \"male\" )\n" + //<<<<<
" $p : ParentTrait( child ##isA ChildTrait.class, child.gender == \"male\" )\n" + //<<<<<
"then\n" +
" //shed ( $p , ParentTrait.class );\n"+
" list.add(\"correct\");\n"+
Expand Down Expand Up @@ -978,8 +979,8 @@ public void testTraitFieldUpdate10(VirtualPropertyMode mode) {
"rule \"trait and assign the child\" \n" +
"\n" +
"when\n" +
" $c : Child( gender == \"male\", this not isA ChildTrait )\n" +
" $p : Parent( this isA ParentTrait )\n" +
" $c : Child( gender == \"male\", this not ##isA ChildTrait )\n" +
" $p : Parent( this ##isA ParentTrait )\n" +
"then\n" +
" ChildTrait c = don ( $c , ChildTrait.class );\n"+ //<<<<<<
" modify($p){\n"+
Expand Down Expand Up @@ -1103,7 +1104,7 @@ public void testTraitTwoParentOneChild(VirtualPropertyMode mode) {
"rule \"test three traits\" \n" +
"\n" +
"when\n" +
" $p : FatherTrait( this isA ParentTrait, this isA GrandParentTrait )\n" + //<<<<<
" $p : FatherTrait( this ##isA ParentTrait, this ##isA GrandParentTrait )\n" + //<<<<<
"then\n" +
" list.add(\"correct\");\n"+
"end\n"+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void testMapCore2( ) {
"rule Last \n" +
"salience -99 \n" +
"when \n" +
" $m : Map( this not isA StudentMap.class )\n" +
" $m : Map( this not ##isA StudentMap.class )\n" +
"then \n" +
" $m.put( \"final\", true );" +
"\n" +
Expand Down Expand Up @@ -451,7 +451,7 @@ public void testDrools216(){
"salience 1\n" +
"no-loop\n" +
"when\n" +
" $map : Map($stu : this[\"worker\"] isA Student.class)\n" +
" $map : Map($stu : this[\"worker\"] ##isA Student.class)\n" +
"then\n" +
" Object obj = don( $map , Worker.class );\n" +
" list.add(\"worker is donned\");\n" +
Expand Down Expand Up @@ -536,7 +536,7 @@ public void testDrools217(){
"salience 1\n" +
"no-loop\n" +
"when\n" +
" $map : Map($stu : this[\"worker\"], $stu isA Student.class)\n" +
" $map : Map($stu : this[\"worker\"], $stu ##isA Student.class)\n" +
"then\n" +
" Object obj = don( $map , Worker.class );\n" +
" list.add(\"worker is donned\");\n" +
Expand Down Expand Up @@ -629,7 +629,7 @@ public void testDrools218(){
"no-loop\n" +
"when\n" +
" $map : Map($stu : this[\"worker\"])\n" +
" Map($stu isA Student.class, this == $map)\n" +
" Map($stu ##isA Student.class, this == $map)\n" +
"then\n" +
" Object obj = don( $map , Worker.class );\n" +
" list.add(\"worker is donned\");\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void testIsAWith2KContainers() {
"\n" +
"rule \"create student\" \n" +
" when\n" +
" $student : Person( age < 26, this not isA Student )\n" +
" $student : Person( age < 26, this not ##isA Student )\n" +
" then\n" +
" Student s = don( $student, Student.class );\n" +
" s.setSchool(\"Masaryk University\");\n" +
Expand All @@ -181,7 +181,7 @@ public void testIsAWith2KContainers() {
"rule \"found student\"\n" +
" salience 10\n" +
" when\n" +
" student : Person( this isA Student )\n" +
" student : Person( this ##isA Student )\n" +
" then\n" +
" students.add(student);\n" +
"end";
Expand Down
2 changes: 2 additions & 0 deletions drools-traits/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<logger name="org.kie.api.internal.utils" level="info"/>
<!--<logger name="org.drools.ancompiler" level="info"/>-->

<logger name="org.drools.drl.parser.DrlParser" level="debug"/>

<root level="warn">
<appender-ref ref="consoleAppender" />
</root>
Expand Down

0 comments on commit e8f6a1c

Please sign in to comment.