@Test
//This test checks a Decision Table involving BRL columns is correctly converted into a RuleModel
public void testLHSWithBRLColumn_ParseToRuleModel() {
GuidedDecisionTable52 dtable = new GuidedDecisionTable52();
GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
//Row 0 should become an IPattern in the resulting RuleModel as it contains getValue()s for all Template fields in the BRL Column
//Row 1 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
//Row 2 should *NOT* become an IPattern in the resulting RuleModel as it does *NOT* contain getValue()s for all Template fields in the BRL Column
String[][] data = new String[][]{
new String[]{ "1", "desc", "Gargamel", "Pupa", "50" },
new String[]{ "2", "desc", "Gargamel", "", "50" },
new String[]{ "3", "desc", "Gargamel", "Pupa", "" }
};
//Simple (mandatory) columns
dtable.setRowNumberCol( new RowNumberCol52() );
dtable.setDescriptionCol( new DescriptionCol52() );
//Simple Condition
Pattern52 p1 = new Pattern52();
p1.setFactType( "Baddie" );
ConditionCol52 con = new ConditionCol52();
con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
con.setFactField( "name" );
con.setOperator( "==" );
p1.getChildColumns().add( con );
dtable.getConditions().add( p1 );
//BRL Column
BRLConditionColumn brl1 = new BRLConditionColumn();
//BRL Column definition
List<IPattern> brl1Definition = new ArrayList<IPattern>();
FactPattern brl1DefinitionFactPattern1 = new FactPattern( "Smurf" );
SingleFieldConstraint brl1DefinitionFactPattern1Constraint1 = new SingleFieldConstraint();
brl1DefinitionFactPattern1Constraint1.setFieldType( DataType.TYPE_STRING );
brl1DefinitionFactPattern1Constraint1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
brl1DefinitionFactPattern1Constraint1.setFieldName( "name" );
brl1DefinitionFactPattern1Constraint1.setOperator( "==" );
brl1DefinitionFactPattern1Constraint1.setValue( "$name" );
brl1DefinitionFactPattern1.addConstraint( brl1DefinitionFactPattern1Constraint1 );
SingleFieldConstraint brl1DefinitionFactPattern1Constraint2 = new SingleFieldConstraint();
brl1DefinitionFactPattern1Constraint2.setFieldType( DataType.TYPE_NUMERIC_INTEGER );
brl1DefinitionFactPattern1Constraint2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
brl1DefinitionFactPattern1Constraint2.setFieldName( "age" );
brl1DefinitionFactPattern1Constraint2.setOperator( "==" );
brl1DefinitionFactPattern1Constraint2.setValue( "$age" );
brl1DefinitionFactPattern1.addConstraint( brl1DefinitionFactPattern1Constraint2 );
brl1Definition.add( brl1DefinitionFactPattern1 );
brl1.setDefinition( brl1Definition );
//Setup BRL column bindings
BRLConditionVariableColumn brl1Variable1 = new BRLConditionVariableColumn( "$name",
DataType.TYPE_STRING,
"Person",
"name" );
brl1.getChildColumns().add( brl1Variable1 );
BRLConditionVariableColumn brl1Variable2 = new BRLConditionVariableColumn( "$age",
DataType.TYPE_NUMERIC_INTEGER,
"Person",
"age" );
brl1.getChildColumns().add( brl1Variable2 );
dtable.getConditions().add( brl1 );
//Now to test conversion
RuleModel rm = new RuleModel();
List<BaseColumn> allColumns = dtable.getExpandedColumns();
List<CompositeColumn<? extends BaseColumn>> allPatterns = dtable.getConditions();
List<List<DTCellValue52>> dtData = DataUtilities.makeDataLists( data );
//Row 0
List<DTCellValue52> dtRowData0 = DataUtilities.makeDataRowList( data[ 0 ] );
TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider( allColumns,