use of org.kie.internal.builder.KnowledgeBuilder in project drools by kiegroup.
the class NamedConsequencesTest method testNonCompilingDuplicatedNamedConsequence.
@Test
public void testNonCompilingDuplicatedNamedConsequence() {
String str = "import org.drools.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + "rule R1 when\n" + " $a: Cheese ( type == \"stilton\" )\n" + " do[t1]\n" + " $b: Cheese ( type == \"cheddar\" )\n" + "then\n" + " results.add( $b.getType() );\n" + "then[t1]\n" + " results.add( $a.getType() );\n" + "then[t1]\n" + " results.add( $a.getType() );\n" + "end\n";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newByteArrayResource(str.getBytes()), ResourceType.DRL);
assertTrue(kbuilder.hasErrors());
}
use of org.kie.internal.builder.KnowledgeBuilder in project drools by kiegroup.
the class NamedConsequencesTest method testOutOfScopeNamedConsequences.
@Test
public void testOutOfScopeNamedConsequences() {
String str = "import org.drools.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + "rule R1 when\n" + " $a: Cheese ( type == \"stilton\" )\n" + " do[t1]\n" + " $b: Cheese ( type == \"cheddar\" )\n" + "then\n" + " results.add( $b.getType() );\n" + "then[t1]\n" + " results.add( $b.getType() );\n" + "end\n";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newByteArrayResource(str.getBytes()), ResourceType.DRL);
assertTrue(kbuilder.hasErrors());
}
use of org.kie.internal.builder.KnowledgeBuilder in project drools by kiegroup.
the class NamedConsequencesTest method testNonCompilingBreakingConsequences.
@Test
public void testNonCompilingBreakingConsequences() {
String str = "import org.drools.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + "rule R1 when\n" + " $a: Cheese ( type == \"stilton\" )\n" + " break[t1]\n" + " $b: Cheese ( type == \"cheddar\" )\n" + "then\n" + " results.add( $b.getType() );\n" + "then[t1]\n" + " results.add( $a.getType() );\n" + "end\n";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newByteArrayResource(str.getBytes()), ResourceType.DRL);
assertTrue(kbuilder.hasErrors());
}
use of org.kie.internal.builder.KnowledgeBuilder in project drools by kiegroup.
the class NamedConsequencesTest method testNonCompilingIFAfterOR.
@Test
public void testNonCompilingIFAfterOR() {
String str = "import org.drools.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + "rule R1 when\n" + " ( $a: Cheese ( type == \"stilton\" )\n" + " or\n" + " $a: Cheese ( type == \"gorgonzola\" ) )\n" + " if ( price > 10 ) do[t1]\n" + " $b: Cheese ( type == \"cheddar\" )\n" + "then\n" + " results.add( $b.getType() );\n" + "then[t1]\n" + " results.add( $a.getType() );\n" + "end\n";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newByteArrayResource(str.getBytes()), ResourceType.DRL);
assertTrue(kbuilder.hasErrors());
}
use of org.kie.internal.builder.KnowledgeBuilder in project drools by kiegroup.
the class NamedConsequencesTest method testOutOfScopeNamedConsequencesWithOr2.
@Test
public void testOutOfScopeNamedConsequencesWithOr2() {
String str = "import org.drools.compiler.Cheese;\n " + "global java.util.List results;\n" + "\n" + "rule R1 when\n" + " ( $a: Cheese ( type == \"stilton\" )\n" + " or\n" + " $b: Cheese ( type == \"gorgonzola\" ) do[t1] )\n" + " $c: Cheese ( type == \"cheddar\" )\n" + "then\n" + " results.add( $c.getType() );\n" + "then[t1]\n" + " results.add( $c.getType() );\n" + "end\n";
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newByteArrayResource(str.getBytes()), ResourceType.DRL);
assertTrue(kbuilder.hasErrors());
}
Aggregations