use of org.drools.core.rule.ConsequenceMetaData in project drools by kiegroup.
the class RuleMetadataTest method testRetractWithFunction.
@Test
public void testRetractWithFunction() {
String rule1 = "retract( getA($a) );";
KieBase kbase = getKnowledgeBase(rule1);
RuleImpl rule = getRule(kbase, "R0");
ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData();
assertEquals(1, consequenceMetaData.getStatements().size());
ConsequenceMetaData.Statement statment = consequenceMetaData.getStatements().get(0);
assertEquals(ConsequenceMetaData.Statement.Type.RETRACT, statment.getType());
assertEquals("org.drools.A", statment.getFactClassName());
}
use of org.drools.core.rule.ConsequenceMetaData in project drools by kiegroup.
the class RuleMetadataTest method testInsert2.
@Test
public void testInsert2() {
String rule1 = "insert( new B(1, $ab) );";
KieBase kbase = getKnowledgeBase(rule1);
RuleImpl rule = getRule(kbase, "R0");
ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData();
assertEquals(1, consequenceMetaData.getStatements().size());
ConsequenceMetaData.Statement statment = consequenceMetaData.getStatements().get(0);
assertEquals(ConsequenceMetaData.Statement.Type.INSERT, statment.getType());
assertEquals(RuleMetadataTest.B.class.getName(), statment.getFactClassName());
}
use of org.drools.core.rule.ConsequenceMetaData in project drools by kiegroup.
the class RuleMetadataTest method testInsert.
@Test
public void testInsert() {
String rule1 = "insert( new A(1, $bb, \"3\") );";
KieBase kbase = getKnowledgeBase(rule1);
RuleImpl rule = getRule(kbase, "R0");
ConsequenceMetaData consequenceMetaData = rule.getConsequenceMetaData();
assertEquals(1, consequenceMetaData.getStatements().size());
ConsequenceMetaData.Statement statment = consequenceMetaData.getStatements().get(0);
assertEquals(ConsequenceMetaData.Statement.Type.INSERT, statment.getType());
assertEquals("org.drools.A", statment.getFactClassName());
assertEquals(3, statment.getFields().size());
ConsequenceMetaData.Field field1 = statment.getFields().get(0);
assertEquals("a", field1.getName());
assertEquals("1", field1.getValue());
assertTrue(field1.isLiteral());
ConsequenceMetaData.Field field2 = statment.getFields().get(1);
assertEquals("b", field2.getName());
assertEquals("$bb", field2.getValue());
assertFalse(field2.isLiteral());
ConsequenceMetaData.Field field3 = statment.getFields().get(2);
assertEquals("c", field3.getName());
assertEquals("\"3\"", field3.getValue());
assertTrue(field3.isLiteral());
}
Aggregations