public class GuidedDTDRLPersistenceTest {
@Test
public void test2Rules() throws Exception {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableName( "michael" );
AttributeCol52 attr = new AttributeCol52();
attr.setAttribute( "salience" );
attr.setDefaultValue( new DTCellValue52( "66" ) );
dt.getAttributeCols().add( attr );
Pattern52 p1 = new Pattern52();
p1.setBoundName( "f1" );
p1.setFactType( "Driver" );
ConditionCol52 con = new ConditionCol52();
con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
con.setFactField( "age" );
con.setHeader( "Driver f1 age" );
con.setOperator( "==" );
p1.getChildColumns().add( con );
ConditionCol52 con2 = new ConditionCol52();
con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
con2.setFactField( "name" );
con2.setHeader( "Driver f1 name" );
con2.setOperator( "==" );
p1.getChildColumns().add( con2 );
ConditionCol52 con3 = new ConditionCol52();
con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
con3.setFactField( "rating" );
con3.setHeader( "Driver rating" );
con3.setOperator( "==" );
p1.getChildColumns().add( con3 );
dt.getConditions().add( p1 );
Pattern52 p2 = new Pattern52();
p2.setBoundName( "f2" );
p2.setFactType( "Driver" );
ConditionCol52 con4 = new ConditionCol52();
con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
con4.setHeader( "Driver 2 pimp" );
con4.setFactField( "(not needed)" );
p2.getChildColumns().add( con4 );
dt.getConditions().add( p2 );
ActionInsertFactCol52 ins = new ActionInsertFactCol52();
ins.setBoundName( "ins" );
ins.setFactType( "Cheese" );
ins.setFactField( "price" );
ins.setType( DataType.TYPE_NUMERIC_INTEGER );
dt.getActionCols().add( ins );
ActionRetractFactCol52 ret = new ActionRetractFactCol52();
dt.getActionCols().add( ret );
ActionSetFieldCol52 set = new ActionSetFieldCol52();
set.setBoundName( "f1" );
set.setFactField( "goo1" );
set.setType( DataType.TYPE_STRING );
dt.getActionCols().add( set );
ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
set2.setBoundName( "f1" );
set2.setFactField( "goo2" );
set2.setDefaultValue( new DTCellValue52( "whee" ) );
set2.setType( DataType.TYPE_STRING );
dt.getActionCols().add( set2 );
dt.setData( DataUtilities.makeDataLists( new String[][]{
new String[]{ "1", "desc", "42", "33", "michael", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", "f2" },
new String[]{ "2", "desc", "66", "39", "bob", "age * 0.3", "age > 7", "6.60", "", "gooVal1", "whee" }
} ) );
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();