public class GuidedDTDRLPersistenceTest {
@Test
public void test2Rules() throws Exception {
GuidedDecisionTable dt = new GuidedDecisionTable();
dt.setTableName( "michael" );
AttributeCol attr = new AttributeCol();
attr.setAttribute( "salience" );
attr.setDefaultValue( "66" );
dt.getAttributeCols().add( attr );
ConditionCol con = new ConditionCol();
con.setBoundName( "f1" );
con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
con.setFactField( "age" );
con.setFactType( "Driver" );
con.setHeader( "Driver f1 age" );
con.setOperator( "==" );
dt.getConditionCols().add( con );
ConditionCol con2 = new ConditionCol();
con2.setBoundName( "f1" );
con2.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
con2.setFactField( "name" );
con2.setFactType( "Driver" );
con2.setHeader( "Driver f1 name" );
con2.setOperator( "==" );
dt.getConditionCols().add( con2 );
ConditionCol con3 = new ConditionCol();
con3.setBoundName( "f1" );
con3.setConstraintValueType( BaseSingleFieldConstraint.TYPE_RET_VALUE );
con3.setFactField( "rating" );
con3.setFactType( "Driver" );
con3.setHeader( "Driver rating" );
con3.setOperator( "==" );
dt.getConditionCols().add( con3 );
ConditionCol con4 = new ConditionCol();
con4.setBoundName( "f2" );
con4.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
con4.setFactType( "Driver" );
con4.setHeader( "Driver 2 pimp" );
con4.setFactField( "(not needed)" );
dt.getConditionCols().add( con4 );
ActionInsertFactCol ins = new ActionInsertFactCol();
ins.setBoundName( "ins" );
ins.setFactType( "Cheese" );
ins.setFactField( "price" );
ins.setType( SuggestionCompletionEngine.TYPE_NUMERIC );
dt.getActionCols().add( ins );
ActionRetractFactCol ret = new ActionRetractFactCol();
ret.setBoundName( "f2" );
dt.getActionCols().add( ret );
ActionSetFieldCol set = new ActionSetFieldCol();
set.setBoundName( "f1" );
set.setFactField( "goo1" );
set.setType( SuggestionCompletionEngine.TYPE_STRING );
dt.getActionCols().add( set );
ActionSetFieldCol set2 = new ActionSetFieldCol();
set2.setBoundName( "f1" );
set2.setFactField( "goo2" );
set2.setDefaultValue( "whee" );
set2.setType( SuggestionCompletionEngine.TYPE_STRING );
dt.getActionCols().add( set2 );
dt.setData( new String[][]{
new String[]{"1", "desc", "42", "33", "michael", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", null},
new String[]{"2", "desc", "", "39", "bob", "age * 0.3", "age > 7", "6.60", "", "gooVal1", ""}
} );
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();