Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-6867

Impact Analysis : support extends

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 7.66.0.Final
    • Impact Analysis
    • None
    • NEW
    • NEW

          @Test
          public void testExtends() {
              String str =
                      "package mypkg;\n" +
                           "import " + Person.class.getCanonicalName() + ";" +
                           "rule R1 when\n" +
                           "  $p1 : Person($address : address)\n" +
                           "then\n" +
                           "end\n" +
                           "rule R2 extends R1 when\n" +
                           "  $p2 : Person(this != $p1, $address.city == address.city)\n" +
                           "then\n" +
                           "  insert(\"Done\");\n" +
                           "end\n" +
                           "rule R3 when\n" +
                           "  $p : String(this == \"Done\")\n" +
                           "then\n" +
                           "end\n";
      
              Person p1 = new Person("John");
              p1.setAddress(new Address("A1"));
              Person p2 = new Person("Paul");
              p2.setAddress(new Address("A1"));
              runRule(str, p1, p2);
              
              AnalysisModel analysisModel = new ModelBuilder().build(str);
      
              ModelToGraphConverter converter = new ModelToGraphConverter();
              Graph graph = converter.toGraph(analysisModel);
      
              assertLink(graph, "mypkg.R1", "mypkg.R2");
              assertLink(graph, "mypkg.R2", "mypkg.R3", ReactivityType.POSITIVE);
          }
      

      fails with

      java.lang.RuntimeException: Unable to get KieModule, Errors Existed: Error Messages:
      Message [id=1, kieBase=defaultKieBase, level=ERROR, path=r0.drl, line=-1, column=0
         text=Unable to Analyse Expression $address.city == address.city:]
      ---
      Warning Messages:
      ---
      Info Messages:
      
      	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:520)
      	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:526)
      	at org.drools.compiler.kie.builder.impl.KieBuilderImpl.getKieModule(KieBuilderImpl.java:501)
      	at org.drools.impact.analysis.parser.ModelBuilder.build(ModelBuilder.java:32)
      	at org.drools.impact.analysis.integrationtests.DrlSyntaxTest.testExtends(DrlSyntaxTest.java:191)
      

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-tkobayas Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: